| name | youtube-song-downloader |
| description | Find YouTube links for requested songs, save links to a text file, and download them as opus using yt-dlp. Use when user says "download song", "get this song", "find and download music", "youtube song", or requests specific songs to download. |
YouTube Song Downloader
Find songs on YouTube, collect their links in a text file, and download them as opus files using yt-dlp.
When to Use This Skill
Use this skill when the user requests:
- "Download [song name] by [artist]"
- "Get me these songs from YouTube"
- "Find and download this music"
- "Add [song] to my download list"
- Any request to find YouTube links for songs and download them
Instructions
Step 1: Gather Song Requests
Ask the user which songs they want to download. Get:
- Song title
- Artist name (helps find the right version)
- Any preferences (live version, acoustic, remix, etc.)
Step 2: Search YouTube for Each Song
IMPORTANT: Always use the Chrome DevTools MCP tools (mcp__chrome-devtools__*), NOT Playwright tools. Chrome DevTools shares cookies with the local Chrome browser, which is required for yt-dlp authentication.
Use the Chrome DevTools MCP tools to search YouTube directly for each song:
-
Navigate to YouTube search: Use mcp__chrome-devtools__navigate_page to go to:
https://www.youtube.com/results?search_query=[song title] [artist] official audio
URL-encode the search query (spaces become + or %20).
-
Take a snapshot: Use mcp__chrome-devtools__take_snapshot to capture the search results page.
-
Extract the video URL: From the snapshot, find the first relevant video result. Look for elements with video links in the format /watch?v=VIDEO_ID. The full URL will be:
https://www.youtube.com/watch?v=VIDEO_ID
-
Repeat for each song: Navigate to a new search for each song in the list.
Tips for finding the right video:
- Look for results with "Official Audio", "Official Video", or the artist's verified channel
- Prefer shorter videos for songs (3-7 minutes typically) over compilations
- Avoid "lyrics" videos unless specifically requested
Valid YouTube URLs look like:
https://www.youtube.com/watch?v=VIDEO_ID
https://youtu.be/VIDEO_ID
Step 3: Create Links File and Song Mapping
Create two files in the current directory:
1. songs.txt - One YouTube URL per line:
https://www.youtube.com/watch?v=abc123
https://www.youtube.com/watch?v=def456
https://www.youtube.com/watch?v=ghi789
2. song_mapping.txt - Tab-separated mapping of URL to song name and artist for renaming:
https://www.youtube.com/watch?v=abc123 Song Name 1 Artist 1
https://www.youtube.com/watch?v=def456 Song Name 2 Artist 2
https://www.youtube.com/watch?v=ghi789 Song Name 3 Artist 3
Show the user the list of songs and their URLs before proceeding.
Step 4: Download Songs with yt-dlp
Run yt-dlp to download all songs from the links file, using Chrome's cookies for authentication:
yt-dlp --cookies-from-browser chrome -x --audio-format opus --audio-quality 0 -o "%(title)s.%(ext)s" -a songs.txt
Flag explanations:
--cookies-from-browser chrome: Use cookies from Chrome browser (handles age-restricted/login-required videos)
-x: Extract audio only
--audio-format opus: Convert to opus (smaller files, good quality)
--audio-quality 0: Best quality
-o "%(title)s.%(ext)s": Name files by video title
-a songs.txt: Read URLs from the links file
Step 5: Re-encode with ffmpeg (Required)
IMPORTANT: yt-dlp's opus encoding can cause playback issues with some devices (e.g., Yoto players). Always re-encode the downloaded files with ffmpeg to ensure compatibility:
for f in *.opus; do
ffmpeg -y -i "$f" -c:a libopus -b:a 128k "${f%.opus}_temp.opus" 2>/dev/null && mv "${f%.opus}_temp.opus" "$f"
done
This re-encodes each opus file in place, fixing any encoding quirks from yt-dlp.
Step 6: Rename Files
Rename downloaded files from YouTube titles to the standardized format {Song Name} - {Artist}.opus.
Use the song_mapping.txt file to match each downloaded file to its proper name. For each entry in the mapping:
- Find the downloaded file (yt-dlp names files by video title)
- Rename to:
{Song Name} - {Artist}.opus
Example renaming:
Note: Use the mv command to rename files. Handle special characters in filenames by quoting paths.
Step 7: Report Results
After download completes:
- List the downloaded files
- Report any failures
- Keep
songs.txt for reference
Examples
Example 1: Single Song
User: "Download 'Bohemian Rhapsody' by Queen"
Actions:
- Search YouTube for "Bohemian Rhapsody Queen official audio" using Chrome DevTools MCP
- Find URL:
https://www.youtube.com/watch?v=fJ9rUzIMcZQ
- Create
songs.txt with that URL
- Create
song_mapping.txt:
https://www.youtube.com/watch?v=fJ9rUzIMcZQ Bohemian Rhapsody Queen
- Run:
yt-dlp --cookies-from-browser chrome -x --audio-format opus --audio-quality 0 -o "%(title)s.%(ext)s" -a songs.txt
- Re-encode with ffmpeg for compatibility
- Rename file to
Bohemian Rhapsody - Queen.opus
- Report: "Downloaded: Bohemian Rhapsody - Queen.opus"
Example 2: Multiple Songs
User: "Get me these songs:
- 'Stairway to Heaven' by Led Zeppelin
- 'Hotel California' by Eagles
- 'Comfortably Numb' by Pink Floyd"
Actions:
- Search YouTube for each song using Chrome DevTools MCP
- Create
songs.txt:
https://www.youtube.com/watch?v=QkF3oxziUI4
https://www.youtube.com/watch?v=BciS5krYL80
https://www.youtube.com/watch?v=_FrOQC-zEog
- Create
song_mapping.txt:
https://www.youtube.com/watch?v=QkF3oxziUI4 Stairway to Heaven Led Zeppelin
https://www.youtube.com/watch?v=BciS5krYL80 Hotel California Eagles
https://www.youtube.com/watch?v=_FrOQC-zEog Comfortably Numb Pink Floyd
- Show user the list for confirmation
- Download all with single yt-dlp command
- Re-encode with ffmpeg
- Rename files:
Stairway to Heaven - Led Zeppelin.opus
Hotel California - Eagles.opus
Comfortably Numb - Pink Floyd.opus
Example 3: Specific Version
User: "Download the live version of 'Purple Rain' by Prince"
Actions:
- Search "Purple Rain Prince live performance"
- Find appropriate live performance URL
- Create links file and download
Technical Details
- Dependencies: yt-dlp and ffmpeg must be installed (
brew install yt-dlp ffmpeg)
- Browser tools: Always use Chrome DevTools MCP (
mcp__chrome-devtools__*), NOT Playwright. Chrome DevTools uses the same profile as your local Chrome browser.
- Authentication: yt-dlp uses
--cookies-from-browser chrome to access your Chrome cookies, enabling download of age-restricted or login-required videos
- Output format: opus (smaller files than mp3, excellent quality)
- Output location: Current working directory
- Links file:
songs.txt in current directory
- Mapping file:
song_mapping.txt - tracks URL to song name and artist for renaming
- File naming:
{Song Name} - {Artist}.opus (e.g., Bohemian Rhapsody - Queen.opus)
- Re-encoding: Required to fix yt-dlp encoding quirks that cause playback issues on some devices (e.g., Yoto players)
Troubleshooting
yt-dlp not found
brew install yt-dlp
Download fails for a specific video
- Video may be region-locked or age-restricted
- Try searching for an alternative upload
- Check if video is available in your region
Poor audio quality
The --audio-quality 0 flag already requests best quality. Some videos may have lower source quality.
Notes
- Always confirm the YouTube links with the user before downloading
- Some videos may have ads or intros - the full video audio is downloaded
- yt-dlp respects YouTube's rate limiting automatically
- Files are renamed from YouTube titles to
{Song Name} - {Artist}.opus format for clean organization
- Always re-encode with ffmpeg after downloading - yt-dlp's direct opus output can have encoding quirks that cause playback failures on some devices
- Keep
song_mapping.txt for reference when renaming files