Compare commits
2
Commits
7975f2b38e
...
a277f2102b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a277f2102b | ||
|
|
dfbbdaaf01 |
No files matched your search
@@ -47,6 +47,9 @@ namespace Echoion::Core
|
||||
|
||||
void loadDirectory(const std::filesystem::path& directory);
|
||||
void loadManagedDirectory(const std::filesystem::path& directory);
|
||||
// Bind and validate cross-plugin services after every startup
|
||||
// directory has been loaded.
|
||||
[[nodiscard]] bool finalizeLoading();
|
||||
[[nodiscard]] Api::Result<std::string>
|
||||
manage(const std::string& requestJson);
|
||||
void setChangeCallback(std::function<void()> callback);
|
||||
|
||||
@@ -132,9 +132,12 @@ namespace Echoion::Core
|
||||
std::unique_ptr<Void::Concurrency::ThreadPool> 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";
|
||||
|
||||
@@ -469,6 +469,7 @@ namespace Echoion::Core
|
||||
extensionPlugins_->loadDirectory(stateDir / "plugins");
|
||||
extensionPlugins_->loadManagedDirectory(stateDir / "plugins" /
|
||||
".managed");
|
||||
(void)extensionPlugins_->finalizeLoading();
|
||||
applyUrlShorteningConfig();
|
||||
|
||||
#ifdef ECHOION_WITH_WEB
|
||||
|
||||
+11
-9
@@ -317,11 +317,6 @@ namespace Echoion::Core
|
||||
publish(*result);
|
||||
plugins_.watch(*result);
|
||||
}
|
||||
if (!bindShortenerServices()) {
|
||||
Void::Log::warn("PluginHost",
|
||||
"Loaded plugins do not provide the configured "
|
||||
"short URL service");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@@ -378,11 +373,18 @@ namespace Echoion::Core
|
||||
publish(id);
|
||||
plugins_.watch(id);
|
||||
}
|
||||
if (!bindShortenerServices()) {
|
||||
Void::Log::warn("PluginHost",
|
||||
"Managed plugins do not provide the configured "
|
||||
"short URL service");
|
||||
}
|
||||
|
||||
bool PluginHost::finalizeLoading()
|
||||
{
|
||||
std::scoped_lock operationLock{reconfigureMutex_};
|
||||
if (bindShortenerServices()) {
|
||||
return true;
|
||||
}
|
||||
Void::Log::warn("PluginHost",
|
||||
"Loaded plugins do not provide the configured short "
|
||||
"URL service");
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string PluginHost::pluginConfiguration(std::string_view name) const
|
||||
|
||||
+23
-4
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user