From de31ec80ae104315cbfc9b5e61e1c4e8386acded Mon Sep 17 00:00:00 2001 From: gxalpha Date: Thu, 10 Oct 2024 10:08:12 +0200 Subject: [PATCH] UI: Remove SendChatMessage from YoutubeApiWrappers With the custom YouTube chat sending removed in the parent commit, there's no need to keep these functions anymore. Effectively reverts 49dfc113c1f458c3872cf35b1045ad1f03f37532. --- UI/data/locale/en-US.ini | 5 ----- UI/window-youtube-actions.cpp | 5 ++--- UI/youtube-api-wrappers.cpp | 19 ++----------------- UI/youtube-api-wrappers.hpp | 3 +-- 4 files changed, 5 insertions(+), 27 deletions(-) diff --git a/UI/data/locale/en-US.ini b/UI/data/locale/en-US.ini index e42f835c7..572b15f15 100644 --- a/UI/data/locale/en-US.ini +++ b/UI/data/locale/en-US.ini @@ -1557,11 +1557,6 @@ YouTube.Errors.livePermissionBlocked="Live streaming is unavailable on the selec YouTube.Errors.errorExecutingTransition="Transition failed due to a backend error. Please try again in a few seconds." YouTube.Errors.errorStreamInactive="YouTube is not receiving data for your stream. Please check your configuration and try again." YouTube.Errors.invalidTransition="The attempted transition was invalid. This may be due to the stream not having finished a previous transition. Please wait a few seconds and try again." -# Chat errors -YouTube.Errors.liveChatDisabled="Live chat is disabled on this stream." -YouTube.Errors.liveChatEnded="Live stream has ended." -YouTube.Errors.messageTextInvalid="The message text is not valid." -YouTube.Errors.rateLimitExceeded="You are sending messages too quickly." # Browser Dock YouTube.DocksRemoval.Title="Clear Legacy YouTube Browser Docks" YouTube.DocksRemoval.Text="These browser docks will be removed as deprecated:\n\n%1\nUse \"Docks/YouTube Live Control Room\" instead." diff --git a/UI/window-youtube-actions.cpp b/UI/window-youtube-actions.cpp index 52b5eaece..9c8533fd0 100644 --- a/UI/window-youtube-actions.cpp +++ b/UI/window-youtube-actions.cpp @@ -406,8 +406,7 @@ bool OBSYoutubeActions::CreateEventAction(YoutubeApiWrappers *api, BroadcastDesc blog(LOG_DEBUG, "No stream created."); return false; } - json11::Json json; - if (!apiYouTube->BindStream(broadcast.id, stream.id, json)) { + if (!apiYouTube->BindStream(broadcast.id, stream.id)) { blog(LOG_DEBUG, "No stream binded."); return false; } @@ -455,7 +454,7 @@ bool OBSYoutubeActions::ChooseAnEventAction(YoutubeApiWrappers *api, StreamDescr blog(LOG_DEBUG, "No stream created."); return false; } - if (!apiYouTube->BindStream(selectedBroadcast, stream.id, json)) { + if (!apiYouTube->BindStream(selectedBroadcast, stream.id)) { blog(LOG_DEBUG, "No stream binded."); return false; } diff --git a/UI/youtube-api-wrappers.cpp b/UI/youtube-api-wrappers.cpp index 1f8a184f2..1ed397f04 100644 --- a/UI/youtube-api-wrappers.cpp +++ b/UI/youtube-api-wrappers.cpp @@ -29,7 +29,6 @@ using namespace json11; #define YOUTUBE_LIVE_TOKEN_URL "https://oauth2.googleapis.com/token" #define YOUTUBE_LIVE_VIDEOCATEGORIES_URL YOUTUBE_LIVE_API_URL "/videoCategories" #define YOUTUBE_LIVE_VIDEOS_URL YOUTUBE_LIVE_API_URL "/videos" -#define YOUTUBE_LIVE_CHAT_MESSAGES_URL YOUTUBE_LIVE_API_URL "/liveChat/messages" #define YOUTUBE_LIVE_THUMBNAIL_URL "https://www.googleapis.com/upload/youtube/v3/thumbnails/set" #define DEFAULT_BROADCASTS_PER_QUERY "50" // acceptable values are 0 to 50, inclusive @@ -246,7 +245,7 @@ bool YoutubeApiWrappers::InsertStream(StreamDescription &stream) return stream.id.isEmpty() ? false : true; } -bool YoutubeApiWrappers::BindStream(const QString broadcast_id, const QString stream_id, json11::Json &json_out) +bool YoutubeApiWrappers::BindStream(const QString broadcast_id, const QString stream_id) { lastErrorMessage.clear(); lastErrorReason.clear(); @@ -256,6 +255,7 @@ bool YoutubeApiWrappers::BindStream(const QString broadcast_id, const QString st const QString url = url_template.arg(broadcast_id, stream_id); const Json data = Json::object{}; this->broadcast_id = broadcast_id; + Json json_out; return InsertCommand(QT_TO_UTF8(url), "application/json", "", data.dump().c_str(), json_out); } @@ -518,18 +518,3 @@ bool YoutubeApiWrappers::FindStream(const QString &id, json11::Json &json_out) return true; } - -bool YoutubeApiWrappers::SendChatMessage(const std::string &chat_id, const QString &message) -{ - QByteArray url = YOUTUBE_LIVE_CHAT_MESSAGES_URL "?part=snippet"; - - json11::Json json_in = Json::object{ - {"snippet", Json::object{ - {"liveChatId", chat_id}, - {"type", "textMessageEvent"}, - {"textMessageDetails", Json::object{{"messageText", QT_TO_UTF8(message)}}}, - }}}; - - json11::Json json_out; - return InsertCommand(url, "application/json", "POST", json_in.dump().c_str(), json_out); -} diff --git a/UI/youtube-api-wrappers.hpp b/UI/youtube-api-wrappers.hpp index 66c8ae46b..5216d2eb2 100644 --- a/UI/youtube-api-wrappers.hpp +++ b/UI/youtube-api-wrappers.hpp @@ -55,7 +55,7 @@ public: bool GetChannelDescription(ChannelDescription &channel_description); bool InsertBroadcast(BroadcastDescription &broadcast); bool InsertStream(StreamDescription &stream); - bool BindStream(const QString broadcast_id, const QString stream_id, json11::Json &json_out); + bool BindStream(const QString broadcast_id, const QString stream_id); bool GetBroadcastsList(json11::Json &json_out, const QString &page, const QString &status); bool GetVideoCategoriesList(QVector &category_list_out); bool SetVideoCategory(const QString &video_id, const QString &video_title, const QString &video_description, @@ -66,7 +66,6 @@ public: bool ResetBroadcast(const QString &broadcast_id, json11::Json &json_out); bool StartLatestBroadcast(); bool StopLatestBroadcast(); - bool SendChatMessage(const std::string &chat_id, const QString &message); void SetBroadcastId(QString &broadcast_id); QString GetBroadcastId();