~yerinalexey/dotfiles

ref: 144a38b0aa0a39003633d53b77fe4e3ca29c054b dotfiles/scripts/dl-music -rwxr-xr-x 584 bytes
144a38b0Alexey Yerin river,update-volume: fix old wob crashes 6 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
#!/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"

# defer rm "$orig"
trap 'rm "$orig"' EXIT

ffmpeg -v 16 -i "$orig" "$dest".opus

opus-edit "$dest".opus