summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlassulus <git@lassul.us>2023-09-04 13:50:34 +0200
committerlassulus <git@lassul.us>2023-09-04 13:50:34 +0200
commite8821a74cc8a37065400df63ba3493216034c44c (patch)
tree699ead7c3681dfbaa92468497e0f2f58a3af714e
parentda71141921958d50e6845ccbdad08a117c7d9be4 (diff)
l: init dl
-rw-r--r--lass/5pkgs/dl/default.nix29
1 files changed, 29 insertions, 0 deletions
diff --git a/lass/5pkgs/dl/default.nix b/lass/5pkgs/dl/default.nix
new file mode 100644
index 000000000..69f2b8c45
--- /dev/null
+++ b/lass/5pkgs/dl/default.nix
@@ -0,0 +1,29 @@
+{ pkgs }:
+pkgs.writers.writeBashBin "dl" ''
+ set -efux
+ LINK_OR_SEARCH=$@
+ if [[ $LINK_OR_SEARCH == magnet:?* ]] || [[ $LINK_OR_SEARCH =~ ^https?: ]]; then
+ LINK=$LINK_OR_SEARCH
+ else
+ SEARCH=$LINK_OR_SEARCH
+ fi
+
+ if ! [ -z ''${SEARCH+x} ]; then
+ LINK=$(${pkgs.we-get}/bin/we-get -n 50 -t the_pirate_bay,1337x --json -s "$SEARCH" |
+ ${pkgs.jq}/bin/jq -r 'to_entries |
+ .[] |
+ "\(.key) [\(.value.seeds)]\t\(.value.link)"
+ ' |
+ ${pkgs.fzf}/bin/fzf -d '\t' --with-nth=1 |
+ ${pkgs.coreutils}/bin/cut -f 2
+ )
+ fi
+
+ if [ -z ''${CATEGORY+x} ]; then
+ CATEGORY=$(echo -e 'movies\nseries' | ${pkgs.fzf}/bin/fzf)
+ fi
+
+ ${pkgs.transmission}/bin/transmission-remote yellow.r \
+ -w /var/download/finished/sorted/"$CATEGORY" \
+ -a "$LINK"
+''