Esempio n. 1
0
        public async Task <List <LivestreamQueryResult> > GetTopStreams(TopStreamQuery topStreamQuery)
        {
            var pagedQuery = new BeamProPagedQuery()
            {
                Skip = topStreamQuery.Skip,
                Take = topStreamQuery.Take
            };
            var topStreams = await beamProClient.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)
                };
            }));
        }
Esempio n. 2
0
        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 beamProClient.GetStreamDetails(vodQuery.StreamId, CancellationToken.None);

                    channelNameIdMap[channel.token] = channel.id;
                    streamid = channel.id;
                }
            }

            var pagedQuery = new BeamProPagedQuery()
            {
                Skip = vodQuery.Skip, Take = vodQuery.Take
            };
            var vods = await beamProClient.GetChannelVideos(streamid, pagedQuery);

            var vodDetails = vods.ConvertAll(input => new VodDetails()
            {
                Views      = input.viewsTotal.GetValueOrDefault(),
                Length     = TimeSpan.FromSeconds(input.duration),
                Title      = input.name,
                RecordedAt = input.createdAt.GetValueOrDefault(),
                Url        = input.vods?[0]?.baseUrl,
                ApiClient  = this,
            });

            return(vodDetails);
        }
Esempio n. 3
0
        public async Task <List <Channel> > GetTopStreams(BeamProPagedQuery 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));
        }
Esempio n. 4
0
        /// <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, BeamProPagedQuery 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));
        }