//自分のマイリストを取得
        public List <NicoNicoMylistGroupData> GetMylistGroup()
        {
            List <NicoNicoMylistGroupData> ret = new List <NicoNicoMylistGroupData>();

            try {
                //マイリスト取得
                var json = DynamicJson.Parse(NicoNicoWrapperMain.Session.GetAsync(MylistGroupAPI).Result);
                foreach (var entry in json.mylistgroup)
                {
                    NicoNicoMylistGroupData data = new NicoNicoMylistGroupData();
                    data.CreateTime  = UnixTime.FromUnixTime((long)entry.create_time).ToString();
                    data.Description = HttpUtility.HtmlDecode(entry.description);

                    data.Id        = entry.id;
                    data.Name      = HttpUtility.HtmlDecode(entry.name);
                    data.IsPublic  = entry.@public == "0" ? false : true;
                    data.SortOrder = int.Parse(entry.sort_order);

                    ret.Add(data);
                }
                return(ret);
            } catch (RequestTimeout) {
                return(null);
            }
        }
Exemple #2
0
        //マイリストページからCSRFトークンを取得する
        public string GetMylistToken(NicoNicoMylistGroupData Group)
        {
            var api = "http://www.nicovideo.jp/my/mylist/#/" + Group.Id;

            var result = NicoNicoWrapperMain.GetSession().GetAsync(api).Result;

            return(result.Substring(result.IndexOf("NicoAPI.token = \"") + 17, 60));
        }
        public MylistListViewModel(MylistViewModel vm, NicoNicoMylistGroupData group, List<NicoNicoMylistData> list)
            : base(group.Name)
        {
            EditModeViewModel = new MylistEditModeViewModel(this);
            Owner = vm;
            Group = group;
            Mylist = new DispatcherCollection<MylistListEntryViewModel>(DispatcherHelper.UIDispatcher);
            foreach(NicoNicoMylistData data in list) {

                Mylist.Add(new MylistListEntryViewModel(this, data));
            }
            Sort(SortIndex);
        }
        //マイリストの情報を更新
        public void UpdateMylistGroup(NicoNicoMylistGroupData group, string token)
        {
            Dictionary <string, string> pair = new Dictionary <string, string>();

            pair["group_id"]     = group.Id;
            pair["name"]         = group.Name;
            pair["default_sort"] = "1";
            pair["description"]  = group.Description;
            pair["token"]        = token;

            HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, MylistGroupUpdateAPI);

            request.Content = new FormUrlEncodedContent(pair);

            var text = NicoNicoWrapperMain.GetSession().GetAsync(request).Result;
        }
Exemple #5
0
        //マイリストに追加
        public MylistResult AddMylist(NicoNicoMylistGroupData group, string cmsid, string desc, string token)
        {
            Dictionary <string, string> pair = new Dictionary <string, string>();

            pair["group_id"]    = group.Id;
            pair["item_id"]     = cmsid;
            pair["description"] = desc;
            pair["token"]       = token;

            HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, MylistAddAPI);

            request.Content = new FormUrlEncodedContent(pair);

            var text = NicoNicoWrapperMain.GetSession().GetAsync(request).Result;

            var json = DynamicJson.Parse(text);

            //エラー時
            if (json.error())
            {
                //もうすでに登録済み
                if (json.error.code == "EXIST")
                {
                    return(MylistResult.EXIST);
                }
            }
            if (json.status())
            {
                if (json.status == "ok")
                {
                    return(MylistResult.SUCCESS);
                }
            }
            //失敗
            return(MylistResult.FAILED);
        }
        //自分のマイリストを取得
        public List<NicoNicoMylistGroupData> GetMylistGroup()
        {
            List<NicoNicoMylistGroupData> ret = new List<NicoNicoMylistGroupData>();

            try {

                //マイリスト取得
                var json = DynamicJson.Parse(NicoNicoWrapperMain.Session.GetAsync(MylistGroupAPI).Result);
                foreach(var entry in json.mylistgroup) {

                    NicoNicoMylistGroupData data = new NicoNicoMylistGroupData();
                    data.CreateTime = UnixTime.FromUnixTime((long)entry.create_time).ToString();
                    data.Description = HttpUtility.HtmlDecode(entry.description);

                    data.Id = entry.id;
                    data.Name = HttpUtility.HtmlDecode(entry.name);
                    data.IsPublic = entry.@public == "0" ? false : true;
                    data.SortOrder = int.Parse(entry.sort_order);

                    ret.Add(data);
                }
                return ret;
            } catch(RequestTimeout) {

                return null;
            }
        }
 public void UpdateMylistGroup(NicoNicoMylistGroupData group)
 {
     UpdateMylistGroup(group, GetMylistToken(group));
 }
        //マイリストの情報を更新
        public void UpdateMylistGroup(NicoNicoMylistGroupData group, string token)
        {
            Dictionary<string, string> pair = new Dictionary<string, string>();
            pair["group_id"] = group.Id;
            pair["name"] = group.Name;
            pair["default_sort"] = "1";
            pair["description"] = group.Description;
            pair["token"] = token;

            HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, MylistGroupUpdateAPI);

            request.Content = new FormUrlEncodedContent(pair);

            var text = NicoNicoWrapperMain.GetSession().GetAsync(request).Result;
        }
        //マイリストページからCSRFトークンを取得する
        public string GetMylistToken(NicoNicoMylistGroupData Group)
        {
            var api = "http://www.nicovideo.jp/my/mylist/#/" + Group.Id;

            var result = NicoNicoWrapperMain.GetSession().GetAsync(api).Result;

            return result.Substring(result.IndexOf("NicoAPI.token = \"") + 17, 60);
        }
Exemple #10
0
        //マイリストに追加
        public MylistResult AddMylist(NicoNicoMylistGroupData group, string cmsid, string desc, string token)
        {
            Dictionary<string, string> pair = new Dictionary<string, string>();
            pair["group_id"] = group.Id;
            pair["item_id"] = cmsid;
            pair["description"] = desc;
            pair["token"] = token;

            HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, MylistAddAPI);

            request.Content = new FormUrlEncodedContent(pair);

            var text = NicoNicoWrapperMain.Session.GetAsync(request).Result;

            var json = DynamicJson.Parse(text);

            //エラー時
            if(json.error()) {

                //もうすでに登録済み
                if(json.error.code == "EXIST") {

                    return MylistResult.EXIST;
                }
            }
            if(json.status()) {

                if(json.status == "ok") {

                    return MylistResult.SUCCESS;
                }
            }
            //失敗
            return MylistResult.FAILED;
        }
 public void UpdateMylistGroup(NicoNicoMylistGroupData group)
 {
     UpdateMylistGroup(group, GetMylistToken(group));
 }
Exemple #12
0
        public void Refresh()
        {
            IsActive = true;

            Task.Run(() => {

                MylistListCollection.Clear();

                Status = "マイリスト取得中(とりあえずマイリスト)";
                NicoNicoMylistGroupData deflist = new NicoNicoMylistGroupData();
                deflist.Name = "とりあえずマイリスト";
                deflist.Description = "";
                deflist.Id = "0";

                MylistListCollection.Add(new MylistListViewModel(this, deflist, MylistInstance.GetDefMylist()));

                foreach(NicoNicoMylistGroupData group in MylistGroupInstance.GetMylistGroup()) {

                    Status = "マイリスト取得中(" + group.Name + ")";
                    MylistListCollection.Add(new MylistListViewModel(this, group, MylistInstance.GetMylist(group.Id)));
                }
                Status = "マイリスト取得完了";

                IsActive = false;
            });
        }