Skip to content

feat: YouTube video/music search in panel (yt-dlp ytsearch) + toggle - #3

Open
aarontanx wants to merge 4 commits into
thisisgm:mainfrom
aarontanx:feat/youtube-search
Open

feat: YouTube video/music search in panel (yt-dlp ytsearch) + toggle#3
aarontanx wants to merge 4 commits into
thisisgm:mainfrom
aarontanx:feat/youtube-search

Conversation

@aarontanx

@aarontanx aarontanx commented Sep 1, 2026

Copy link
Copy Markdown

feat: YouTube video/music search in panel (yt-dlp ytsearch) + toggle

Fixes panel only showing playlists when [ytmusic] is enabled — no video/music results, even though TUI Ctrl+F does search YouTube.

Problem

cliamp-library only spoke Subsonic (/rest/stream token → search3/getAlbumList2). With no Navidrome host (e.g. config.toml only has [ytmusic] enabled=true and radio), server_from() returned None and search printed []. Playlists still appeared via Model.matchPlaylists() from cliamp playlist list, so users saw “only playlists from YouTube Music” and no video/music results — even though cliamp TUI Ctrl+F provider-search (strings ytsearch1:/ytsearch10:) does search YouTube via yt-dlp.

Socket has no search command ({"cmd":"search"}unknown command), so panel had no YouTube path.

Solution

Mirror TUI's YouTube search in the panel using the same yt-dlp backend the youtube provider uses, with a toggle.

  • cliamp-library

    • Add YT_SEARCH_LIMIT=8, YT_SEARCH_TIMEOUT=15, yt_search(query)yt-dlp --flat-playlist --print-json ytsearchN:query (NDJSON). Filters channels (ie_key==YoutubeTab, channel URLs, non-11-char IDs) and keeps only videos (ie_key==Youtube + watch?v=). Returns kind:"youtube" rows with url. Never raises — missing yt-dlp returns [] so Subsonic outage doesn't blank panel.
    • Add play_youtube(id, title, artist) → writes ~/.config/cliamp/playlists/cliampui.toml with path="https://www.youtube.com/watch?v=ID" (cliamp youtube provider resolves via yt-dlp), then cliamp load cliampui.
    • main(): play-youtube/play-yt handled without Subsonic host; albums/search no longer early-exit on missing host — they return Subsonic rows (or []) and still run yt_search. search merges search3 + yt_search and honors --no-youtube flag.
  • Model.js

    • parseResults handles kind=="youtube" (conditional url to keep tests/model.test.js green).
  • Service.qml

    • playResult() routes youtube[libraryHelper, "play-youtube", id, name, artist].
    • enableYoutubeSearch: boolSetting("enableYoutubeSearch", true), _dispatchLibrary() adds --no-youtube when disabled, and filters youtube rows post-parse as safety.
  • manifest.json + README.md

    • New setting enableYoutubeSearch (boolean, default true, schema + defaults), settings table updated.
  • Library.qml

    • Placeholder Search songs, albums, playlists and YouTube.
    • Inline YouTube search ON/OFF row (CursorSurface) + toggleYoutubeRequested signal.
  • Panel.qml

    • Handles onToggleYoutubeRequested: toggles enableYoutubeSearch via root.settings + bar.shell.updateEntryInline and re-triggers current search.

Toggle

Settings UI (auto-generated from manifest.json schema) → Search YouTube in library (default ON). Or inline:

  • Library → YouTube search ON/OFF row (click to toggle, persists)
  • CLI:
    omarchy bar set io.github.thisisgm.cliampui enableYoutubeSearch false --json
    omarchy bar set io.github.thisisgm.cliampui enableYoutubeSearch true --json
    omarchy restart shell # or toggle via library row (no restart needed, re-searches)

When OFF, cliamp-library search --no-youtube skips yt-dlp entirely (no network, no delay) and panel shows only Subsonic + playlists, like before.

Testing

python3 cliamp-library search "rick astley" | jq # 7 youtube rows (channel filtered)
python3 cliamp-library search "rick astley" --no-youtube | jq # 0 (no Subsonic host)
python3 cliamp-library play-youtube dQw4w9WgXcQ "Never Gonna Give You Up" "Rick Astley"
cat ~/.config/cliamp/playlists/cliampui.toml # [[track]] path youtube
cliamp status --json | jq # playing, stream true, duration 213
deno run --allow-read tests/model.test.js # all model tests passed
omarchy plugin validate ~/.config/omarchy/plugins/io.github.thisisgm.cliampui # exit 0
omarchy restart shell

Panel: search “lofi” → YOUTUBE rows appear alongside album/song/playlist when ON, disappear when OFF; toggle via library row instantly refreshes; Enter plays immediately (daemon stays, no TUI kill).

Notes

  • Requires yt-dlp on PATH (already used by cliamp's youtube provider, 2026.08.19 tested). If missing, falls back to Subsonic only.
  • Clamped to 3–15 results to keep 260 ms debounce responsive; albumProcess single-flight prevents overlapping yt-dlp runs.
  • No credential handling — same as TUI ytsearch, uses anonymous YouTube search.
  • play-youtube accepts full URL as well.

Closes the reported issue: search now finds YouTube videos/music just like TUI Ctrl+F, with toggle to keep it Subsonic-only.

- cliamp-library: add yt_search() using yt-dlp ytsearchN:query (same
  backend as cliamp's youtube provider strings ytsearch1:/ytsearch10:),
  merge Subsonic search3 rows with YouTube rows, filter channels
  (YoutubeTab) and require 11-char video IDs, add play-youtube to build
  a one-track scratch playlist from https://www.youtube.com/watch?v=ID
  so the daemon can play without Subsonic. Works without a Navidrome
  host (host absence no longer blanks search).

- Model.js: parseResults now handles kind=youtube (with url), sample
  updated, row conditional url to keep existing tests green.

- Service.qml: playResult routes youtube kind to play-youtube with
  title/artist for TOML metadata.

- Library.qml: placeholder updated to reflect YouTube.

Fixes panel showing only playlists (matchPlaylists) when [ytmusic]
enabled but no Subsonic, and enables video/music search like TUI
Ctrl+F. Tested: search rick astley -> 7 youtube rows, play-youtube
loads cliampui.toml and cliamp plays (duration 213, stream true).
@coderabbitai

coderabbitai Bot commented Sep 1, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Team

Run ID: 010c774d-41e2-4d4d-8eb1-d6203e255e8e


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

- manifest: add enableYoutubeSearch boolean (default true) with schema,
  README settings table + notes updated
- Service.qml: boolSetting enableYoutubeSearch, _dispatchLibrary adds
  --no-youtube when disabled, filters youtube rows post-parse
- cliamp-library: search honors --no-youtube flag to skip yt_search
- Library.qml: inline 'YouTube search ON/OFF' row + toggleYoutubeRequested signal
- Panel.qml: handle toggle, persist via bar.shell.updateEntryInline and
  re-trigger current search

Toggle via bar settings UI or library row, or CLI:
  omarchy bar set io.github.thisisgm.cliampui enableYoutubeSearch false --json
  omarchy bar set io.github.thisisgm.cliampui enableYoutubeSearch true --json
@aarontanx aarontanx changed the title feat: YouTube video/music search in panel (yt-dlp ytsearch, play-youtube) feat: YouTube video/music search in panel (yt-dlp ytsearch) + toggle Sep 1, 2026
Fixes plugin widget failing to load (Service unavailable) after toggle
feature - syntax error at 695:11 Expected token ','
Library/OutputSheet emit hovered onContainsMouseChanged -> Panel.cursorIndex follows mouse (matches CursorSurface contract, audio panel SinkRow pattern)

Service: isYoutube fix dropped shuffle/repeat/total/volumeDb causing ReferenceError and missing button; restore them and keep isYoutube canSeek exception; fixes volumeDb not defined at playerUnity

NowPlaying: keep draggable scrub (progressBar.scrubbing) already live
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant