-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnotflix
executable file
·53 lines (39 loc) · 1.37 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
#!/usr/bin/env sh
dir=~/Desktop/movie
# quary piratebay
query=$(rofi -dmenu -p "Search Torrent: " <&- | sed -e 's/ /%20/g')
echo $query
curl -s https://thepiratebay.party/search/$query/1/99/0 > $dir/tmp.html
# get titles
grep -o '<a href="https://thepiratebay.party/torrent/.*</a>' $dir/tmp.html |
sed 's/<[^>]*>//g' > $dir/titles.bw
# get movie size and clean them
grep -o '<td align=.* .*</td>' $dir/tmp.html | sed 's/ //g'| sed -e 's/<[^>]*>//g' > $dir/size.bw
awk '{print NR " - ["$0"]"}' $dir/size.bw > tmp && mv tmp $dir/size.bw
# get links
grep -Eo "magnet:\?xt=urn:btih:[a-zA-Z0-9]*" $dir/tmp.html | sed -s '' > $dir/links.bw
# launch dmenu and get magnet link
menu="rofi -dmenu -i -l 25"
LINE=$(paste -d\ $dir/size.bw $dir/titles.bw |
$menu |
cut -d\- -f1 |
awk '{$1=$1; print}')
url=$(head -n $LINE $dir/links.bw | tail -n +$LINE)
# ask is you mant to stream or download the movie
if [ -z $1 ]; then
stream=$(rofi -dmenu -p "stream or download: " <&-)
else
stream=$2
fi
echo $url
if [[ "$stream" == 'stream' ]]; then
# Simple notification
notify-send "🎥 Enjoy Watching ☺️ " -i "NONE"
peerflix -k "$url"
#fi [[ "$stream" == 'url' ]]; then
#echo $url
else
# Simple notification
notify-send "🎥 Downloading torrent to current dir: $PWD " -i "NONE"
peerflix --path /home/hqnw/Desktop/movie "$url"
fi