public static async Task <string> GetTagSearchDataAsync( NiconicoContext context , string tag , uint from , uint limit , Sort?sort , Order?order ) { var dict = new Dictionary <string, string>(); dict.Add("__format", "json"); dict.Add(nameof(tag), tag); dict.Add(nameof(from), from.ToString()); dict.Add(nameof(limit), limit.ToString()); if (order.HasValue) { dict.Add(nameof(order), order.Value == Order.Ascending ? "a" : "d"); } if (sort.HasValue) { dict.Add(nameof(sort), sort.Value.ToShortString()); } return(await context.GetStringAsync(NiconicoUrls.NICOVIDEO_CE_NICOAPI_V1_TAG_SEARCH, dict)); }
// ユーザーの投稿動画関連 public static Task <string> GetUserDataAsync(NiconicoContext context, uint user_id, uint page, Sort sortMethod, Order sortDir) { var url = NiconicoUrls.MakeUserVideoRssUrl(user_id.ToString(), page, sortMethod.ToShortString(), sortDir.ToShortString()); return(context .GetStringAsync(url)); }
public static Task <string> GetMylistSearchDataAsync( NiconicoContext context , string str , uint from , uint limit , Sort?sort , Order?order ) { var dict = new Dictionary <string, string>(); dict.Add("__format", "json"); dict.Add(nameof(str), str); dict.Add(nameof(from), from.ToString()); dict.Add(nameof(limit), limit.ToString()); if (order.HasValue) { dict.Add(nameof(order), order.Value.ToChar().ToString()); } if (sort.HasValue) { dict.Add(nameof(sort), sort.Value.ToShortString()); } return(context.GetStringAsync(NiconicoUrls.NICOVIDEO_CE_NICOAPI_V1_MYLIST_SEARCH, dict)); }
/// <summary> /// タイムシフト予約の削除用トークンを取得します。(要ログインセッション) /// </summary> /// <param name="context"></param> /// <returns></returns> public static async Task <ReservationToken> GetReservationToken(NiconicoContext context) { var timeshiftPageHtmlText = await context.GetStringAsync("http://live.nicovideo.jp/my_timeshift_list"); HtmlAgilityPack.HtmlDocument htmlDocument = new HtmlAgilityPack.HtmlDocument(); htmlDocument.LoadHtml(timeshiftPageHtmlText); var confirmNode = htmlDocument.DocumentNode .Descendants("input") .FirstOrDefault(x => x.Id == "confirm") ; // will return string like "ulck_0123456789" if (confirmNode != null) { return(new ReservationToken() { Token = confirmNode.GetAttributeValue("value", "") }); } else { return(null); } }
public static async Task <string> GetCommentDataAsync(NiconicoContext context, int userId, string commentServerUrl, int threadId, bool isKeyRequired) { var paramDict = new Dictionary <string, string>(); paramDict.Add("user_id", userId is 0 ? "" : userId.ToString()); paramDict.Add("version", "20090904"); paramDict.Add("thread", threadId.ToString()); paramDict.Add("res_from", "-1000"); // 公式動画の場合はThreadKeyとforce_184を取得する if (isKeyRequired) { var threadKeyResponse = await GetThreadKeyDataAsync(context, threadId) .ContinueWith(prevTask => ParseThreadKey(prevTask.Result)); if (threadKeyResponse != null) { paramDict.Add("threadkey", threadKeyResponse.ThreadKey); paramDict.Add("force_184", threadKeyResponse.Force184); } } var param = HttpQueryExtention.DictionaryToQuery(paramDict); var commentUrl = $"{commentServerUrl}thread?{Uri.EscapeUriString(param)}"; return(await context.GetStringAsync(commentUrl)); }
private static async Task <ChannelFollowApiInfo> GetFollowChannelApiInfo(NiconicoContext context, string channelScreenName) { var html = await context.GetStringAsync("http://ch.nicovideo.jp/" + channelScreenName); var document = new HtmlDocument(); document.LoadHtml(html); var bookmarkAnchorNode = document.DocumentNode.Descendants("a").Single(x => { if (x.Attributes.Contains("class") && x.Attributes["class"].Value.Contains("bookmark")) { return(x.Attributes["class"].Value.Split(' ').FirstOrDefault() == "bookmark"); } else { return(false); } }); return(new ChannelFollowApiInfo() { AddApi = bookmarkAnchorNode.Attributes["api_add"].Value, DeleteApi = bookmarkAnchorNode.Attributes["api_delete"].Value, Params = System.Net.WebUtility.HtmlDecode(bookmarkAnchorNode.Attributes["params"].Value) }); }
public static Task <string> GetMylistGroupDetailDataAsync(NiconicoContext context, string group_id) { var dict = new Dictionary <string, string>(); dict.Add(nameof(group_id), group_id); return(context.GetStringAsync(NiconicoUrls.MylistGroupDetailApi, dict)); }
private static Task <string> GetLiveInfoJsonAsync(NiconicoContext context, string liveId) { var dict = new Dictionary <string, string>(); dict.Add("v", liveId); dict.Add("__format", "json"); return(context.GetStringAsync(NiconicoUrls.CeLiveVideoInfoApi, dict)); }
public static async Task <string> GetTagSearchDataAsync(NiconicoContext context, string tag, uint pageCount, Sort sortMethod, Order sortDir) { var sortMethodChar = sortMethod.ToShortString(); var sortDirChar = sortDir.ToShortString(); return(await context .GetStringAsync(NiconicoUrls.MakeTagSearchUrl(System.Net.WebUtility.UrlEncode(tag), pageCount, sortMethodChar, sortDirChar))); }
private static Task <string> GetLiveCommunityVideoJsonAsync(NiconicoContext context, string communityOrChannelId) { var dict = new Dictionary <string, string>(); dict.Add("community_id", communityOrChannelId); dict.Add("__format", "json"); return(context.GetStringAsync(NiconicoUrls.CeLiveCommunityVideoApi, dict)); }
public static async Task <string> __DeleteFollowChannelAsync(NiconicoContext context, string channelId) { var info = await context.Channel.GetChannelInfo(channelId); var apiInfo = await GetFollowChannelApiInfo(context, info.ScreenName); return(await context.GetStringAsync($"{apiInfo.DeleteApi}?{apiInfo.Params}")); }
public static Task <string> GetOtherStreamsDataAsync( NiconicoContext context, StatusType status, ushort pageIndex) { return(context.GetStringAsync( pageIndex > 1 ? $"{NiconicoUrls.LiveIndexZeroStreamListUrl}{status.ToStatusTypeString()}&zpage={pageIndex}" : $"{NiconicoUrls.LiveIndexZeroStreamListUrl}{status.ToStatusTypeString()}" )); }
public static Task <string> GetCommunityLiveInfoDataAsync(NiconicoContext context, string community_id) { var dict = new Dictionary <string, string>(); dict.Add("__format", "json"); dict.Add(nameof(community_id), community_id); return(context.GetStringAsync(NiconicoUrls.NICOVIDEO_CE_LIVEAPI_V1_COMMUNITY_VIDEO, dict)); }
public static async Task <string> GetVideoDataAsync(NiconicoContext context, string videoId) { var dict = new Dictionary <string, string>(); dict.Add("__format", "json"); dict.Add("v", videoId); return(await context.GetStringAsync(NiconicoUrls.NICOVIDEO_CE_NICOAPI_V1_VIDEO_INFO, dict)); }
public static async Task <string> GetVideoArrayDataAsync(NiconicoContext context, IEnumerable <string> videoIdList) { var dict = new Dictionary <string, string>(); dict.Add("__format", "json"); dict.Add("v", string.Join(",", videoIdList)); return(await context.GetStringAsync(NiconicoUrls.NICOVIDEO_CE_NICOAPI_V1_VIDEO_INFO_ARRAY, dict)); }
public static Task <string> GetNGCommentDataAsync(NiconicoContext context) { var dict = new Dictionary <string, string>(); dict.Add("mode", "get"); return(context .GetStringAsync(NiconicoUrls.UserNGCommentUrl + "?mode=get")); }
public static async Task <NicoCasLiveProgramResponse> GetLiveProgramAsync(NiconicoContext context, string liveId) { const string NicocasLiveUrlFormat = @"https://api.cas.nicovideo.jp/v1/services/live/programs/{0}"; var json = await context.GetStringAsync(string.Format(NicocasLiveUrlFormat, liveId)); var response = JsonConvert.DeserializeObject <NicoCasLiveProgramResponse>(json); return(response); }
public static async Task <string> GetFlvDataAsync(NiconicoContext context, string requestId, string cKey) { await context .GetAsync($"{NiconicoUrls.VideoWatchPageUrl}{requestId}"); await Task.Delay(1000); return(await context .GetStringAsync($"{NiconicoUrls.VideoFlvUrl}{requestId}?as3=1")); }
private static Task <string> GetRecommendDataAsync(NiconicoContext context, string user_tags, int seed, int page) { var dict = new Dictionary <string, string>(); dict.Add(nameof(user_tags), user_tags); dict.Add(nameof(seed), seed.ToString()); dict.Add(nameof(page), page.ToString()); return(context.GetStringAsync(NiconicoUrls.RecommendApiUrl, dict)); }
public static Task <string> GetOnAirStreamsIndexDataAsync(NiconicoContext context, ushort pageIndex) { var sb = new StringBuilder(NiconicoUrls.LiveZappingListIndexUrl); if (pageIndex != 1) { sb.Append("&zpage="); sb.Append(pageIndex); } return(context.GetStringAsync(sb.ToString())); }
public static Task <string> RemoveHistoryDataAsync( NiconicoContext context, string token, string requestId) { if (!NiconicoRegex.IsVideoId(requestId) && !uint.TryParse(requestId, out var _)) { throw new ArgumentException(); } return(context .GetStringAsync($"{NiconicoUrls.VideoRemoveUrl}{token}&video_id={requestId}")); }
/// <summary> /// /// </summary> /// <param name="context"></param> /// <param name="channelId"></param> /// <param name="page"></param> /// <returns></returns> public static Task <string> GetChannelVideoPageHtmlAsync(NiconicoContext context, string channelId, int page) { var directoryName = ChannelIdToURLDirectoryName(channelId); Dictionary <string, string> dict = new Dictionary <string, string>(); if (page != 0) { dict.Add("page", (page + 1).ToString()); } return(context.GetStringAsync($"{NiconicoUrls.ChannelUrlBase}{directoryName}/video", dict)); }
// コメントの送信 public static async Task <string> GetPostKeyAsync(NiconicoContext context, string threadId, int commentCount) { var paramDict = new Dictionary <string, string>(); paramDict.Add("thread", threadId); paramDict.Add("block_no", ((commentCount) / 100).ToString()); paramDict.Add("device", "1"); paramDict.Add("version", "1"); paramDict.Add("version_sub", "6"); return(await context.GetStringAsync(NiconicoUrls.VideoPostKeyUrl, paramDict)); }
// Note: 放送者によって取得するAPIが異なる // 「公式・チャンネル」と「コミュニティ」 // コミュニティ放送の場合だけコミュニティIDが必要で // コミュニティ放送の生放送IDを間違って公式・チャンネル側のAPIに使うと // 何もリコメンドが得られない(jsonの空配列が返ってくる) // コミュニティ向けのAPIはコミュニティIDと生放送IDの両方が必須で // 正しく指定しなかった場合は エラーコード 400 が返される // データ構造は両方とも共通している public static Task <string> GetOfficialOrChannelLiveRecommendJsonAsync(NiconicoContext context, string liveId) { if (!liveId.StartsWith("lv")) { throw new ArgumentException($"liveId is must StartWith \"lv\"."); } var dict = new Dictionary <string, string>(); dict.Add("video_id", liveId); return(context.GetStringAsync("http://live.nicovideo.jp/api/video.recommendation", dict)); }
public static Task <string> VoteDataAsync(NiconicoContext context, string requestId, ushort choiceNumber) { if (!NiconicoRegex.IsLiveId(requestId)) { throw new ArgumentException(); } if (choiceNumber > 8) { throw new ArgumentException(); } return(context .GetStringAsync($"{NiconicoUrls.LiveVoteUrl}?v={requestId}&id={choiceNumber}")); }
public static Task <string> GetCKeyDataAsync(NiconicoContext context, string refererId, string requestId) { if (!NiconicoRegex.IsLiveId(refererId)) { throw new ArgumentException(); } if (!NiconicoRegex.IsVideoId(requestId)) { throw new ArgumentException(); } return(context .GetStringAsync($"{NiconicoUrls.LiveCKeyUrl}?referer_id={refererId}&id={requestId}")); }
public static async Task <string> GetRelatedPlaylistDataAsync(NiconicoContext context, string videoId, string referer) { var dict = new Dictionary <string, string>(); dict.Add("watch_id", videoId); dict.Add("referer", referer); dict.Add("continuous", ""); dict.Add("playlist_type", ""); var query = HttpQueryExtention.DictionaryToQuery(dict); return(await context .GetStringAsync($"{NiconicoUrls.VideoPlaylistApiUrl}?{query}")); }
// マイリストの詳細取得 public static Task <string> GetMylistGroupDetailDataAsync( NiconicoContext context , string group_id , bool isNeedDetail ) { var dict = new Dictionary <string, string>(); dict.Add("__format", "json"); dict.Add(nameof(group_id), group_id); dict.Add(nameof(isNeedDetail), isNeedDetail.ToString1Or0()); return(context.GetStringAsync(NiconicoUrls.NICOVIDEO_CE_NICOAPI_V1_MYLISTGROUP_GET, dict)); }
public static async Task <string> GetFlvDataAsync(NiconicoContext context, string requestId) { // if( !NiconicoRegex.IsVideoId( requestId ) ) { // throw new ArgumentException(); } await context .GetAsync($"{NiconicoUrls.VideoWatchPageUrl}{requestId}"); await Task.Delay(1000); return(await context .GetStringAsync($"{NiconicoUrls.VideoFlvUrl}{requestId}?as3=1")); }
public static Task <string> GetChannelInfoJsonAsync(NiconicoContext context, string channelId) { string channelIdNumberOnly = channelId; if (channelId.StartsWith("ch") && channelId.Skip(2).All(c => c >= '0' && c <= '9')) { channelIdNumberOnly = channelId.Remove(0, 2); } if (channelIdNumberOnly.All(c => c >= '0' && c <= '9')) { return(context.GetStringAsync($"{NiconicoUrls.ChannelInfoApiUrl}{channelIdNumberOnly}")); } else { throw new NotSupportedException(); } }