public async Task <List <LivestreamQueryResult> > GetTopStreams(TopStreamQuery topStreamQuery) { var pagedQuery = new MixerPagedQuery() { Skip = topStreamQuery.Skip, Take = topStreamQuery.Take }; var topStreams = await mixerClient.GetTopStreams(pagedQuery); return(topStreams.ConvertAll(input => { var channelIdentifier = new ChannelIdentifier(this, input.token); channelNameIdMap[input.token] = input.id; return new LivestreamQueryResult(channelIdentifier) { LivestreamModel = ConvertToLivestreamModel(input) }; })); }
public async Task <List <VodDetails> > GetVods(VodQuery vodQuery) { if (string.IsNullOrEmpty(vodQuery.StreamId)) { throw new ArgumentNullException("vodQuery.StreamId"); } int streamid; if (!int.TryParse(vodQuery.StreamId, out streamid)) { if (!channelNameIdMap.TryGetValue(vodQuery.StreamId, out streamid)) { var channel = await mixerClient.GetStreamDetails(vodQuery.StreamId, CancellationToken.None); channelNameIdMap[channel.token] = channel.id; streamid = channel.id; } } var pagedQuery = new MixerPagedQuery() { Skip = vodQuery.Skip, Take = vodQuery.Take }; var vods = await mixerClient.GetChannelVideos(streamid, pagedQuery); var vodDetails = vods.Select(x => new VodDetails() { Views = x.viewsTotal.GetValueOrDefault(), Length = TimeSpan.FromSeconds(x.duration), Title = x.name, RecordedAt = x.createdAt.GetValueOrDefault(), Url = $"{BaseUrl}{vodQuery.StreamId}?vod={x.id}", ApiClient = this, }).ToList(); return(vodDetails); }
public async Task <List <Channel> > GetTopStreams(MixerPagedQuery pagedQuery, CancellationToken cancellationToken = default(CancellationToken)) { var request = RequestConstants.Channels + $"?order=viewersCurrent:DESC&page={pagedQuery.Skip}&limit={pagedQuery.Take}"; return(await HttpClientExtensions.ExecuteRequest <List <Channel> >(request, cancellationToken)); }
/// <param name="channelId">Must be the "id" of the channel and not the channel name/token</param> /// <param name="pagedQuery"></param> /// <param name="cancellationToken"></param> public async Task <List <Recording> > GetChannelVideos(int channelId, MixerPagedQuery pagedQuery, CancellationToken cancellationToken = default(CancellationToken)) { var request = $"{RequestConstants.Videos.Replace("{0}", channelId.ToString())}?page={pagedQuery.Skip}&limit={pagedQuery.Take}"; return(await HttpClientExtensions.ExecuteRequest <List <Recording> >(request, cancellationToken)); }