UI: Add SendChatMessage to YouTube API wrappers
parent
5a298106bc
commit
49dfc113c1
|
@ -1326,3 +1326,8 @@ 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.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.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."
|
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."
|
||||||
|
|
|
@ -497,7 +497,8 @@ bool OBSYoutubeActions::CreateEventAction(YoutubeApiWrappers *api,
|
||||||
blog(LOG_DEBUG, "No stream created.");
|
blog(LOG_DEBUG, "No stream created.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!apiYouTube->BindStream(broadcast.id, stream.id)) {
|
json11::Json json;
|
||||||
|
if (!apiYouTube->BindStream(broadcast.id, stream.id, json)) {
|
||||||
blog(LOG_DEBUG, "No stream binded.");
|
blog(LOG_DEBUG, "No stream binded.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -547,7 +548,8 @@ bool OBSYoutubeActions::ChooseAnEventAction(YoutubeApiWrappers *api,
|
||||||
blog(LOG_DEBUG, "No stream created.");
|
blog(LOG_DEBUG, "No stream created.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!apiYouTube->BindStream(selectedBroadcast, stream.id)) {
|
if (!apiYouTube->BindStream(selectedBroadcast, stream.id,
|
||||||
|
json)) {
|
||||||
blog(LOG_DEBUG, "No stream binded.");
|
blog(LOG_DEBUG, "No stream binded.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@ using namespace json11;
|
||||||
#define YOUTUBE_LIVE_TOKEN_URL "https://oauth2.googleapis.com/token"
|
#define YOUTUBE_LIVE_TOKEN_URL "https://oauth2.googleapis.com/token"
|
||||||
#define YOUTUBE_LIVE_VIDEOCATEGORIES_URL YOUTUBE_LIVE_API_URL "/videoCategories"
|
#define YOUTUBE_LIVE_VIDEOCATEGORIES_URL YOUTUBE_LIVE_API_URL "/videoCategories"
|
||||||
#define YOUTUBE_LIVE_VIDEOS_URL YOUTUBE_LIVE_API_URL "/videos"
|
#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 \
|
#define YOUTUBE_LIVE_THUMBNAIL_URL \
|
||||||
"https://www.googleapis.com/upload/youtube/v3/thumbnails/set"
|
"https://www.googleapis.com/upload/youtube/v3/thumbnails/set"
|
||||||
|
|
||||||
|
@ -274,7 +275,8 @@ bool YoutubeApiWrappers::InsertStream(StreamDescription &stream)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool YoutubeApiWrappers::BindStream(const QString broadcast_id,
|
bool YoutubeApiWrappers::BindStream(const QString broadcast_id,
|
||||||
const QString stream_id)
|
const QString stream_id,
|
||||||
|
json11::Json &json_out)
|
||||||
{
|
{
|
||||||
lastErrorMessage.clear();
|
lastErrorMessage.clear();
|
||||||
lastErrorReason.clear();
|
lastErrorReason.clear();
|
||||||
|
@ -285,7 +287,6 @@ bool YoutubeApiWrappers::BindStream(const QString broadcast_id,
|
||||||
const QString url = url_template.arg(broadcast_id, stream_id);
|
const QString url = url_template.arg(broadcast_id, stream_id);
|
||||||
const Json data = Json::object{};
|
const Json data = Json::object{};
|
||||||
this->broadcast_id = broadcast_id;
|
this->broadcast_id = broadcast_id;
|
||||||
Json json_out;
|
|
||||||
return InsertCommand(QT_TO_UTF8(url), "application/json", "",
|
return InsertCommand(QT_TO_UTF8(url), "application/json", "",
|
||||||
data.dump().c_str(), json_out);
|
data.dump().c_str(), json_out);
|
||||||
}
|
}
|
||||||
|
@ -583,3 +584,22 @@ bool YoutubeApiWrappers::FindStream(const QString &id, json11::Json &json_out)
|
||||||
|
|
||||||
return true;
|
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);
|
||||||
|
}
|
||||||
|
|
|
@ -57,7 +57,8 @@ public:
|
||||||
bool GetChannelDescription(ChannelDescription &channel_description);
|
bool GetChannelDescription(ChannelDescription &channel_description);
|
||||||
bool InsertBroadcast(BroadcastDescription &broadcast);
|
bool InsertBroadcast(BroadcastDescription &broadcast);
|
||||||
bool InsertStream(StreamDescription &stream);
|
bool InsertStream(StreamDescription &stream);
|
||||||
bool BindStream(const QString broadcast_id, const QString stream_id);
|
bool BindStream(const QString broadcast_id, const QString stream_id,
|
||||||
|
json11::Json &json_out);
|
||||||
bool GetBroadcastsList(json11::Json &json_out, const QString &page,
|
bool GetBroadcastsList(json11::Json &json_out, const QString &page,
|
||||||
const QString &status);
|
const QString &status);
|
||||||
bool
|
bool
|
||||||
|
@ -74,6 +75,8 @@ public:
|
||||||
json11::Json &json_out);
|
json11::Json &json_out);
|
||||||
bool StartLatestBroadcast();
|
bool StartLatestBroadcast();
|
||||||
bool StopLatestBroadcast();
|
bool StopLatestBroadcast();
|
||||||
|
bool SendChatMessage(const std::string &chat_id,
|
||||||
|
const QString &message);
|
||||||
|
|
||||||
void SetBroadcastId(QString &broadcast_id);
|
void SetBroadcastId(QString &broadcast_id);
|
||||||
QString GetBroadcastId();
|
QString GetBroadcastId();
|
||||||
|
|
Loading…
Reference in New Issue