diff --git a/DownKyi.Core/BiliApi/Favorites/FavoritesInfo.cs b/DownKyi.Core/BiliApi/Favorites/FavoritesInfo.cs new file mode 100644 index 0000000..022816f --- /dev/null +++ b/DownKyi.Core/BiliApi/Favorites/FavoritesInfo.cs @@ -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 + { + + /// + /// 获取收藏夹元数据 + /// + /// + 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(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; + } + } + + } +} diff --git a/DownKyi.Core/BiliApi/Favorites/Models/FavoritesMetaInfo.cs b/DownKyi.Core/BiliApi/Favorites/Models/FavoritesMetaInfo.cs new file mode 100644 index 0000000..04ff3ea --- /dev/null +++ b/DownKyi.Core/BiliApi/Favorites/Models/FavoritesMetaInfo.cs @@ -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; } + } + +} diff --git a/DownKyi.Core/DownKyi.Core.csproj b/DownKyi.Core/DownKyi.Core.csproj index 4a0a896..335492d 100644 --- a/DownKyi.Core/DownKyi.Core.csproj +++ b/DownKyi.Core/DownKyi.Core.csproj @@ -140,6 +140,8 @@ + +