-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvid-download
executable file
·42 lines (37 loc) · 1.12 KB
/
vid-download
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
url=""
quality=""
arguments=""
helperPath=`dirname "$0"`
#Function for getting arguments for the downloader
providearguments(){
arguments=`echo -e 'no\n-k 1M -x 5' |dmenu -i -fn 'roboto mono nerd font:bold:size=11' -p "arguments"`
[[ $arguments = "" ]] && exit 0
}
#Function to select url from clipboard.
#greenclip is here a clipboard manager.
selecturl(){
url=`greenclip print | xargs -0 | $helperPath/extract |dmenu -i -l 10 -fn 'roboto mono nerd font:bold:size=11' -p "Select url"`
[[ $url = "" ]] && exit 0
}
#function to use youtube-dl to fetch quality of videos.
selectquality(){
quality=`notify-send "Fetching" "video quality" | youtube-dl -F $url | \
sed -n '7,50p' | \
dmenu -i -l 10 -fn 'roboto mono nerd font:bold:size=11' -p "Select quality" | \
awk '{print $1;}'`
[[ $quality = "" ]] && exit 0
}
main(){
selecturl
selectquality
providearguments
quality=`echo $quality | sed 's/ /+/'`
if [[ $arguments = "no" ]]
then
youtube-dl -f $quality --external-downloader aria2c $url
else
echo "$arguments"
youtube-dl -f $quality --external-downloader aria2c --external-downloader-args "$arguments" $url
fi
}
main