Download all YouTube playlist files as mp3
Posted on 2017-12-25(Mon) in posts
I use yt-dlp to download stuff off YouTube and these aliases are superuseful. I installed it with brew install yt-dlp you might also need to brew install id3v2.
alias ya='yt-dlp -w -i -x -o "%(playlist_index)02d-%(title)s.%(ext)s" --add-metadata --audio-format mp3 -I ::-1 --exec "id3v2 -2 -T %(playlist_index)d -t %(title)q -a %(channel)q -A %(playlist_title)q %(filepath,_filename|)q; mv %(filepath,_filename|)q $HOME/Music/Automatically\ Add\ To\ Music.localized/; sleep 2"'
complete -F __yt_dlp ya
alias yab='yt-dlp -w -i -x -o "%(playlist_index)02d-%(title)s.m4b" --add-metadata --audio-format aac -I ::-1 --exec "open -a Books %(filepath,_filename|)q; sleep 2"'
complete -F __yt_dlp yab
alias yv='yt-dlp -w -i -o "%(playlist_index)02d-%(title)s.%(ext)s" --format "bestvideo[vcodec^=avc1]+bestaudio[ext=m4a]/bestvideo+bestaudio/best" --write-sub --write-auto-sub --sub-lang "en.*" --sub-format srt --embed-subs --merge-output-format mp4 --add-metadata -I ::-1 --exec "mv %(filepath,_filename|)q $HOME/TV/Automatically\ Add\ To\ TV.localized/ && trash -v %(playlist_index)02d-%(title)q.*.srt ; sleep 2"'
complete -F __yt_dlp yv
ya - downloads a youtube file or playlist in mp3 format and sets the id3v2 track number to the track number of the playlist, then moves the file to it's automatically added to Music.app and then waits two seconds before downloading the next file since sometimes it takes a while to notice to get the files to add. It also downloads the playlist in reverse order so that if you show your songs in descending date added they're in the correct order.
yab - downloads the file or playlist in aac and opens in in Books.app as an audiobook
yv - does similar to ya, but downloads an mp4 video file that is compatible with AppleTV and adds it to TV.app