public async Task SyncMylistGroups() { if (_UserMylists.Count == 0) { // とりあえずマイリストを手動で追加 Deflist = new MylistGroupInfo("0", HohoemaApp, this) { Name = "とりあえずマイリスト", Description = "ユーザーの一時的なマイリストです", UserId = HohoemaApp.LoginUserId.ToString(), IsPublic = false, Sort = MylistDefaultSort.Latest }; _UserMylists.Add(Deflist); await Deflist.Refresh(); } // ユーザーのマイリストグループの一覧を取得 List <LoginUserMylistGroup> mylistGroupDataLists = null; try { mylistGroupDataLists = await HohoemaApp.ContentFinder.GetLoginUserMylistGroups(); } catch { Debug.WriteLine("ユーザーマイリストの更新に失敗しました。"); } if (mylistGroupDataLists == null) { return; } // 追加分だけを検出してUserMylistに追加 var addedMylistGroups = mylistGroupDataLists .Where(x => _UserMylists.All(y => x.Id != y.GroupId)) .ToArray(); foreach (var userMylist in addedMylistGroups) { var addedMylistGroupInfo = MylistGroupInfo.FromMylistGroupData(userMylist, HohoemaApp, this); _UserMylists.Add(addedMylistGroupInfo); await addedMylistGroupInfo.Refresh(); await Task.Delay(500); } // 削除分だけ検出してUserMylistから削除 var removedMylistGroups = _UserMylists .Where(x => !x.IsDeflist) .Where(x => mylistGroupDataLists.All(y => x.GroupId != y.Id)) .ToArray(); foreach (var removeMylistGroup in removedMylistGroups) { _UserMylists.Remove(removeMylistGroup); } }
public async Task <ContentManageResult> CopyMylistTo(MylistGroupInfo targetGroupInfo, params string[] videoIdList) { var threadIdList = videoIdList.Select(x => { return(_VideoIdToThreadIdMap[x]); }) .ToArray(); var result = await HohoemaApp.NiconicoContext.User.CopyMylistItemAsync(this.GroupId, targetGroupInfo.GroupId, NiconicoItemType.Video, threadIdList); if (result == ContentManageResult.Success) { await targetGroupInfo.Refresh(); } return(result); }
public void UpdateRequestMylist(MylistGroupInfo info) { if (info.IsDeflist) { var updater = HohoemaApp.BackgroundUpdater.RegistrationBackgroundUpdateScheduleHandler(info , "mylist_deflist", label: "とりあえずマイリスト" ); } else { var updater = HohoemaApp.BackgroundUpdater.RegistrationBackgroundUpdateScheduleHandler(info , "mylist_" + info.Name, label: "Mylist:" + info.Name ); } }
public async Task SyncMylistGroups() { using (var releaser = await _UpdateLock.LockAsync()) { if (_UserMylists.Count == 0) { // とりあえずマイリストを手動で追加 Deflist = new MylistGroupInfo("0", HohoemaApp, this) { Label = "とりあえずマイリスト", Description = "ユーザーの一時的なマイリストです", UserId = HohoemaApp.LoginUserId.ToString(), IsPublic = false, Sort = MylistDefaultSort.Latest }; _UserMylists.Add(Deflist); await Deflist.Refresh(); } // ユーザーのマイリストグループの一覧を取得 List <LoginUserMylistGroup> mylistGroupDataLists = null; mylistGroupDataLists = await HohoemaApp.ContentProvider.GetLoginUserMylistGroups(); if (mylistGroupDataLists == null) { return; } // 追加分だけを検出してUserMylistに追加 var addedMylistGroups = mylistGroupDataLists .Where(x => _UserMylists.All(y => x.Id != y.GroupId)) .Select(x => MylistGroupInfo.FromMylistGroupData(x, HohoemaApp, this)) .ToArray(); foreach (var userMylist in addedMylistGroups) { _UserMylists.Add(userMylist); } // 削除分だけ検出してUserMylistから削除 var removedMylistGroups = _UserMylists .Where(x => !x.IsDeflist) .Where(x => mylistGroupDataLists.All(y => x.GroupId != y.Id)) .ToArray(); foreach (var removeMylistGroup in removedMylistGroups) { _UserMylists.Remove(removeMylistGroup); } // 追加分の更新を実行 foreach (var userMylist in addedMylistGroups) { try { await userMylist.Refresh(); } catch (Exception e) { await(App.Current as App).WriteErrorFile(e); } await Task.Delay(500); } } }