maunium-stickerpicker-nix/fetchers.nix

61 lines
1.6 KiB
Nix
Raw Normal View History

2023-01-02 01:18:49 +00:00
{ pkgs, lib, ... }: let
baseFetcher = { instructions, type, title, id ? "", dir }: let
dirname = "${type}-${dir}";
in ''
pushd $IMG_DIR
mkdir '${dirname}'
pushd '${dirname}'
${instructions}
popd
'';
in {
directory-deps = [ ];
directory-build = { src, id ? "", title ? "", ... }: baseFetcher {
inherit id title;
type = "directory";
dir = builtins.baseNameOf src;
instructions = ''
ln -s ${src}/* .
'';
};
chatsticker-deps = with pkgs; [ wget html-xml-utils ];
chatsticker-build = { name, id ? "", title ? "", ... }: baseFetcher {
inherit id title;
2023-05-13 22:13:13 +00:00
type = "chatsticker";
2023-01-02 01:18:49 +00:00
dir = name;
instructions = ''
wget "https://chatsticker.com/sticker/${name}" -O raw.html
hxnormalize -l 240 -x raw.html > normalized.html
cat normalized.html | hxselect -s '\n' -c ".img-fluid::attr(src)" > images.txt;
sed -i 's|;compress=true||' images.txt
for url in $(cat images.txt); do
wget $url
done
rm raw.html normalized.html images.txt
'';
};
2023-05-13 22:13:13 +00:00
stickers-cloud-deps = with pkgs; [ wget html-xml-utils ];
stickers-cloud-build = { name, id ? "", title ? "", ... }: baseFetcher {
inherit id title;
type = "stickers-cloud";
dir = name;
instructions = ''
wget "https://stickers.cloud/en/pack/${name}" -O raw.html
hxnormalize -l 240 -x raw.html > normalized.html
cat normalized.html | hxselect -s '\n' -c "img.d-block.image-ratio::attr(src)" > images.txt;
for url in $(cat images.txt); do
wget $url
done
rm raw.html normalized.html images.txt
'';
};
2023-01-02 01:18:49 +00:00
}