summaryrefslogtreecommitdiff
path: root/scripts/ytdl
blob: 9aafb42d39c68285b1673e592d328a206ba70f24 (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
#!/bin/sh
# wrapper for yt-dlp

MUSICDIR="${XDG_MUSIC_DIR:-$HOME/music}"
VIDEODIR="${XDG_VIDEOS_DIR:-$HOME/Videos}"

case $1 in
v)
	mkdir -p "$VIDEODIR"
	herbe "Video download started"
	yt-dlp -f 'bv,ba' -o '%(title)s [%(id)s].%(ext)s'\
	-P "$VIDEODIR" "$2" &&
	herbe "Video downloaded" ||
		(herbe "Error: No internet connection" && exit 1) ;;
m)
	mkdir -p "$MUSICDIR/download"
	herbe "Music download started"
	yt-dlp -f 'ba' -x --embed-thumbnail --audio-format mp3\
	-o '%(title)s [%(id)s].%(ext)s' -P "$MUSICDIR/download" "$2" &&
	herbe "Music downloaded" ||
		(herbe "Error: No internet connection" && exit 1) ;;
p)
	NAME=$(printf '' | dmenu -p 'Name ')
	mkdir -p "$MUSICDIR/$NAME"
	herbe "Playlist download started"
	yt-dlp -f 'ba' -x --embed-thumbnail --audio-format mp3\
	-o '%(playlist_index)s - %(title)s [%(id)s].%(ext)s'\
	-P "$MUSICDIR/$NAME" "$2" &&
	herbe "Playlist downloaded" ||
		(herbe "Error: No internet connection" && exit 1) ;;
*)
	exit 1 ;;
esac