blob: f0fbb88521b48b09fee531d7e3b8b9a98a738948 (
plain) (
blame)
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
|
#!/bin/sh
# https://sinanmohd.com
####################
## user variables ##
####################
# dir where files are stored
store_path="${HOME}"/.cache/pirowatch
# torrent port
torrent_port=49110
# dht port
dht_port=49130
get_selection() {
list=$(webtorrent --mpv -o "$HOME"/.cache/pirowatch --torrent-port "$torrent_port" --dht-port "$dht_port" "$1" --select |
grep -i ".mp4\|.mkv\|.webm\|.avi\|.mov\|.flac\|.opus\|.mp3\|.flac\|.wav")
if [ "$(echo "$list" | wc -l)" = 1 ]; then
printf "%s" "$list" | cut -d ' ' -f 1
else
printf "%s" "$list" | dmenu -p " " -l 25 | cut -d ' ' -f 1
fi
}
start_stream() {
webtorrent --mpv -o "$store_path" --torrent-port "$torrent_port" --dht-port "$dht_port" "$1" --select "$2"
}
if [ -z "$1" ]; then
magnet=$(find "$DOWNLOADS" -type f -name "*.torrent" | dmenu -p " " -l 25)
[ -z "$magnet" ] && exit
else
magnet="$1"
fi
selection=$(get_selection "$magnet")
if [ -z "$selection" ]; then
exit
else
notify-send " Connecting to peers" "please wait for few seconds"
start_stream "$magnet" "$selection"
fi
|