simplify, use transmission, added category search.

This commit is contained in:
Crony Akatsuki 2022-08-01 18:11:40 +02:00
parent 1db3eacde9
commit ded1907f2e

47
pirokit
View File

@ -6,41 +6,41 @@ set -eo pipefail
baseurl="https://www.1377x.to/" baseurl="https://www.1377x.to/"
cachedir="$HOME/.cache/dl" cachedir="$HOME/.cache/dl"
#get query from dmenu(later rofi) #get query from dmenu
query=$(echo "" | rofi -dmenu -p "Search Torrent" | sed 's/ /+/g') query=$(printf '%s' | dmenu -p "Search Torrent:" | sed 's/ /+/g')
#setup working dir #setup working dir
mkdir -p $cachedir mkdir -p $cachedir
cd $cachedir cd $cachedir
curl -s $baseurl/search/$query/1/ -o tmp.html case "$(printf "All\\nMovies\\nTV\\nGames\\nMusic\\nApplications\\nDocumentaries\\nOther" | dmenu -p "Category to search in: ")" in
All) curl -s $baseurl/search/$query/1/ -o tmp.html;;
Movies) curl -s $baseurl/category-search/$query/Movies/1/ -o tmp.html ;;
TV) curl -s $baseurl/category-search/$query/TV/1/ -o tmp.html ;;
Games) curl -s $baseurl/category-search/$query/Games/1/ -o tmp.html ;;
Music) curl -s $baseurl/category-search/$query/Music/1/ -o tmp.html ;;
Applications) curl -s $baseurl/category-search/$query/Apps/1/ -o tmp.html ;;
Documentaries) curl -s $baseurl/category-search/$query/Documentaries/1/ -o tmp.html ;;
Other) curl -s $baseurl/category-search/$query/Other/1/ -o tmp.html ;;
*) exit ;;
esac
#get titles #get titles
grep -o '<a href=./torrent/.*</a>' tmp.html | grep -o '<a href=./torrent/.*</a>' tmp.html | sed 's/<[^>]*>//g' > titles.bw #deletes tags
sed 's/<[^>]*>//g' > titles.bw #deletes tags
#get seeders #get seeders
grep -P '<td class="coll-2 seeds">\d*</td>' tmp.html | grep -P '<td class="coll-2 seeds">\d*</td>' tmp.html | sed 's/<[^>]*>//g' > seeders.bw
sed 's/<[^>]*>//g' > seeders.bw
#get leechers #get leechers
grep -P '<td class="coll-3 leeches">\d*</td>' tmp.html | grep -P '<td class="coll-3 leeches">\d*</td>' tmp.html | sed 's/<[^>]*>//g' > leechers.bw
sed 's/<[^>]*>//g' > leechers.bw
#get sizes #get sizes
grep -P '<td class="coll-4 size mob-uploader">.*</td>' tmp.html | grep -P '<td class="coll-4 size mob-uploader">.*</td>' tmp.html | sed 's/<[^>]*>//g' > sizes.bw
sed 's/<[^>]*>//g' > sizes.bw
#get links #get links
grep -E '/torrent/' tmp.html | grep -E '/torrent/' tmp.html | sed -E 's#.*(/torrent/.*)/">.*/#\1#' | sed 's/td>//g' > links.bw
sed -E 's#.*(/torrent/.*)/">.*/#\1#' |
sed 's/td>//g' > links.bw
#generates line numbers #generates line numbers
awk '{print NR " - "$0""}' titles.bw > titlesNumbered.bw awk '{print NR " - "$0""}' titles.bw > titlesNumbered.bw
#gets line number (that groupthe user selected in dmenu) #gets line number (that groupthe user selected in dmenu)
LINE=$(paste -d\| titlesNumbered.bw seeders.bw leechers.bw sizes.bw | LINE=$(paste -d\| titlesNumbered.bw seeders.bw leechers.bw sizes.bw | dmenu -i -l 25 | cut -d- -f1)
rofi -dmenu -i -l 25 |
cut -d- -f1
)
suburl=$(sed "${LINE}q;d" links.bw) suburl=$(sed "${LINE}q;d" links.bw)
url="$baseurl$suburl/" url="$baseurl$suburl/"
@ -49,12 +49,9 @@ url="$baseurl$suburl/"
curl -s $url > tmp.html curl -s $url > tmp.html
#scrape magnet link #scrape magnet link
magnet=$(paste tmp.html | magnet=$(paste tmp.html | tr -d '\n' | sed -E 's#.*(magnet:\?xt=urn:btih:[^"]*).*#\1#')
tr -d '\n' |
sed -E 's#.*(magnet:\?xt=urn:btih:[^"]*).*#\1#'
)
deluge-console add $magnet transmission-remote -a $magnet
#notify the user that the download has started #notify the user that the download has started
notify-send "⬇️ download started ⬇️" quick-notify "Pirokit" "Download Started"