コード例 #1
0
        public static async Task <bool> UpdateMylistGroupAsync(NiconicoContext context, string mylistId, string name, string description, bool isPublic, MylistSortKey defaultSortKey, MylistSortOrder defaultSortOrder)
        {
            var dict = new Dictionary <string, string>();

            dict.Add("name", name);
            dict.Add("description", description);
            dict.Add("isPublic", isPublic.ToString1Or0());
            dict.Add("defaultSortKey", defaultSortKey.ToQueryString());
            dict.Add("defaultSortOrder", defaultSortOrder.ToQueryString());

            var request = new HttpRequestMessage(HttpMethod.Put, new Uri($"https://nvapi.nicovideo.jp/v1/users/me/mylists/{mylistId}"));

#if WINDOWS_UWP
            request.Content         = new HttpFormUrlEncodedContent(dict);
            request.Headers.Referer = new Uri($"https://www.nicovideo.jp/my/mylist/{mylistId}");
#else
            request.Content          = new FormUrlEncodedContent(dict);
            request.Headers.Referrer = new Uri($"https://www.nicovideo.jp/my/mylist/{mylistId}");
#endif
            request.Headers.Add("X-Request-With", "https://www.nicovideo.jp");


            var res = await context.SendAsync(request);

            var json = await res.Content.ReadAsStringAsync();

            var result = JsonConvert.DeserializeObject <MylistUpdateResultResponse>(json);
            return(result.Meta.Status == 200);
        }
コード例 #2
0
        public static async Task <WatchAfterMylistGroupItemsResponse> GetWatchAfterMylistGroupItemsAsync(NiconicoContext context, MylistSortKey sortKey, MylistSortOrder sortOrder, uint pageSize, uint pageCount)
        {
            var uri = $"https://nvapi.nicovideo.jp/v1/users/me/watch-later?sortKey={sortKey.ToQueryString()}&sortOrder={sortOrder.ToQueryString()}&pageSize={pageSize}&page={pageCount + 1}";
            await context.PrepareCorsAsscessAsync(HttpMethod.Get, uri);

            return(await context.GetJsonAsAsync <WatchAfterMylistGroupItemsResponse>(uri, Converter.Settings,
                                                                                     haaders =>
            {
#if WINDOWS_UWP
                haaders.Referer = new Uri("https://www.nicovideo.jp/my/watchlater?ref=pc_mypage_menu");
#else
                haaders.Referrer = new Uri("https://www.nicovideo.jp/my/watchlater?ref=pc_mypage_menu");
#endif
            }));
        }
コード例 #3
0
        public static async Task <MylistGroupItemsResponse> GetMylistGroupItemsAsync(NiconicoContext context, long mylistId, MylistSortKey sortKey, MylistSortOrder sortOrder, uint pageSize, uint pageCount)
        {
            // Note: CORSのOPTIONSを先に送る奴が必要になるかも
            var uri = $"https://nvapi.nicovideo.jp/v2/mylists/{mylistId}?sortKey={sortKey.ToQueryString()}&sortOrder={sortOrder.ToQueryString()}&pageSize={pageSize}&page={pageCount + 1}";
            await context.PrepareCorsAsscessAsync(HttpMethod.Get, uri);

            return(await context.GetJsonAsAsync <MylistGroupItemsResponse>(uri, Converter.Settings));
        }