完成合集和列表api

croire 2 years ago
parent 6b3044e9f7
commit 4fdb1c3f16

@ -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<long> Aids { get; set; }
[JsonProperty("archives")]
public List<SpaceSeasonsSeriesArchives> Archives { get; set; }
[JsonProperty("meta")]
public SpaceSeasonsMeta Meta { get; set; }
[JsonProperty("page")]
public SpaceSeasonsSeriesPage Page { get; set; }
}
}

@ -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<long> Aids { get; set; }
// page
[JsonProperty("archives")]
public List<SpaceSeasonsSeriesArchives> Archives { get; set; }
}
}

@ -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<long> RecentAids { get; set; }
}
}

@ -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
}
}
/// <summary>
/// 查询用户的合集的视频详情
/// </summary>
/// <param name="mid"></param>
/// <param name="seasonId"></param>
/// <param name="pageNum"></param>
/// <param name="pageSize"></param>
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<SpaceSeasonsDetailOrigin>(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;
}
}
/// <summary>
/// 查询用户的列表元数据
/// </summary>
/// <param name="seriesId"></param>
/// <returns></returns>
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<SpaceSeriesMetaOrigin>(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;
}
}
/// <summary>
/// 查询用户的列表的视频详情
/// </summary>
/// <param name="mid"></param>
/// <param name="seriesId"></param>
/// <param name="pn"></param>
/// <param name="ps"></param>
/// <returns></returns>
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<SpaceSeriesDetailOrigin>(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 课程
/// <summary>
/// 查询用户发布的课程列表
/// </summary>

@ -217,11 +217,14 @@
<Compile Include="BiliApi\Users\Models\SpacePublicationListTypeVideoZone.cs" />
<Compile Include="BiliApi\Users\Models\SpacePublicationListVideo.cs" />
<Compile Include="BiliApi\Users\Models\SpacePublicationPage.cs" />
<Compile Include="BiliApi\Users\Models\SpaceSeasonsDetail.cs" />
<Compile Include="BiliApi\Users\Models\SpaceSeasonsSeries.cs" />
<Compile Include="BiliApi\Users\Models\SpaceSeasonsSeriesArchives.cs" />
<Compile Include="BiliApi\Users\Models\SpaceSeasonsSeriesMeta.cs" />
<Compile Include="BiliApi\Users\Models\SpaceSeasonsSeriesOrigin.cs" />
<Compile Include="BiliApi\Users\Models\SpaceSeasonsSeriesPage.cs" />
<Compile Include="BiliApi\Users\Models\SpaceSeriesDetail.cs" />
<Compile Include="BiliApi\Users\Models\SpaceSeriesMeta.cs" />
<Compile Include="BiliApi\Users\Models\SpaceSettings.cs" />
<Compile Include="BiliApi\Users\Models\SpaceSettingsToutu.cs" />
<Compile Include="BiliApi\Users\Models\UpStat.cs" />

Loading…
Cancel
Save