新增GetVideoViewInfo API

This commit is contained in:
leiurayer 2023-09-07 01:12:27 +08:00
parent 99c6cf42c1
commit 66e73a2537
4 changed files with 3322 additions and 2 deletions

View File

@ -0,0 +1,28 @@
using BiliSharp.Api.Login;
using BiliSharp.Api.Sign;
using BiliSharp.Api.Video;
namespace BiliSharp.UnitTest.Api.Video
{
public class TestVideoInfo
{
[Fact]
public void TestGetVideoViewInfo_Default()
{
// 设置wbi keys
var info = LoginInfo.GetNavigationInfo();
var imgKey = info.Data.WbiImg.ImgUrl.Split('/').ToList().Last().Split('.')[0];
var subKey = info.Data.WbiImg.SubUrl.Split('/').ToList().Last().Split('.')[0];
var keys = new Tuple<string, string>(imgKey, subKey);
WbiSign.SetKey(keys);
string bvid = "BV1Pu4y1y7FA";
long aid = 915570400;
var videoInfo = VideoInfo.GetVideoViewInfo(bvid, aid);
Assert.Equal(bvid, videoInfo.Data.View.Bvid);
Assert.Equal(aid, videoInfo.Data.View.Aid);
}
}
}

View File

@ -583,13 +583,13 @@ namespace BiliSharp.Api.Models.User
///
/// </summary>
public class UserSpaceInfoDataTheme
{ }
{ }
/// <summary>
///
/// </summary>
public class UserSpaceInfoDataSysNotice
{ }
{ }
/// <summary>
///

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,35 @@
using BiliSharp.Api.Models.Video;
using BiliSharp.Api.Sign;
using System.Collections.Generic;
namespace BiliSharp.Api.Video
{
/// <summary>
/// 视频基本信息
/// </summary>
public static class VideoInfo
{
/// <summary>
/// 获取视频超详细信息(web端)
/// </summary>
/// <param name="bvid"></param>
/// <param name="aid"></param>
/// <returns></returns>
public static VideoView GetVideoViewInfo(string bvid, long aid)
{
var parameters = new Dictionary<string, object>
{
{ "platform", "web" },
//{ "need_operation_card", 1 },
//{ "web_location", 1446382 },
{ "need_elec", 1 },
{ "aid", aid },
{ "bvid", bvid },
};
string query = WbiSign.ParametersToQuery(WbiSign.EncodeWbi(parameters));
string url = $"https://api.bilibili.com/x/web-interface/wbi/view/detail?{query}";
return Utils.GetData<VideoView>(url);
}
}
}