first
This commit is contained in:
parent
84ed0186f6
commit
1db3eacde9
98
pirokit
98
pirokit
@ -1,68 +1,60 @@
|
|||||||
#!/usr/bin/bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
mkdir -p $HOME/.cache/pirokit
|
#ensures there are no accidental downloads
|
||||||
|
set -eo pipefail
|
||||||
|
|
||||||
if [ -z $1 ]; then
|
baseurl="https://www.1377x.to/"
|
||||||
query=$(echo "" | dmenu -p "Search Torrent: ")
|
cachedir="$HOME/.cache/dl"
|
||||||
else
|
|
||||||
query=$1
|
|
||||||
fi
|
|
||||||
|
|
||||||
baseurl="https://1337x.to"
|
#get query from dmenu(later rofi)
|
||||||
cachedir="$HOME/.cache/pirokit"
|
query=$(echo "" | rofi -dmenu -p "Search Torrent" | sed 's/ /+/g')
|
||||||
query="$(sed 's/ /+/g' <<<$query)"
|
|
||||||
|
|
||||||
#curl -s https://1337x.to/category-search/$query/Movies/1/ > $cachedir/tmp.html
|
#setup working dir
|
||||||
curl -s https://1337x.to/search/$query/1/ > $cachedir/tmp.html
|
mkdir -p $cachedir
|
||||||
|
cd $cachedir
|
||||||
|
|
||||||
# Get Titles
|
curl -s $baseurl/search/$query/1/ -o tmp.html
|
||||||
grep -o '<a href="/torrent/.*</a>' $cachedir/tmp.html |
|
|
||||||
sed 's/<[^>]*>//g' > $cachedir/titles.bw
|
|
||||||
|
|
||||||
result_count=$(wc -l $cachedir/titles.bw | awk '{print $1}')
|
|
||||||
if [ "$result_count" -lt 1 ]; then
|
|
||||||
notify-send "😔 No Result found. Try again 🔴"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
# Seeders and Leechers
|
#get titles
|
||||||
grep -o '<td class="coll-2 seeds.*</td>\|<td class="coll-3 leeches.*</td>' $cachedir/tmp.html |
|
grep -o '<a href=./torrent/.*</a>' tmp.html |
|
||||||
sed 's/<[^>]*>//g' | sed 'N;s/\n/ /' > $cachedir/seedleech.bw
|
sed 's/<[^>]*>//g' > titles.bw #deletes tags
|
||||||
|
#get seeders
|
||||||
# Size
|
grep -P '<td class="coll-2 seeds">\d*</td>' tmp.html |
|
||||||
grep -o '<td class="coll-4 size.*</td>' $cachedir/tmp.html |
|
sed 's/<[^>]*>//g' > seeders.bw
|
||||||
sed 's/<span class="seeds">.*<\/span>//g' |
|
#get leechers
|
||||||
sed -e 's/<[^>]*>//g' > $cachedir/size.bw
|
grep -P '<td class="coll-3 leeches">\d*</td>' tmp.html |
|
||||||
|
sed 's/<[^>]*>//g' > leechers.bw
|
||||||
# Links
|
#get sizes
|
||||||
grep -E '/torrent/' $cachedir/tmp.html |
|
grep -P '<td class="coll-4 size mob-uploader">.*</td>' tmp.html |
|
||||||
|
sed 's/<[^>]*>//g' > sizes.bw
|
||||||
|
#get links
|
||||||
|
grep -E '/torrent/' tmp.html |
|
||||||
sed -E 's#.*(/torrent/.*)/">.*/#\1#' |
|
sed -E 's#.*(/torrent/.*)/">.*/#\1#' |
|
||||||
sed 's/td>//g' > $cachedir/links.bw
|
sed 's/td>//g' > links.bw
|
||||||
|
|
||||||
|
#generates line numbers
|
||||||
|
awk '{print NR " - "$0""}' titles.bw > titlesNumbered.bw
|
||||||
|
|
||||||
|
#gets line number (that groupthe user selected in dmenu)
|
||||||
|
LINE=$(paste -d\| titlesNumbered.bw seeders.bw leechers.bw sizes.bw |
|
||||||
|
rofi -dmenu -i -l 25 |
|
||||||
|
cut -d- -f1
|
||||||
|
)
|
||||||
|
|
||||||
# Clearning up some data to display
|
suburl=$(sed "${LINE}q;d" links.bw)
|
||||||
sed 's/\./ /g; s/\-/ /g' $cachedir/titles.bw |
|
url="$baseurl$suburl/"
|
||||||
sed 's/[^A-Za-z0-9 ]//g' | tr -s " " > $cachedir/tmp && mv $cachedir/tmp $cachedir/titles.bw
|
|
||||||
|
|
||||||
awk '{print NR " - ["$0"]"}' $cachedir/size.bw > $cachedir/tmp && mv $cachedir/tmp $cachedir/size.bw
|
#get page that contains magnet link
|
||||||
awk '{print "[S:"$1 ", L:"$2"]" }' $cachedir/seedleech.bw > $cachedir/tmp && mv $cachedir/tmp $cachedir/seedleech.bw
|
curl -s $url > tmp.html
|
||||||
|
|
||||||
# Getting the line number
|
#scrape magnet link
|
||||||
LINE=$(paste -d\ $cachedir/size.bw $cachedir/seedleech.bw $cachedir/titles.bw |
|
magnet=$(paste tmp.html |
|
||||||
dmenu -i -l 25 |
|
tr -d '\n' |
|
||||||
cut -d\- -f1 |
|
sed -E 's#.*(magnet:\?xt=urn:btih:[^"]*).*#\1#'
|
||||||
awk '{$1=$1; print}')
|
)
|
||||||
|
|
||||||
url=$(head -n $LINE $cachedir/links.bw | tail -n +$LINE)
|
deluge-console add $magnet
|
||||||
fullURL="${baseurl}${url}/"
|
|
||||||
|
|
||||||
# Requesting page for magnet link
|
#notify the user that the download has started
|
||||||
curl -s $fullURL > $cachedir/tmp.html
|
notify-send "⬇️ download started ⬇️"
|
||||||
magnet=$(grep -Po "magnet:\?xt=urn:btih:[a-zA-Z0-9]*" $cachedir/tmp.html | head -n 1)
|
|
||||||
|
|
||||||
deluge-console add "$magnet"
|
|
||||||
|
|
||||||
# Simple notification
|
|
||||||
notify-send "⬇️ Start downloading File 📁"
|
|
||||||
|
Loading…
Reference in New Issue
Block a user