Beispiel #1
0
        public async Task GetChannelVideos()
        {
            // to find a user to query for recordings, look for hasVod=true in the response for channels "https://beam.pro/api/v1/channels?order=hasVod:DESC"
            // you must use the "id" of the channel rather than the channel name/token
            var videos = await sut.GetChannelVideos(1903, new BeamProPagedQuery()
            {
                Take = 10
            });

            Assert.NotEmpty(videos);
            Assert.NotNull(videos[0].duration);
        }
Beispiel #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);
        }