コード例 #1
0
        public async Task GetStreamDetails()
        {
            var streamDetails = await sut.GetStreamDetails("monstercat");

            Assert.NotNull(streamDetails);
            Assert.NotNull(streamDetails.description);
        }
コード例 #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);
        }