yt-dlp (OpenClaw Music Fetcher)
Workflow: Analyze prompt -> Identify specific track -> Check ~/.openclaw/workspace/music/ folder -> Download if missing -> Pass to cmus.
Find the active workspace music folder
The agent must always operate within the specific OpenClaw workspace directory to ensure portability.
- Path:
~/.openclaw/workspace/music/(Resolved as an absolute path from the user's home directory). - Never download files to the root, current working directory, or system folders.
Track Identification & Verification Logic
When the user requests a song (via lyrics, artist, composer, or title):
- Analyze: Determine the exact track name and artist.
- Check Local: Search the workspace music folder:
find ~/.openclaw/workspace/music/ -type f -iname "*<keyword>*" - Branching:
- If the file EXISTS: Skip download. Pass the absolute file path to the
cmusskill. - If the file is MISSING: Proceed to the download step using
yt-dlp.
- If the file EXISTS: Skip download. Pass the absolute file path to the
yt-dlp quick start
Ensure the directory exists, navigate to it, and download the missing track. The ytsearch1: prefix is used to grab the best match from YouTube Music/YouTube automatically:
mkdir -p ~/.openclaw/workspace/music/ && cd ~/.openclaw/workspace/music/ && yt-dlp -x --audio-format mp3 -o "%(title)s.%(ext)s" "ytsearch1:<Exact Track Name> <Artist>"
Notes
- Post-Download Action: Always wait for the download to finish, then run
findagain to capture the final filename (asyt-dlpsanitizes titles) before passing it tocmus. - Generalization: Use
~or$HOMEinstead of hardcoded paths like/home/huy/to ensure the skill works for all users. - Dependency:
yt-dlprequiresffmpegto extract and convert audio streams into.mp3format. - Prefer highly specific search queries (Track + Artist) to ensure the agent picks the correct version of a song.