新增收藏夹信息api

croire 3 years ago
parent 67e7f38f9d
commit 7a0f3df4fb

@ -0,0 +1,40 @@
using DownKyi.Core.BiliApi.Favorites.Models;
using DownKyi.Core.Logging;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DownKyi.Core.BiliApi.Favorites
{
public static class FavoritesInfo
{
/// <summary>
/// 获取收藏夹元数据
/// </summary>
/// <param name="mediaId"></param>
public static FavoritesMetaInfo GetFavoritesInfo(long mediaId)
{
string url = $"https://api.bilibili.com/x/v3/fav/folder/info?media_id={mediaId}";
string referer = "https://www.bilibili.com";
string response = WebClient.RequestWeb(url, referer);
try
{
var info = JsonConvert.DeserializeObject<FavoritesMetaInfoOrigin>(response);
if (info != null) { return info.Data; }
else { return null; }
}
catch (Exception e)
{
Utils.Debug.Console.PrintLine("GetFavoritesInfo()发生异常: {0}", e);
LogManager.Error("FavoritesInfo", e);
return null;
}
}
}
}

@ -0,0 +1,79 @@
using DownKyi.Core.BiliApi.Models;
using Newtonsoft.Json;
namespace DownKyi.Core.BiliApi.Favorites.Models
{
// https://api.bilibili.com/x/v3/fav/folder/info
public class FavoritesMetaInfoOrigin : 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 FavoritesMetaInfo Data { get; set; }
}
public class FavoritesMetaInfo : BaseModel
{
[JsonProperty("id")]
public long Id { get; set; }
[JsonProperty("fid")]
public long Fid { get; set; }
[JsonProperty("mid")]
public long Mid { get; set; }
// attr
[JsonProperty("title")]
public string Title { get; set; }
[JsonProperty("cover")]
public string Cover { get; set; }
[JsonProperty("upper")]
public FavUpper Upper { get; set; }
// cover_type
[JsonProperty("cnt_info")]
public FavStatus CntInfo { get; set; }
// type
[JsonProperty("intro")]
public string Intro { get; set; }
[JsonProperty("ctime")]
public long Ctime { get; set; }
[JsonProperty("mtime")]
public long Mtime { get; set; }
// state
[JsonProperty("fav_state")]
public int FavState { get; set; }
[JsonProperty("like_state")]
public int LikeState { get; set; }
[JsonProperty("media_count")]
public int MediaCount { get; set; }
}
public class FavUpper : BaseModel
{
[JsonProperty("mid")]
public long Mid { get; set; }
[JsonProperty("name")]
public string Name { get; set; }
[JsonProperty("face")]
public string Face { get; set; }
[JsonProperty("followed")]
public bool Followed { get; set; }
// vip_type
// vip_statue
}
public class FavStatus : BaseModel
{
[JsonProperty("collect")]
public long Collect { get; set; }
[JsonProperty("play")]
public long Play { get; set; }
[JsonProperty("thumb_up")]
public long ThumbUp { get; set; }
[JsonProperty("share")]
public long Share { get; set; }
}
}

@ -140,6 +140,8 @@
<Compile Include="BiliApi\Cheese\Models\CheeseView.cs" />
<Compile Include="BiliApi\Danmaku\DanmakuProtobuf.cs" />
<Compile Include="BiliApi\Danmaku\Models\BiliDanmaku.cs" />
<Compile Include="BiliApi\Favorites\FavoritesInfo.cs" />
<Compile Include="BiliApi\Favorites\Models\FavoritesMetaInfo.cs" />
<Compile Include="BiliApi\Login\LoginHelper.cs" />
<Compile Include="BiliApi\Models\BaseModel.cs" />
<Compile Include="BiliApi\Login\LoginInfo.cs" />

Loading…
Cancel
Save