Skip to content

Instantly share code, notes, and snippets.

@camnewnham
Last active February 23, 2024 08:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save camnewnham/8a9c0e2a0db1b8e2dcb06c9093f48d04 to your computer and use it in GitHub Desktop.
Save camnewnham/8a9c0e2a0db1b8e2dcb06c9093f48d04 to your computer and use it in GitHub Desktop.
Youtube Music Playlist Download
# get yt-dlp (https://github.com/yt-dlp/yt-dlp)
# install ffmpeg (choco install ffmpeg or https://www.ffmpeg.org/download.html
# run command below
# copy to the "Music" folder on your Garmin Watch via USB
# example $URL = "https://music.youtube.com/playlist?list=PL-BHPGwxCFX_onAQe_WIv7JewuMpT38Ft"
$URL = Read-Host "Enter YouTube Music Playlist URL"
.\yt-dlp --output "%(playlist_id)s/%(id)s.%(ext)s" --add-metadata --extract-audio --audio-format mp3 --write-playlist-metafiles --write-info-json "$URL"
$URL -match "(?<=list=)[^&]+"
$PLAYLIST_ID = $Matches[0]
$PLAYLIST_TITLE = (Get-Content ".\$PLAYLIST_ID\$PLAYLIST_ID.info.json" | ConvertFrom-Json).title
Remove-Item -Path .\$PLAYLIST_ID\*.json
(Get-ChildItem -Path .\$PLAYLIST_ID -Filter *.mp3 -Name) > "$PLAYLIST_ID\$PLAYLIST_TITLE.m3u8"
Rename-Item $PLAYLIST_ID -NewName $PLAYLIST_TITLE
Read-Host "Complete. Press any key to close."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment