This repository has no description
792 B
29 lines
1{ pkgs }:
2pkgs.writers.writeBashBin "dl" ''
3 set -efux
4 LINK_OR_SEARCH=$@
5 if [[ $LINK_OR_SEARCH == magnet:?* ]] || [[ $LINK_OR_SEARCH =~ ^https?: ]]; then
6 LINK=$LINK_OR_SEARCH
7 else
8 SEARCH=$LINK_OR_SEARCH
9 fi
10
11 if ! [ -z ''${SEARCH+x} ]; then
12 LINK=$(${pkgs.we-get}/bin/we-get -n 50 -t the_pirate_bay,1337x --json -s "$SEARCH" |
13 ${pkgs.jq}/bin/jq -r 'to_entries |
14 .[] |
15 "\(.key) [\(.value.seeds)]\t\(.value.link)"
16 ' |
17 ${pkgs.fzf}/bin/fzf -d '\t' --with-nth=1 |
18 ${pkgs.coreutils}/bin/cut -f 2
19 )
20 fi
21
22 if [ -z ''${CATEGORY+x} ]; then
23 CATEGORY=$(echo -e 'movies\nseries' | ${pkgs.fzf}/bin/fzf)
24 fi
25
26 ${pkgs.transmission}/bin/transmission-remote yellow.r \
27 -w /var/download/finished/sorted/"$CATEGORY" \
28 -a "$LINK"
29''