~yerinalexey/dotfiles

ref: 8577e9749fa7fe80273e2b41122b441e994500e3 dotfiles/scripts/dl-music -rwxr-xr-x 580 bytes
8577e974Alexey Yerin qb: remove unused styles 3 months ago
                                                                                
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
#!/bin/sh -e

# Download music from YouTube

MUSIC_DIRECTORY="$HOME"/music

video_url="$1"

if [ -z "$video_url" ]; then
	printf "Warning: defaulting video URL to \$(wl-paste)\n" >&2
	video_url="$(wl-paste)"
fi

video_title="$(youtube-dl --get-title "$video_url" | sed 's/\s*\[NCS Release\]\s*//g')"
dest="$MUSIC_DIRECTORY"/"$video_title"

orig="$(youtube-dl --get-filename -f bestaudio -o "$dest.%(ext)s" "$video_url")"
youtube-dl -f bestaudio -o "$dest.%(ext)s" "$video_url"

# Convert to opus
ffmpeg -v 16 -i "$orig" "$dest".opus

# Clean up
rm "$orig"

opus-edit "$dest".opus