Youtube2Audio: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
Line 1: | Line 1: | ||
= Youtube to Audio = | = Youtube to Audio = | ||
== yt-dlp | |||
Faster (as of 2022-04-22) alternative fork on https://github.com/yt-dlp/yt-dlp | |||
VID='PGCTQTZXGXs' | |||
conda create -n yt-dlp yt-dlp | |||
conda activate yt-dlp | |||
yt-dlp --extract-audio --keep-video "https://www.youtube.com/watch?v=$VID" | |||
== Download youtube-dl or update to latest == | == Download youtube-dl or update to latest == | ||
Revision as of 07:38, 22 April 2022
Youtube to Audio
== yt-dlp
Faster (as of 2022-04-22) alternative fork on https://github.com/yt-dlp/yt-dlp
VID='PGCTQTZXGXs' conda create -n yt-dlp yt-dlp conda activate yt-dlp yt-dlp --extract-audio --keep-video "https://www.youtube.com/watch?v=$VID"
Download youtube-dl or update to latest
sudo youtube-dl -U
Commands for DL a playlist
mkdir -p artist/album cd artist/album youtube-dl --extract-audio --keep-video 'album-playlist-url'
Option --embed-thumbnail seems useful, but did not work. Maybe retry later...
Commands for adding metadata
will need adapting to actual yt title audio formats. This playlist only contained video with opus (ogg vorbis) audio tracks.
mkdir meta find . -name '*.opus' -print | while read f; do t=${f%-???????????.opus} t=${t/Roger Waters - /} t=${t#*/} a=${t%/*} t=${t#*/} echo "<$a><$t>" mkdir -p "meta/$a" ffmpeg -v 0 -i "$f" -acodec copy -metadata title="$t" -metadata artist="Roger Waters" -metadata album="$a" "meta/$a/$t.opus" </dev/zero ffmpeg -v 0 -i "$f" -acodec mp3 -metadata title="$t" -metadata artist="Roger Waters" -metadata album="$a" "meta/$a/$t.mp3" </dev/zero done
The redirects are necessary because ffmpeg encoders seem to read from stdin and garble the "while read f" loop input
Add pictures as mp3 tag
for f in *.mp3; do b=${f/.mp3/}; echo $b; id3v2 --APIC `cat "../$b.jpg"` "$f"; done