Core: re-apply YouTube config (API key) on reload

reloadConfig/updateConfig updated the network proxy but never re-pushed the
YouTube settings, so editing youtubeApiKey and reloading had no effect — the
YouTube client kept its startup key. Add MusicManager::applyYouTubeConfig()
(API key, cookies, concurrency, URL shortening; empty key clears it -> yt-dlp
fallback) and call it from both reloadConfig and updateConfig.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
faumarayandClaude Opus 4.8 committed 2026-06-25 21:49:52 +03:00
1 parent 7e3081ecd1
commit 5796ccbc74
3 files changed
+36

No files matched your search

+29
View File
@@ -158,6 +158,35 @@ namespace Echoion::Core
}
}
void MusicManager::applyYouTubeConfig(const Api::YouTubeConfig& youtube)
{
if (!youTubeClient_) {
return;
}
// Empty string clears the key (hasApiKey() -> false), so search falls
// back to yt-dlp.
youTubeClient_->setApiKey(youtube.youtubeApiKey.value_or(""));
if (youtube.youtubeCookiesPath.has_value()) {
youTubeClient_->setCookiesPath(*youtube.youtubeCookiesPath);
} else if (youtube.cookiesFromBrowser.has_value()) {
youTubeClient_->setCookiesFromBrowser(*youtube.cookiesFromBrowser);
}
if (youtube.ytDlpMaxConcurrent > 0) {
youTubeClient_->setMaxConcurrentResolutions(
youtube.ytDlpMaxConcurrent);
}
youTubeClient_->setUrlShorteningEnabled(youtube.enableUrlShortening);
const bool hasKey = youtube.youtubeApiKey.has_value() &&
!youtube.youtubeApiKey->empty();
Void::Log::info("MusicManager", "{}",
std::format("YouTube config re-applied (API key: {})",
hasKey ? "set" : "none (yt-dlp)"));
}
void MusicManager::shutdown()
{
isPlaying_ = false;