public void MigrateTwitchVODMetadata() { var channelId = _twitchService.GetChannelIdFromChannelName("dasmehdi").GetAwaiter().GetResult(); ChannelVideos videos = null; var offset = 0; do { videos = _twitchService.GetVideosFromChannelId(channelId, offset).GetAwaiter().GetResult(); videos.Videos.ForEach(video => { var vod = new Vod() { ImportedAt = DateTime.UtcNow, Video = video }; var dbVod = _vodCollection.AddOrUpdateAsync(vod).GetAwaiter().GetResult(); Assert.IsInstanceOfType(dbVod, typeof(Vod)); }); offset += 100; } while (offset <= videos.Total); }
public VideoModel Load(Guid id) { Video video = Videos.SingleOrDefault(v => v.Id == id); if (video == null) { return(null); } return(new VideoModel { Video = video, Owner = Users.SingleOrDefault(u => u.Id == video.OwnerId), Channels = Channels.Where(c => ChannelVideos.Where(v => v.VideoId == video.Id).Select(v => v.ChannelId).Contains(c.Id)), Tags = Tags.Where(t => VideoTags.Where(v => v.VideoId == video.Id).Select(v => v.TagId).Contains(t.Id)), Views = Views.Where(v => v.VideoId == video.Id), Reactions = Reactions.Where(r => r.VideoId == video.Id), Favourites = Favourites.Where(f => f.VideoId == video.Id), Comments = Comments.Where(c => c.VideoId == video.Id) }); }