public async Task <int> GetMylistGroupVideo(OtherOwneredMylist mylist, uint limit = 50) { var mylistGroupId = mylist.Id; var res = await ContextActionAsync(async context => { return(await context.Mylist.GetMylistGroupVideoAsync(mylistGroupId, (uint)mylist.Count, limit)); }); if (!res.IsOK) { return(0); } var videos = res.MylistVideoInfoItems; foreach (var item in videos) { var nicoVideo = Database.NicoVideoDb.Get(item.Video.Id); nicoVideo.Title = item.Video.Title; nicoVideo.ThumbnailUrl = item.Video.ThumbnailUrl.OriginalString; nicoVideo.PostedAt = item.Video.FirstRetrieve; nicoVideo.Length = item.Video.Length; nicoVideo.IsDeleted = item.Video.IsDeleted; nicoVideo.DescriptionWithHtml = item.Video.Description; nicoVideo.MylistCount = (int)item.Video.MylistCount; nicoVideo.CommentCount = (int)item.Thread.GetCommentCount(); nicoVideo.ViewCount = (int)item.Video.ViewCount; Database.NicoVideoDb.AddOrUpdate(nicoVideo); mylist.Add(item.Video.Id); } return(videos.Count); }
public async Task FillMylistGroupVideo(OtherOwneredMylist mylist) { if (mylist.IsFilled) { return; } if (mylist.ItemCount == 0) { throw new NotSupportedException(); } var count = (int)mylist.ItemCount; var tryCount = (count / 150) + 1; var increaseCount = mylist.Count; foreach (var index in Enumerable.Range(0, tryCount)) { if (index != 0) { await Task.Delay(500); } var result = await ContextActionAsync(async context => { return(await context.Mylist.GetMylistGroupVideoAsync( group_id: mylist.Id, from: (uint)(index * 150 + increaseCount), limit: 150 )); }); if (!result.IsOK) { break; } foreach (var item in result.MylistVideoInfoItems) { var nicoVideo = Database.NicoVideoDb.Get(item.Video.Id); nicoVideo.Title = item.Video.Title; nicoVideo.ThumbnailUrl = item.Video.ThumbnailUrl.OriginalString; nicoVideo.PostedAt = item.Video.FirstRetrieve; nicoVideo.Length = item.Video.Length; nicoVideo.IsDeleted = item.Video.IsDeleted; nicoVideo.DescriptionWithHtml = item.Video.Description; nicoVideo.MylistCount = (int)item.Video.MylistCount; nicoVideo.CommentCount = (int)item.Thread.GetCommentCount(); nicoVideo.ViewCount = (int)item.Video.ViewCount; Database.NicoVideoDb.AddOrUpdate(nicoVideo); mylist.Add(item.Video.Id); } } return; }
public OtherOwnedMylistIncrementalSource( OtherOwneredMylist list , MylistProvider mylistProvider , NGSettings ngSettings = null ) : base() { MylistGroupId = list.Id; Mylist = list; MylistProvider = mylistProvider; NgSettings = ngSettings; }
public async Task <OtherOwneredMylist> GetMylistGroupVideo(string mylistGroupId, uint from = 0, uint limit = 50) { var detail = await GetMylistGroupDetail(mylistGroupId); if (!detail.IsOK) { return(null); } var res = await ContextActionAsync(async context => { return(await context.Mylist.GetMylistGroupVideoAsync(mylistGroupId, from, limit)); }); if (!res.IsOK) { return(null); } var mylistInfo = detail.MylistGroup; var videos = res.MylistVideoInfoItems; var mylist = new OtherOwneredMylist() { Id = mylistGroupId, Label = mylistInfo.Name, Description = mylistInfo.Description, UserId = mylistInfo.UserId, ItemCount = (int)mylistInfo.Count, }; foreach (var item in videos) { var nicoVideo = Database.NicoVideoDb.Get(item.Video.Id); nicoVideo.Title = item.Video.Title; nicoVideo.ThumbnailUrl = item.Video.ThumbnailUrl.OriginalString; nicoVideo.PostedAt = item.Video.FirstRetrieve; nicoVideo.Length = item.Video.Length; nicoVideo.IsDeleted = item.Video.IsDeleted; nicoVideo.DescriptionWithHtml = item.Video.Description; nicoVideo.MylistCount = (int)item.Video.MylistCount; nicoVideo.CommentCount = (int)item.Thread.GetCommentCount(); nicoVideo.ViewCount = (int)item.Video.ViewCount; Database.NicoVideoDb.AddOrUpdate(nicoVideo); mylist.Add(item.Video.Id); } return(mylist); }
public async Task <OtherOwneredMylist> GetMylistGroupVideo(string mylistGroupId) { var detail = await GetMylistGroupDetail(mylistGroupId); if (!detail.IsOK) { return(null); } var mylistInfo = detail.MylistGroup; var mylist = new OtherOwneredMylist() { Id = mylistGroupId, Label = mylistInfo.Name, Description = mylistInfo.Description, UserId = mylistInfo.UserId, ItemCount = (int)mylistInfo.Count, }; var count = (int)detail.MylistGroup.Count; var tryCount = (count / 150) + 1; foreach (var index in Enumerable.Range(0, tryCount)) { if (index != 0) { await Task.Delay(500); } var result = await ContextActionAsync(async context => { return(await context.Mylist.GetMylistGroupVideoAsync(mylistGroupId, (uint)index * 150, 150)); }); if (!result.IsOK) { break; } foreach (var item in result.MylistVideoInfoItems) { var nicoVideo = Database.NicoVideoDb.Get(item.Video.Id); nicoVideo.Title = item.Video.Title; nicoVideo.ThumbnailUrl = item.Video.ThumbnailUrl.OriginalString; nicoVideo.PostedAt = item.Video.FirstRetrieve; nicoVideo.Length = item.Video.Length; nicoVideo.IsDeleted = item.Video.IsDeleted; nicoVideo.DescriptionWithHtml = item.Video.Description; nicoVideo.MylistCount = (int)item.Video.MylistCount; nicoVideo.CommentCount = (int)item.Thread.GetCommentCount(); nicoVideo.ViewCount = (int)item.Video.ViewCount; Database.NicoVideoDb.AddOrUpdate(nicoVideo); mylist.Add(item.Video.Id); } } return(mylist); }