public static List <string> GetList(int cate_id, DateTime from, DateTime to) { Log.Info($"正在获取排行 - 分区{cate_id} / 时间{from.ToString("yyyyMMdd")}~{to.ToString("yyyyMMdd")}"); string url = "http://" + $"s.search.bilibili.com/cate/search?main_ver=v3&search_type=video&view_type=hot_rank&pic_size=160x100&order=click©_right=-1&cate_id={cate_id}&page=1&pagesize=150&time_from={from.ToString("yyyyMMdd")}&time_to={to.ToString("yyyyMMdd")}"; string html = BiliInterface.GetHtml(url); if (html == null) { return(null); } JObject obj = JObject.Parse(html); IEnumerable <string> avs = from n in obj["result"] select "av" + Regex.Match((string)n["arcurl"], @"\d+").Value; return(avs.ToList()); }
public static List <string> GetSearch(string keyword, int tids_1, int tids_2, string order, DateTime needFrom, int need = 0) { int page = 1; List <string> re = new List <string>(); //highlight=1会导致title被加入高亮样式html,改成0还是有,无解 string url = "http://" + $"api.bilibili.com/x/web-interface/search/type?jsonp=jsonp&highlight=0&search_type=video&keyword={keyword}&order={order}&duration=0&page={page}&tids={tids_2}"; string html = BiliInterface.GetHtml(url); if (html == null) { return(null); } JObject obj = JObject.Parse(html); int numResults = (int)obj["data"]["numResults"]; int numPages = (int)obj["data"]["numPages"]; Log.Info($"找到{numResults}个,{numPages}页"); for (int i = 2; i <= numPages + 1; i++) { IList <JToken> results = obj["data"]["result"].Children().ToList(); foreach (var result in results) { DateTime uploadtime = UnixTimeStampToDateTime(result["pubdate"].ToObject <double>()); if (uploadtime >= needFrom.Date) { string avnum = "av" + result["aid"]; re.Add(avnum); } else { i = 99999; break; } } if (i == 99999) { break; } url = "http://" + $"api.bilibili.com/x/web-interface/search/type?jsonp=jsonp&search_type=video&keyword={keyword}&order={order}&duration=0&page={i}&tids={tids_2}"; html = BiliInterface.GetHtml(url); obj = JObject.Parse(html); } return(re); }
public static List <string> GetListOld(SortType type, int zone, int page, DateTime from, DateTime to) { Log.Info("正在获取排行(旧版) - 依据" + type.ToString().ToLower() + "/分区" + zone + "/分页" + page + "/时间" + from.ToString("yyyy-MM-dd") + "~" + to.ToString("yyyy-MM-dd")); string url = "http://www.bilibili.com/list/" + type.ToString() + "-" + zone + "-" + page + "-" + from.ToString("yyyy-MM-dd") + "~" + to.ToString("yyyy-MM-dd") + ".html"; string html = BiliInterface.GetHtml(url); if (html == null) { return(null); } int p = html.IndexOf("href=\"/video/av"); List <string> r = new List <string>(); while (p > 0) { string s = html.Substring(p + 13, html.IndexOf("/", p + 13) - p - 13); if (!r.Contains(s)) { r.Add(s); } p = html.IndexOf("href=\"/video/av", p + 3); } return(r); }
private void Http_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) { try { string response = e.Result; JArray result = JArray.Parse(response); List <Asset> asserts = new List <Asset>(); bool hasBeta = false; bool hasStable = false; if (result != null) { foreach (JObject release in result) { if ((bool)release["prerelease"]) { if (!hasBeta) { Asset ass = new Asset(); ass.Parase(release); if (ass.IsNewVersion(Version)) { asserts.Add(ass); hasBeta = true; } } } else { Asset ass = new Asset(); ass.Parase(release); if (ass.IsNewVersion(Version)) { asserts.Add(ass); hasStable = true; } break; } } } if (asserts.Count != 0) { foreach (Asset ass in asserts) { Log.Info($"发现新版本{ass.name}" + (ass.prerelease ? "beta" : "")); } int stable = asserts.Count - 1; string changelog = "更新日志获取失败惹 T T"; try { changelog = BiliInterface.GetHtml("https://raw.githubusercontent.com/SkiTiSu/BiliRanking/master/BiliRanking/changelog.txt"); changelog = changelog.Substring(0, changelog.IndexOf("\n\n")); } catch { Log.Warn("更新日志获取失败"); } if (!checkBeta && hasStable) { DialogResult res = MessageBox.Show($"发现新版本{asserts[stable].name}啦\r\n最近{changelog}\r\n\r\n马上更新嘛?", @"\(^o^)/更新啦", MessageBoxButtons.YesNo); if (res == DialogResult.Yes) { StartDownload(asserts[stable]); } else { Log.Info("更新被取消"); } } else if (checkBeta && (hasBeta || hasStable)) { DialogResult res = MessageBox.Show($"发现新版本{asserts[0].name}beta啦\r\n最近{changelog}\r\n\r\n马上更新嘛?", @"\(^o^)/更新啦", MessageBoxButtons.YesNo); if (res == DialogResult.Yes) { StartDownload(asserts[0]); } else { Log.Info("更新被取消"); } } else { Log.Info("没有符合要求的更新"); } } else { Log.Info("没有发现新版本"); } } catch (Exception ex) { Log.Error("检查更新失败 - 解析json失败"); Log.Debug(ex.Message); } }