-
Notifications
You must be signed in to change notification settings - Fork 0
/
.dv
82 lines (74 loc) · 2.74 KB
/
.dv
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
#!/bin/bash
#
# Downloads videos in 720p, 480p, etc. if availible
# -o '%(title)s.%(ext)s'
dv() {
if [ $# = '0' ]; then
cat <<HELP_USAGE
Welcome to Yet Another Video Downloader!
USAGE:
$0 <quality> <link> [localization] [extra]
quality Max quality of the video, e.g. 240, 360, etc
link Link of the video, the id or full name of the youtube video. see
youtube-dl readme for more info:
https://github.com/ytdl-org/youtube-dl
localization Localization of the downloaded file, defaults to '~/Downloads'.
extra Currently it only accepts two options, and it can't be mixed:
w Downloads the video with the worst audio available
nv No video, downloads only audio
na No audio, downloads only video
mp4 Download video in MP4 format
Current Aliases:
alias dv2="dv 240"
alias dv3="dv 360"
...
alias dv10="dv 1080"
Note:
You cannot change the order of the arguments, because I'm lazy, but I accept PRs!
https://github.com/EGA-SUPREMO/dotfiles
HELP_USAGE
else # Dont know how to exit program without closing tab when using oh my zsh
FORMAT="-f bestaudio+bestvideo[height<=${1}]/best=[height<=${1}]"
case $4 in
*"mp4"*)
FORMAT="bestvideo[ext=mp4][height<=${1}]+bestaudio[ext=m4a]/best=[ext=mp4][height<=${1}]"
;;
*"w"*)
if [[ $3 = '~m' ]]; then
echo -n "are you sure you want to download a music with worstaudio? press Ctrl+C or wait 10 seconds" && sleep 10s
fi
FORMAT="-f bestvideo[height<=${1}]+worstaudio/best=[height<=${1}]"
;;
*"s"*)
youtube-dl --skip-download $2 --write-sub --sub-lang en,es
;;
*"nv"*)
FORMAT="-f bestaudio"
;;
*"na"*)
FORMAT="-f bestvideo[height<=${1}]"
;;
*)
FORMAT="-f bestvideo[height<=${1}]+bestaudio/best=[height<=${1}]"
;;
esac
cd ${3-~/Downloads} && youtube-dl -R 'infinite' $FORMAT $2
fi
}
alias dv2="dv 240"
alias dv3="dv 360"
alias dv4="dv 480"
alias dv7="dv 720"
alias dv10="dv 1080"
# 'aliases' to download music without needing to tell the dir
dv2m() { dv2 $1 ~/Music $2; }
dv3m() { dv3 $1 ~/Music $2; }
dv4m() { dv4 $1 ~/Music $2; }
dv7m() { dv7 $1 ~/Music $2; }
dv10m() { dv10 $1 ~/Music $2; }
# 'aliases' to download videos without needing to tell the dir
dv2v() { dv2 $1 ~/Videos $2; }
dv3v() { dv3 $1 ~/Videos $2; }
dv4v() { dv4 $1 ~/Videos $2; }
dv7v() { dv7 $1 ~/Videos $2; }
dv10v() { dv10 $1 ~/Videos $2; }