-
Notifications
You must be signed in to change notification settings - Fork 0
/
yt-dl.sh
executable file
·67 lines (61 loc) · 2.19 KB
/
yt-dl.sh
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
#!/bin/sh
#####################################################################################################################
#
# Author : Spyridakis Christos
# Created Date : 16/7/2021
# Last Updated : 8/8/2021
# Email : spyridakischristos@gmail.com
#
# Description :
# Use youtube-dl to download video, audio or playlist
#
####################################################################################################################
helpMenu() {
echo "Usage: $0 [Option]... [Option]... "
echo "Use youtube-dl to download video, audio or playlist"
echo
echo "[Options] :"
echo " -h, --help This help menu"
echo " -a, --audio Download only audio to mp3"
echo " -v, --video Download video to mp4"
echo " -A, --audio-list Download only audio list to mp3"
echo " -V, --video-list Download video list to mp4"
}
video() {
echo "Download video from URL: ${1}"
youtube-dl -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/bestvideo+bestaudio' --merge-output-format mp4 --embed-thumbnail $1
}
video_list() {
echo "Download video playlist from URL: ${1}"
youtube-dl -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/bestvideo+bestaudio' --merge-output-format mp4 --embed-thumbnail -o "%(autonumber)s-%(title)s.%(ext)s" --yes-playlist $1
}
audio() {
echo "Download audio from URL: ${1}"
youtube-dl --extract-audio --embed-thumbnail --audio-format mp3 $1
}
audio_list() {
echo "Download audio playlist from URL: ${1}"
youtube-dl --extract-audio --embed-thumbnail --audio-format mp3 --yes-playlist $1
}
while :
do
case "$1" in
-h | --help) helpMenu ; exit 0 ;;
-a | --audio) audio $2 ; shift ; shift ;;
-v | --video) video $2 ; shift ; shift ;;
-A | --audio-list) audio_list $2 ; shift ; shift ;;
-V | --video-list) video_list $2 ; shift ; shift ;;
--*)
echo "Unknown option: $1" >&2
helpMenu
exit 1
;;
-*)
echo "Unknown option: $1" >&2
helpMenu
exit 1
;;
*)
break
esac
done