#pragma once #include "../YouTubeClient.hpp" #include "TrackSource.hpp" #include namespace Echoion::Core { // yt-dlp-backed source, in two router entries over the same // YouTubeClient: // - Direct ("ytdlp-direct", useProxy=false): non-YouTube extractor URLs // (SoundCloud, Bandcamp, VK, Yandex, radio pages) reachable without a // proxy. Never handles bare text search. // - Proxied ("ytdlp-proxied", useProxy=true): last-resort YouTube // resolution + text search through the configured proxy; also owns // the SOCKS5 download-to-file path. class YtDlpSource : public ITrackSource { public: enum class Mode { Direct, Proxied }; YtDlpSource(std::shared_ptr client, Mode mode, std::string tempDir); [[nodiscard]] std::string_view name() const override { return mode_ == Mode::Direct ? "ytdlp-direct" : "ytdlp-proxied"; } [[nodiscard]] bool canHandle(const std::string& query) const override; [[nodiscard]] bool isAvailable() const override; [[nodiscard]] bool supportsSearch() const override { return mode_ == Mode::Proxied; } Api::Result search(std::string_view query) override; Api::Result resolve(const std::string& urlOrId) override; Api::Result getStream(const Api::TrackInfo& track) override; // Force the download-to-file path on the next getStream (set by // the router's preferDownload retry). Api::Result getStreamViaDownload(const Api::TrackInfo& track); private: std::shared_ptr client_; Mode mode_; std::string tempDir_; }; } // namespace Echoion::Core