From 7a0f3df4fb899bef6f35fe56c912a2b022f4e2da Mon Sep 17 00:00:00 2001
From: croire <1432593898@qq.com>
Date: Thu, 21 Oct 2021 10:21:48 +0800
Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=94=B6=E8=97=8F=E5=A4=B9?=
=?UTF-8?q?=E4=BF=A1=E6=81=AFapi?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../BiliApi/Favorites/FavoritesInfo.cs | 40 ++++++++++
.../Favorites/Models/FavoritesMetaInfo.cs | 79 +++++++++++++++++++
DownKyi.Core/DownKyi.Core.csproj | 2 +
3 files changed, 121 insertions(+)
create mode 100644 DownKyi.Core/BiliApi/Favorites/FavoritesInfo.cs
create mode 100644 DownKyi.Core/BiliApi/Favorites/Models/FavoritesMetaInfo.cs
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 @@
+
+