forked from Bugswriter/notflix
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathnotflix
executable file
·84 lines (64 loc) · 2.38 KB
/
notflix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/bin/sh
# Dependencies - webtorrent, mpv
mkdir -p $HOME/.cache/notflix
menu="dmenu -i -l 25"
baseurl="https://1337x.wtf"
cachedir="$HOME/.cache/notflix"
category=$(dmenu -p "Movies? TV? Documentaries? Anime? (1,2,3,4): " <&-)
case $category in
"1") category="Movies";;
"2") category="TV";;
"3") category="Documentaries";;
"4") category="Anime";;
*) category="Movies";;
esac
if [ -z $1 ]; then
query=$(dmenu -p "Search Torrent: " <&-)
else
query=$1
fi
query="$(echo $query | sed 's/ /+/g')"
curl -s https://1337x.to/category-search/$query/$category/1/ > $cachedir/tmp.html
#curl -s $baseurl/search/$query/Movies/1/ > $cachedir/tmp.html
# Get Titles
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" -i "NONE"
exit 0
fi
# Seeders and Leechers
grep -o '<td class="coll-2 seeds.*</td>\|<td class="coll-3 leeches.*</td>' $cachedir/tmp.html |
sed 's/<[^>]*>//g' | sed 'N;s/\n/ /' > $cachedir/seedleech.bw
# Size
grep -o '<td class="coll-4 size.*</td>' $cachedir/tmp.html |
sed 's/<span class="seeds">.*<\/span>//g' |
sed -e 's/<[^>]*>//g' > $cachedir/size.bw
# Links
grep -E '/torrent/' $cachedir/tmp.html |
sed -E 's#.*(/torrent/.*)/">.*/#\1#' |
sed 's/td>//g' > $cachedir/links.bw
# Clearning up some data to display
sed 's/\./ /g; s/\-/ /g' $cachedir/titles.bw |
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
awk '{print "[S:"$1 ", L:"$2"]" }' $cachedir/seedleech.bw > $cachedir/tmp && mv $cachedir/tmp $cachedir/seedleech.bw
# Getting the line number
LINE=$(paste -d\ $cachedir/size.bw $cachedir/seedleech.bw $cachedir/titles.bw |
$menu |
cut -d\- -f1 |
awk '{$1=$1; print}')
if [ -z "$LINE" ]; then
notify-send "No Result selected. Exiting..." -i "NONE"
exit 0
fi
notify-send "Searching Magnet seeds" -i "NONE"
url=$(head -n $LINE $cachedir/links.bw | tail -n +$LINE)
fullURL="${baseurl}${url}/"
# Requesting page for magnet link
curl -s $fullURL > $cachedir/tmp.html
magnet=$(grep -Po "magnet:\?xt=urn:btih:[a-zA-Z0-9]*" $cachedir/tmp.html | head -n 1)
webtorrent "$magnet" --mpv
# Simple notification
notify-send "Enjoy Watching" -i "NONE"