Fall back to SoundCloud when YouTube hides search results

YouTube applies restricted-mode filtering to programmatic search: the
same query that returns a clip in a signed-in browser comes back as an
empty list over the API, with exit code 0 and no message at all, and
cookies do not change it. Verified locally — "gudium идол" returns three
results, "gudium аудиопорно" returns none, and so does the plain
youtube.com/results page for the same words.

An empty YouTube search now retries on SoundCloud, and when both come up
empty the message says the query may have been filtered and suggests
pasting a link, instead of implying the track does not exist.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Leonid Pershin
2026-09-09 00:07:20 +03:00
co-authored by Claude Opus 5
parent 3e53f34374
commit f84489e27e
5 changed files with 405 additions and 373 deletions
+2 -2
View File
@@ -1,7 +1,7 @@
import { EventEmitter } from "node:events";
import { config } from "../config.js";
import { logger } from "../logger.js";
import { resolveQuery, searchTracks } from "../sources/index.js";
import { NOTHING_FOUND, resolveQuery, searchTracks } from "../sources/index.js";
import {
UserFacingError,
type LoopMode,
@@ -178,7 +178,7 @@ export class MusicManager extends EventEmitter<ManagerEvents> {
});
const result = await resolveQuery(query, requester, config.MAX_QUEUE_SIZE - player.queue.length);
if (result.tracks.length === 0) throw new UserFacingError("Ничего не найдено");
if (result.tracks.length === 0) throw new UserFacingError(NOTHING_FOUND);
const mode = options.mode ?? "append";
const wasIdle = !player.current;