Add only the track when a link carries both a video and a list

A link copied from an open mix (watch?v=…&list=RD…) expanded into the
whole radio station — 500 entries from one paste. Any URL with a `v=`
parameter now resolves to that single track, and only a /playlist?list=…
URL expands. The rule is deliberately blunt rather than keyed on
start_radio, so pasting a link behaves the same way every time.

Playlist expansion is also capped separately from the queue limit
(MAX_PLAYLIST_TRACKS, 100 by default) and the chat says when a playlist
hit that ceiling.

Verified against the real yt-dlp: both mix links resolve to one track, a
plain video link to one, and a playlist URL to its 13 entries.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Leonid Pershin
2026-09-09 00:20:35 +03:00
co-authored by Claude Opus 5
parent ffcf88efb7
commit 6d65134f8e
6 changed files with 34 additions and 6 deletions
+7 -3
View File
@@ -212,13 +212,17 @@ export async function search(
}
/** Resolves a URL that may point at a single track, a playlist, or an album. */
export async function resolveUrl(url: string, requestedBy: Requester, maxTracks: number): Promise<SearchResult> {
export async function resolveUrl(
url: string,
requestedBy: Requester,
maxTracks: number,
options: { singleTrack?: boolean } = {},
): Promise<SearchResult> {
const { stdout, stderr } = await runYtDlp([
...baseArgs(),
"--flat-playlist",
"--dump-single-json",
"--playlist-end",
String(maxTracks),
...(options.singleTrack ? ["--no-playlist"] : ["--playlist-end", String(maxTracks)]),
url,
]);
const root = parseNdjson(stdout)[0];