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
+11
View File
@@ -194,6 +194,17 @@ cd /opt/stoat-mbot && docker compose up -d --build && docker compose logs -f
- `YTDLP_COOKIES` — путь к `cookies.txt`, см. раздел ниже.
- `YTDLP_EXTRACTOR_ARGS` — дополнительные `--extractor-args` через `;`.
## Поиск иногда не находит то, что видно в браузере
YouTube может вернуть пустой список там, где в залогиненном браузере результаты есть: для
программного доступа применяется фильтрация (ограниченный режим), причём молча — yt-dlp
завершается успешно и без единого сообщения, куки не помогают. Признак: тот же запрос без
«спорного» слова находится нормально.
Что делает бот: если YouTube ничего не отдал, поиск автоматически повторяется в SoundCloud,
а если пусто и там — сообщает об этом прямо, а не показывает пустой список. Надёжный обход —
вставить прямую ссылку на трек: по ссылке фильтр не применяется.
## Обновление yt-dlp
YouTube регулярно ломает экстракторы, и симптом всегда один: трек находится, но не играет, а в