Implement reload commands; fix SOCKS5 playback; API->yt-dlp search fallback
F1 (reload commands): Core registers itself as Api::ICoreInterface in the service registry; !reloadconfig and !reload resolve it via ctx.service and call Core::reloadConfig() (which reloads config.json from disk), replacing the old placeholder replies. F2 (SOCKS5 playback): ffmpeg can't use a SOCKS5 proxy, so it connected directly to the IP-locked googlevideo URL and timed out; the fallback then buffered the whole (705 MB) body in memory and tripped Void::Net's body limit. New YouTubeClient::downloadAudioToFile() re-downloads the audio with yt-dlp (which handles SOCKS5 + writes to disk) by video id and ffmpeg opens the local file. MusicManager::downloadAudioForPlayback now uses it, and the play-open path short-circuits straight to the download when the proxy is SOCKS5 (skipping the doomed ~15 s ffmpeg attempt); HTTP/no-proxy keeps stream-first-then-download. F3 (API fallback): YouTubeClient::search() now falls back to yt-dlp when the Data API path errors (bad/expired key, quota, network), mirroring what fetchPlaylistItems already did. Build green; runtime behaviour to be verified on the live bot. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
1efdbe0771
commit
499143050b
8 files changed
+190
-81
No files matched your search
@@ -125,7 +125,7 @@ namespace Echoion::Core
|
||||
// Additional methods for internal use (not in interface)
|
||||
void setAudioDataCallback(
|
||||
const MusicManager::AudioDataCallback& callback);
|
||||
Api::Result<void> reloadConfig();
|
||||
Api::Result<void> reloadConfig() override;
|
||||
|
||||
// Internal implementations using full types
|
||||
Api::Result<void> playTrack(const Api::TrackInfo& track);
|
||||
|
||||
@@ -201,7 +201,7 @@ namespace Echoion::Core
|
||||
|
||||
// Download audio through proxy for playback
|
||||
[[nodiscard]] Api::Result<std::string>
|
||||
downloadAudioForPlayback(const std::string& url);
|
||||
downloadAudioForPlayback(const Api::TrackInfo& track);
|
||||
void cleanupTempFile(const std::string& filepath);
|
||||
|
||||
// Prefetch next track for seamless transitions
|
||||
|
||||
@@ -101,6 +101,14 @@ namespace Echoion::Core
|
||||
[[nodiscard]] Api::Result<std::string>
|
||||
getAudioStreamUrl(std::string_view videoId);
|
||||
|
||||
// Download the best audio to a file via yt-dlp (used when the
|
||||
// stream URL can't be opened directly — e.g. behind a SOCKS5 proxy
|
||||
// that ffmpeg can't use). yt-dlp applies the proxy + cookies and
|
||||
// writes to disk; returns the resulting file path.
|
||||
[[nodiscard]] Api::Result<std::string>
|
||||
downloadAudioToFile(std::string_view videoIdOrUrl,
|
||||
const std::string& outDir);
|
||||
|
||||
// Configure cookie options for yt-dlp
|
||||
void setCookiesPath(const std::string& path);
|
||||
void setCookiesFromBrowser(const std::string& browser);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Command.hpp"
|
||||
#include <CoreInterface.hpp>
|
||||
#include <Void/Log/Log.hpp>
|
||||
#include <format>
|
||||
|
||||
@@ -13,11 +14,24 @@ namespace Echoion::Core
|
||||
|
||||
void execute(const CommandContext& ctx) override
|
||||
{
|
||||
// This is a placeholder - actual reload is handled by the
|
||||
// plugin
|
||||
Void::Log::info("ReloadCommand", "{}", "Reload requested by user");
|
||||
ctx.reply("Reload is handled automatically by the plugin. Use "
|
||||
"the TS3 plugin menu to reload the core.");
|
||||
Void::Log::info("ReloadCommand", "{}",
|
||||
"Reload requested by user");
|
||||
|
||||
// Reload configuration from disk. A full core/plugin reload is
|
||||
// driven from the TS plugin menu (that lives in the plugin).
|
||||
if (auto core = ctx.service<Api::ICoreInterface>()) {
|
||||
auto result = core->reloadConfig();
|
||||
if (result) {
|
||||
ctx.reply("✅ Configuration reloaded. For a full core "
|
||||
"reload, use the TS plugin menu.");
|
||||
} else {
|
||||
ctx.reply(std::string("❌ Config reload failed: ") +
|
||||
result.error().message);
|
||||
}
|
||||
} else {
|
||||
ctx.reply("Reload is handled by the plugin. Use the TS "
|
||||
"plugin menu to reload the core.");
|
||||
}
|
||||
}
|
||||
|
||||
std::string_view getDescription() const override
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "Command.hpp"
|
||||
#include <CoreInterface.hpp>
|
||||
#include <Void/Log/Log.hpp>
|
||||
#include "echoion/core/Core.hpp" // For Core::reloadConfig
|
||||
#include <format>
|
||||
|
||||
namespace Echoion::Core
|
||||
@@ -15,15 +15,19 @@ namespace Echoion::Core
|
||||
void execute(const CommandContext& ctx) override
|
||||
{
|
||||
try {
|
||||
// Note: ctx.core is not directly accessible, we need to use
|
||||
// the MusicManager's core reference For now, reply with
|
||||
// instructions
|
||||
ctx.reply(
|
||||
"Config reload: Please use !reload command or restart "
|
||||
"the bot for config changes to take effect.");
|
||||
auto core = ctx.service<Api::ICoreInterface>();
|
||||
if (!core) {
|
||||
ctx.reply("Config reload is unavailable right now.");
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: Add core reference to CommandContext so commands
|
||||
// can call Core methods
|
||||
auto result = core->reloadConfig();
|
||||
if (result) {
|
||||
ctx.reply("✅ Configuration reloaded from disk.");
|
||||
} else {
|
||||
ctx.reply(std::string("❌ Failed to reload config: ") +
|
||||
result.error().message);
|
||||
}
|
||||
} catch (const std::exception& e) {
|
||||
Void::Log::error("ReloadConfigCommand", "{}", std::format(
|
||||
"ReloadConfig command exception: {}", e.what()));
|
||||
|
||||
Reference in new issue
Block a user