1 parent
df99b6ea7f
commit
d146f11f02
63 files changed
+8331
-2709
No files matched your search
@@ -0,0 +1,58 @@
|
||||
#pragma once
|
||||
|
||||
#include "../YouTubeClient.hpp"
|
||||
#include "TrackSource.hpp"
|
||||
#include <memory>
|
||||
|
||||
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<YouTubeClient> 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<Api::SearchResult>
|
||||
search(std::string_view query) override;
|
||||
Api::Result<Api::TrackInfo>
|
||||
resolve(const std::string& urlOrId) override;
|
||||
Api::Result<StreamHandle>
|
||||
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<StreamHandle>
|
||||
getStreamViaDownload(const Api::TrackInfo& track);
|
||||
|
||||
private:
|
||||
|
||||
std::shared_ptr<YouTubeClient> client_;
|
||||
Mode mode_;
|
||||
std::string tempDir_;
|
||||
};
|
||||
|
||||
} // namespace Echoion::Core
|
||||
Reference in new issue
Block a user