diff --git a/DownKyi.Core/BiliApi/Users/Models/SpaceSeasonsDetail.cs b/DownKyi.Core/BiliApi/Users/Models/SpaceSeasonsDetail.cs new file mode 100644 index 0000000..a540679 --- /dev/null +++ b/DownKyi.Core/BiliApi/Users/Models/SpaceSeasonsDetail.cs @@ -0,0 +1,32 @@ +using DownKyi.Core.BiliApi.Models; +using Newtonsoft.Json; +using System.Collections.Generic; + +namespace DownKyi.Core.BiliApi.Users.Models +{ + // https://api.bilibili.com/x/polymer/space/seasons_archives_list?mid={mid}&season_id={seasonId}&page_num={pageNum}&page_size={pageSize}&sort_reverse=false + public class SpaceSeasonsDetailOrigin : BaseModel + { + //[JsonProperty("code")] + //public int Code { get; set; } + //[JsonProperty("message")] + //public string Message { get; set; } + //[JsonProperty("ttl")] + //public int Ttl { get; set; } + [JsonProperty("data")] + public SpaceSeasonsDetail Data { get; set; } + } + + public class SpaceSeasonsDetail : BaseModel + { + [JsonProperty("aids")] + public List Aids { get; set; } + [JsonProperty("archives")] + public List Archives { get; set; } + [JsonProperty("meta")] + public SpaceSeasonsMeta Meta { get; set; } + [JsonProperty("page")] + public SpaceSeasonsSeriesPage Page { get; set; } + } + +} diff --git a/DownKyi.Core/BiliApi/Users/Models/SpaceSeriesDetail.cs b/DownKyi.Core/BiliApi/Users/Models/SpaceSeriesDetail.cs new file mode 100644 index 0000000..d77643f --- /dev/null +++ b/DownKyi.Core/BiliApi/Users/Models/SpaceSeriesDetail.cs @@ -0,0 +1,29 @@ +using DownKyi.Core.BiliApi.Models; +using Newtonsoft.Json; +using System.Collections.Generic; + +namespace DownKyi.Core.BiliApi.Users.Models +{ + // https://api.bilibili.com/x/series/archives?mid={mid}&series_id={seriesId}&only_normal=true&sort=desc&pn={pn}&ps={ps} + public class SpaceSeriesDetailOrigin : BaseModel + { + //[JsonProperty("code")] + //public int Code { get; set; } + //[JsonProperty("message")] + //public string Message { get; set; } + //[JsonProperty("ttl")] + //public int Ttl { get; set; } + [JsonProperty("data")] + public SpaceSeriesDetail Data { get; set; } + } + + public class SpaceSeriesDetail : BaseModel + { + [JsonProperty("aids")] + public List Aids { get; set; } + // page + [JsonProperty("archives")] + public List Archives { get; set; } + } + +} diff --git a/DownKyi.Core/BiliApi/Users/Models/SpaceSeriesMeta.cs b/DownKyi.Core/BiliApi/Users/Models/SpaceSeriesMeta.cs new file mode 100644 index 0000000..8377df1 --- /dev/null +++ b/DownKyi.Core/BiliApi/Users/Models/SpaceSeriesMeta.cs @@ -0,0 +1,28 @@ +using DownKyi.Core.BiliApi.Models; +using Newtonsoft.Json; +using System.Collections.Generic; + +namespace DownKyi.Core.BiliApi.Users.Models +{ + // https://api.bilibili.com/x/series/series?series_id={seriesId} + public class SpaceSeriesMetaOrigin : BaseModel + { + //[JsonProperty("code")] + //public int Code { get; set; } + //[JsonProperty("message")] + //public string Message { get; set; } + //[JsonProperty("ttl")] + //public int Ttl { get; set; } + [JsonProperty("data")] + public SpaceSeriesMetaData Data { get; set; } + } + + public class SpaceSeriesMetaData : BaseModel + { + [JsonProperty("meta")] + public SpaceSeriesMeta Meta { get; set; } + [JsonProperty("recent_aids")] + public List RecentAids { get; set; } + } + +} diff --git a/DownKyi.Core/BiliApi/Users/UserSpace.cs b/DownKyi.Core/BiliApi/Users/UserSpace.cs index 0f6dd56..e7c5c18 100644 --- a/DownKyi.Core/BiliApi/Users/UserSpace.cs +++ b/DownKyi.Core/BiliApi/Users/UserSpace.cs @@ -242,7 +242,7 @@ namespace DownKyi.Core.BiliApi.Users public static SpaceSeasonsSeries GetSeasonsSeries(long mid, int pageNum, int pageSize) { // https://api.bilibili.com/x/polymer/space/seasons_series_list?mid=49246269&page_num=1&page_size=18 - string url = $"https://api.bilibili.com/x/space/channel/video?mid={mid}&page_num={pageNum}&page_size={pageSize}"; + string url = $"https://api.bilibili.com/x/polymer/space/seasons_series_list?mid={mid}&page_num={pageNum}&page_size={pageSize}"; string referer = "https://www.bilibili.com"; string response = WebClient.RequestWeb(url, referer); @@ -261,18 +261,96 @@ namespace DownKyi.Core.BiliApi.Users } } + /// + /// 查询用户的合集的视频详情 + /// + /// + /// + /// + /// + public static SpaceSeasonsDetail GetSeasonsDetail(long mid, long seasonId, int pageNum, int pageSize) + { + // https://api.bilibili.com/x/polymer/space/seasons_archives_list?mid=23947287&season_id=665&sort_reverse=false&page_num=1&page_size=30 + string url = $"https://api.bilibili.com/x/polymer/space/seasons_archives_list?mid={mid}&season_id={seasonId}&page_num={pageNum}&page_size={pageSize}&sort_reverse=false"; + string referer = "https://www.bilibili.com"; + string response = WebClient.RequestWeb(url, referer); + + try + { + SpaceSeasonsDetailOrigin origin = JsonConvert.DeserializeObject(response); + if (origin == null || origin.Data == null) + { return null; } + return origin.Data; + } + catch (Exception e) + { + Utils.Debugging.Console.PrintLine("GetSeasonsDetail()发生异常: {0}", e); + LogManager.Error("UserSpace", e); + return null; + } + } + + /// + /// 查询用户的列表元数据 + /// + /// + /// + public static SpaceSeriesMetaData GetSeriesMeta(long seriesId) + { + // https://api.bilibili.com/x/series/series?series_id=1253087 + string url = $"https://api.bilibili.com/x/series/series?series_id={seriesId}"; + string referer = "https://www.bilibili.com"; + string response = WebClient.RequestWeb(url, referer); + + try + { + SpaceSeriesMetaOrigin origin = JsonConvert.DeserializeObject(response); + if (origin == null || origin.Data == null) + { return null; } + return origin.Data; + } + catch (Exception e) + { + Utils.Debugging.Console.PrintLine("GetSeriesMeta()发生异常: {0}", e); + LogManager.Error("UserSpace", e); + return null; + } + } + + /// + /// 查询用户的列表的视频详情 + /// + /// + /// + /// + /// + /// + public static SpaceSeriesDetail GetSeriesDetail(long mid, long seriesId, int pn, int ps) + { + // https://api.bilibili.com/x/series/archives?mid=27899754&series_id=1253087&only_normal=true&sort=desc&pn=1&ps=30 - // TODO - // https://api.bilibili.com/x/polymer/space/seasons_archives_list?mid=23947287&season_id=665&sort_reverse=false&page_num=1&page_size=30 + string url = $"https://api.bilibili.com/x/series/archives?mid={mid}&series_id={seriesId}&only_normal=true&sort=desc&pn={pn}&ps={ps}"; + string referer = "https://www.bilibili.com"; + string response = WebClient.RequestWeb(url, referer); - // https://api.bilibili.com/x/series/archives?mid=27899754&series_id=1253087&only_normal=true&sort=desc&pn=1&ps=30 - // https://api.bilibili.com/x/series/archives?mid=27899754&series_id=1253087&only_normal=true&sort=asc&pn=1&ps=30 - // https://api.bilibili.com/x/series/series?series_id=1253087 + try + { + SpaceSeriesDetailOrigin origin = JsonConvert.DeserializeObject(response); + if (origin == null || origin.Data == null) + { return null; } + return origin.Data; + } + catch (Exception e) + { + Utils.Debugging.Console.PrintLine("GetSeriesDetail()发生异常: {0}", e); + LogManager.Error("UserSpace", e); + return null; + } + } #endregion #region 课程 - /// /// 查询用户发布的课程列表 /// diff --git a/DownKyi.Core/DownKyi.Core.csproj b/DownKyi.Core/DownKyi.Core.csproj index 2ab62e5..4ee018b 100644 --- a/DownKyi.Core/DownKyi.Core.csproj +++ b/DownKyi.Core/DownKyi.Core.csproj @@ -217,11 +217,14 @@ + + +