blob: ff69aede03d2185fd87ad163ddf3bacaee4325b9 (
plain)
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
|
#!/bin/sh
while getopts "s:v:S:V" flag
do
case $flag in
s) use=sound && link=$OPTARG ;;
v) use=video && link=$OPTARG;;
S) use=batch_sound ;;
V) use=batch_video ;;
esac
done
vidselect() {
:> ~/.cache/vid_sload/list &&
dl_links=$(cat ~/.cache/dl_list | gsed 's/https.*v=//g' | gsed -z 's/\n/\|/g' | sed 's/\|$//g') &&
num=1
for line in $(cat ~/.cache/view_hist)
do
(echo "$line" | grep -q -E $dl_links &&
printf '[X] %s\n' "$line" ||
printf '[%s] %s\n' "$num" "$line") >> ~/.cache/vid_sload/list
num=$((( $num+1 )))
done && cat ~/.cache/vid_sload/list &&
echo "####################################" &&
echo "Add video to list (a), download (s/v/l) or exit?" &&
read ans;
mode=$(echo $ans | gsed 's/\s.*//g') &&
argnam=$(echo $ans | sed 's/^.//g') &&
vidlink=$(grep $argnam ~/.cache/vid_sload/list | gsed 's/^.*\]\s//' | gsed 's/^.*\*\*\*//g')
cd ~/Downloads
if [ $mode == 'a' ]; then
echo $vidlink >> ~/.cache/dl_list
echo $vidlink
reload
elif [ $mode == 's' ]; then
yt-dlp -x -w -c --add-chapters --prefer-free-formats $vidlink && exit
elif [ $mode == 'v' ]; then
yt-dlp -f 'bestvideo[height<=480]+bestaudio/best[height<=360]/best[height<=720]/best' -w -c --add-chapters --prefer-free-formats $vidlink && exit
elif [ $mode == 'l' ] ; then
yt-dlp -f 'bestvideo[height<=480]+bestaudio/best[height<=360]/best[height<=720]/best' -w -c --add-chapters --prefer-free-formats -a ~/.cache/dl_list && rm ~/.cache/dl_list && touch ~/.cache/dl_list && exit
elif [ $mode == 'exit' ] ; then
exit
else
echo "Unknown option: Please try again."
fi
}
reload() {
clear
vidselect
}
if [ -z "$1" ]
then
vidselect
else
cd ~/Downloads
case $use in
sound)
yt-dlp -x -w -c --add-chapters --prefer-free-formats $link && exit;;
video)
yt-dlp -f 'bestvideo[height<=480]+bestaudio/best[height<=360]/best[height<=720]/best' -w -c --add-chapters --prefer-free-formats $link && exit;;
batch_sound)
yt-dlp -x -w -c --prefer-free-formats -a ~/.cache/dl_list && rm ~/.cache/dl_list && touch ~/.cache/dl_list && exit ;;
batch_video)
yt-dlp -f 'bestvideo[height<=480]+bestaudio/best[height<=360]/best[height<=720]/best' -w -c --add-chapters --prefer-free-formats -a ~/.cache/dl_list && rm ~/.cache/dl_list && touch ~/.cache/dl_list && exit ;;
esac
fi
|