in Gems/Twitch/Code/Source/TwitchREST.cpp [705:776]
void TwitchREST::GetChannelVideos(ReceiptID& receipt, const AZStd::string& channelID, BroadCastType boradcastType, const AZStd::string& language, AZ::u64 offset)
{
AZStd::string url(BuildKrakenURL("channels") + "/" + channelID + "/videos?limit=100");
if (offset > 0)
{
url += "&offset=";
url += AZStd::to_string(offset);
}
AZStd::string bt( GetBroadCastTypeNameFromType(boradcastType) );
if( !bt.empty() )
{
url += "&broadcast_type=";
url += bt;
}
if( !language.empty() )
{
url += "&language=";
url += language;
}
AddHTTPRequest(url, Aws::Http::HttpMethod::HTTP_GET, GetDefaultHeaders(), [receipt, this](const Aws::Utils::Json::JsonView& jsonDoc, Aws::Http::HttpResponseCode httpCode)
{
ResultCode rc(ResultCode::TwitchRESTError);
VideoReturn videoReturn;
if (httpCode == Aws::Http::HttpResponseCode::OK)
{
rc = ResultCode::Success;
SafeGetJSONu64(videoReturn.Total, "_total", jsonDoc);
Aws::Utils::Array<Aws::Utils::Json::JsonView> jsonVideosArray = jsonDoc.GetArray("videos");
for (size_t index = 0; index < jsonVideosArray.GetLength(); index++)
{
Aws::Utils::Json::JsonView item = jsonVideosArray.GetItem(index);
VideoInfo vi;
SafeGetJSONString(vi.ID, "_id", item);
SafeGetJSONu64(vi.BroadcastID, "broadcast_id", item);
SafeGetJSONBroadCastType(vi.Type, "broadcast_type", item);
SafeGetJSONVideoChannel(vi.Channel, item);
SafeGetJSONString(vi.CreatedDate, "created_at", item);
SafeGetJSONString(vi.Description, "description", item);
SafeGetJSONString(vi.DescriptionHTML, "description_html", item);
SafeGetJSONVideoFPS(vi.FPS, item);
SafeGetJSONString(vi.Game, "game", item);
SafeGetJSONString(vi.Language, "language", item);
SafeGetJSONu64(vi.Length, "length", item);
SafeGetJSONVideoPreview(vi.Preview, item);
SafeGetJSONString(vi.PublishedDate, "published_at", item);
SafeGetJSONVideoResolutions(vi.Resolutions, item);
SafeGetJSONString(vi.Status, "status", item);
SafeGetJSONString(vi.TagList, "tag_list", item);
SafeGetJSONVideoThumbnails(vi.Thumbnails, item);
SafeGetJSONString(vi.Title, "title", item);
SafeGetJSONString(vi.URL, "url", item);
SafeGetJSONString(vi.Viewable, "viewable", item);
SafeGetJSONString(vi.ViewableAt, "viewable_at", item);
SafeGetJSONu64(vi.Views, "views", item);
videoReturn.Videos.push_back(vi);
}
}
TwitchNotifyBus::QueueBroadcast(&TwitchNotifyBus::Events::GetChannelVideos, VideoReturnValue(videoReturn, receipt, rc));
});
}