|
@@ -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);
|
|
|
|
+}
|