You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
downkyi/DownKyi.Core/BiliApi/Video/Ranking.cs

41 lines
1.3 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using DownKyi.Core.BiliApi.Video.Models;
using DownKyi.Core.Logging;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
namespace DownKyi.Core.BiliApi.Video
{
public static class Ranking
{
/// <summary>
/// 获取分区视频排行榜列表
/// </summary>
/// <param name="rid">目标分区tid</param>
/// <param name="day">3日榜或周榜3/7</param>
/// <param name="original"></param>
/// <returns></returns>
public static List<RankingVideoView> RegionRankingList(int rid, int day = 3, int original = 0)
{
string url = $"https://api.bilibili.com/x/web-interface/ranking/region?rid={rid}&day={day}&ps={original}";
string referer = "https://www.bilibili.com";
string response = WebClient.RequestWeb(url, referer);
try
{
var ranking = JsonConvert.DeserializeObject<RegionRanking>(response);
if (ranking != null) { return ranking.Data; }
else { return null; }
}
catch (Exception e)
{
Utils.Debug.Console.PrintLine("RegionRankingList()发生异常: {0}", e);
LogManager.Error("Ranking", e);
return null;
}
}
}
}