From dfbbdaaf017cd16851bf8422d0a20d37ec8a8e6a Mon Sep 17 00:00:00 2001 From: faumaray Date: Sun, 26 Jul 2026 16:44:25 +0300 Subject: [PATCH] Sources: use standalone yt-dlp releases --- include/echoion/core/YtDlpManager.hpp | 7 +++++-- src/YtDlpManager.cpp | 27 +++++++++++++++++++++++---- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/include/echoion/core/YtDlpManager.hpp b/include/echoion/core/YtDlpManager.hpp index b31aad5..ef21e33 100644 --- a/include/echoion/core/YtDlpManager.hpp +++ b/include/echoion/core/YtDlpManager.hpp @@ -132,9 +132,12 @@ namespace Echoion::Core std::unique_ptr pool_; // yt-dlp download URLs - static constexpr std::string_view YTDLP_DOWNLOAD_LINUX = + static constexpr std::string_view YTDLP_DOWNLOAD_LINUX_X86_64 = "https://github.com/yt-dlp/yt-dlp/releases/latest/download/" - "yt-dlp"; + "yt-dlp_linux"; + static constexpr std::string_view YTDLP_DOWNLOAD_LINUX_AARCH64 = + "https://github.com/yt-dlp/yt-dlp/releases/latest/download/" + "yt-dlp_linux_aarch64"; static constexpr std::string_view YTDLP_DOWNLOAD_WINDOWS = "https://github.com/yt-dlp/yt-dlp/releases/latest/download/" "yt-dlp.exe"; diff --git a/src/YtDlpManager.cpp b/src/YtDlpManager.cpp index d64c8ff..9e450b5 100644 --- a/src/YtDlpManager.cpp +++ b/src/YtDlpManager.cpp @@ -87,8 +87,12 @@ namespace Echoion::Core return std::string(YTDLP_DOWNLOAD_WINDOWS); #elif defined(__APPLE__) return std::string(YTDLP_DOWNLOAD_MACOS); +#elif defined(__x86_64__) || defined(_M_X64) + return std::string(YTDLP_DOWNLOAD_LINUX_X86_64); +#elif defined(__aarch64__) || defined(_M_ARM64) + return std::string(YTDLP_DOWNLOAD_LINUX_AARCH64); #else - return std::string(YTDLP_DOWNLOAD_LINUX); + return {}; #endif } @@ -327,6 +331,11 @@ namespace Echoion::Core } std::string downloadUrl = getDownloadUrl(); + if (downloadUrl.empty()) { + return Api::fail( + Api::ErrorCode::ServiceUnavailable, + "No standalone yt-dlp release is available for this platform"); + } Void::Log::info( "YtDlpManager", "{}", std::format("Downloading yt-dlp from: {}", downloadUrl)); @@ -445,12 +454,22 @@ namespace Echoion::Core if (!probe || probe->exit_code != 0) { std::error_code ec; std::filesystem::remove(tempPath, ec); + std::string details = + probe ? std::format("exit code {}", probe->exit_code) + : probe.error().message(); + if (probe) { + const auto& output = + !probe->err.empty() ? probe->err : probe->out; + if (!output.empty()) { + constexpr std::size_t maxDiagnosticLength = 1024; + details += std::format( + "; output: {}", output.substr(0, maxDiagnosticLength)); + } + } return Api::fail( Api::ErrorCode::ServiceUnavailable, std::format("Downloaded yt-dlp failed verification: {}", - probe ? std::format("exit code {}", - probe->exit_code) - : probe.error().message())); + details)); } std::error_code renameEc;