//マイリストを移動 public void MoveMylist(MylistListEntryViewModel source, MylistListViewModel dest) { string token = GetMylistToken(source.Owner.Group); Dictionary <string, string> pair = new Dictionary <string, string>(); pair["group_id"] = source.Owner.Group.Id; pair["target_group_id"] = dest.Group.Id; pair["id_list[0][]"] = source.Entry.ItemId; pair["token"] = token; HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, MylistMoveAPI); //とりあえずマイリストだったら if (source.Owner.Group.Id == "0") { request.RequestUri = new Uri(DefListMoveAPI); } request.Content = new FormUrlEncodedContent(pair); var text = NicoNicoWrapperMain.GetSession().GetAsync(request).Result; //移動先がとりあえずマイリストだったら if (dest.Group.Id == "0") { AddDefMylist(source.Entry.Id, token); } }
//マイリストを移動 public void MoveMylist(IEnumerable <MylistListEntryViewModel> source, MylistListViewModel dest) { string token = GetMylistToken(source.First().Owner.Group); Dictionary <string, string> pair = new Dictionary <string, string>(); pair["group_id"] = source.First().Owner.Group.Id; pair["target_group_id"] = dest.Group.Id; pair["token"] = token; //id_list以外のペアを指定 var encodedContent = new FormUrlEncodedContent(pair); //エンコードされたデータを取得 var text = encodedContent.ReadAsStringAsync().Result; //id_listを付け足す text += MakeIdList(source); HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, MylistMoveAPI); //ソースがとりあえずマイリストだったら if (source.First().Owner.Group.Id == "0") { request.RequestUri = new Uri(DefListMoveAPI); } //データw指定 request.Content = new StringContent(text); //コンテンツタイプを設定 request.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/x-www-form-urlencoded"); //移動先がとりあえずマイリストだったら if (dest.Group.Id == "0") { foreach (MylistListEntryViewModel vm in source) { AddDefMylist(vm.Entry.Id, token); } } else { var ret = NicoNicoWrapperMain.GetSession().GetAsync(request).Result; } }
//マイリストをコピー public void CopyMylist(IEnumerable <MylistListEntryViewModel> source, MylistListViewModel dest) { string token = GetMylistToken(source.First().Owner.Group); Dictionary <string, string> pair = new Dictionary <string, string>(); pair["group_id"] = source.First().Owner.Group.Id; pair["target_group_id"] = dest.Group.Id; pair["token"] = token; //フォームエンコード済み文字列を取得 var encodedContent = new FormUrlEncodedContent(pair); var text = encodedContent.ReadAsStringAsync().Result; //IDリスト作成 text += MakeIdList(source); HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, MylistCopyAPI); if (source.First().Owner.Group.Id == "0") { request.RequestUri = new Uri(DefListCopyAPI); } request.Content = new StringContent(text); request.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/x-www-form-urlencoded"); if (dest.Group.Id == "0") { foreach (MylistListEntryViewModel vm in source) { AddDefMylist(vm.Entry.Id, token); } } else { var ret = NicoNicoWrapperMain.GetSession().GetAsync(request).Result; } }