diff --git a/DownKyi.Core/BiliApi/Cheese/CheeseInfo.cs b/DownKyi.Core/BiliApi/Cheese/CheeseInfo.cs index d09b9b2..dc14168 100644 --- a/DownKyi.Core/BiliApi/Cheese/CheeseInfo.cs +++ b/DownKyi.Core/BiliApi/Cheese/CheeseInfo.cs @@ -27,7 +27,7 @@ namespace DownKyi.Core.BiliApi.Cheese try { - var cheese = JsonConvert.DeserializeObject(response); + CheeseViewOrigin cheese = JsonConvert.DeserializeObject(response); if (cheese != null) { return cheese.Data; } else { return null; } } @@ -54,7 +54,7 @@ namespace DownKyi.Core.BiliApi.Cheese try { - var cheese = JsonConvert.DeserializeObject(response); + CheeseEpisodeListOrigin cheese = JsonConvert.DeserializeObject(response); if (cheese != null) { return cheese.Data; } else { return null; } } diff --git a/DownKyi.Core/BiliApi/Login/LoginInfo.cs b/DownKyi.Core/BiliApi/Login/LoginInfo.cs deleted file mode 100644 index 3a03586..0000000 --- a/DownKyi.Core/BiliApi/Login/LoginInfo.cs +++ /dev/null @@ -1,40 +0,0 @@ -using DownKyi.Core.BiliApi.Login.Models; -using DownKyi.Core.Logging; -using Newtonsoft.Json; -using System; - -namespace DownKyi.Core.BiliApi.Login -{ - /// - /// 登录基本信息 - /// - public static class LoginInfo - { - - /// - /// 导航栏用户信息 - /// - /// - public static UserInfoForNavigation GetUserInfoForNavigation() - { - string url = "https://api.bilibili.com/x/web-interface/nav"; - string referer = "https://www.bilibili.com"; - string response = WebClient.RequestWeb(url, referer); - - try - { - var userInfo = JsonConvert.DeserializeObject(response); - if (userInfo == null || userInfo.Data == null) { return null; } - - if (userInfo.Data.IsLogin) { return userInfo.Data; } - else { return null; } - } - catch (Exception e) - { - Utils.Debugging.Console.PrintLine("GetUserInfoForNavigation()发生异常: {0}", e); - LogManager.Error("LoginInfo", e); - return null; - } - } - } -} diff --git a/DownKyi.Core/BiliApi/Users/Models/BangumiFollow.cs b/DownKyi.Core/BiliApi/Users/Models/BangumiFollow.cs new file mode 100644 index 0000000..81d9b57 --- /dev/null +++ b/DownKyi.Core/BiliApi/Users/Models/BangumiFollow.cs @@ -0,0 +1,76 @@ +using DownKyi.Core.BiliApi.Models; +using Newtonsoft.Json; +using System.Collections.Generic; + +namespace DownKyi.Core.BiliApi.Users.Models +{ + public class BangumiFollow : BaseModel + { + [JsonProperty("season_id")] + public long SeasonId { get; set; } + [JsonProperty("media_id")] + public long MediaId { get; set; } + [JsonProperty("season_type")] + public int SeasonType { get; set; } + [JsonProperty("season_type_name")] + public string SeasonTypeName { get; set; } + [JsonProperty("title")] + public string Title { get; set; } + [JsonProperty("cover")] + public string Cover { get; set; } + [JsonProperty("total_count")] + public int TotalCount { get; set; } + // is_finish + // is_started + // is_play + [JsonProperty("badge")] + public string Badge { get; set; } + [JsonProperty("badge_type")] + public int BadgeType { get; set; } + // rights + // stat + [JsonProperty("new_ep")] + public BangumiFollowNewEp NewEp { get; set; } + // rating + // square_cover + [JsonProperty("season_status")] + public int SeasonStatus { get; set; } + [JsonProperty("season_title")] + public string SeasonTitle { get; set; } + [JsonProperty("badge_ep")] + public string BadgeEp { get; set; } + // media_attr + // season_attr + [JsonProperty("evaluate")] + public string Evaluate { get; set; } + [JsonProperty("areas")] + public List Areas { get; set; } + [JsonProperty("subtitle")] + public string Subtitle { get; set; } + [JsonProperty("first_ep")] + public long FirstEp { get; set; } + // can_watch + // series + // publish + // mode + // section + [JsonProperty("url")] + public string Url { get; set; } + // badge_info + // first_ep_info + // formal_ep_count + // short_url + // badge_infos + // season_version + // horizontal_cover_16_9 + // horizontal_cover_16_10 + // subtitle_14 + // viewable_crowd_type + // producers + // follow_status + // is_new + [JsonProperty("progress")] + public string Progress { get; set; } + // both_follow + } +} diff --git a/DownKyi.Core/BiliApi/Users/Models/BangumiFollowAreas.cs b/DownKyi.Core/BiliApi/Users/Models/BangumiFollowAreas.cs new file mode 100644 index 0000000..56b7135 --- /dev/null +++ b/DownKyi.Core/BiliApi/Users/Models/BangumiFollowAreas.cs @@ -0,0 +1,13 @@ +using DownKyi.Core.BiliApi.Models; +using Newtonsoft.Json; + +namespace DownKyi.Core.BiliApi.Users.Models +{ + public class BangumiFollowAreas : BaseModel + { + [JsonProperty("id")] + public int Id { get; set; } + [JsonProperty("name")] + public string Name { get; set; } + } +} diff --git a/DownKyi.Core/BiliApi/Users/Models/BangumiFollowNewEp.cs b/DownKyi.Core/BiliApi/Users/Models/BangumiFollowNewEp.cs new file mode 100644 index 0000000..a3d9060 --- /dev/null +++ b/DownKyi.Core/BiliApi/Users/Models/BangumiFollowNewEp.cs @@ -0,0 +1,23 @@ +using DownKyi.Core.BiliApi.Models; +using Newtonsoft.Json; + +namespace DownKyi.Core.BiliApi.Users.Models +{ + public class BangumiFollowNewEp : BaseModel + { + [JsonProperty("id")] + public long Id { get; set; } + [JsonProperty("index_show")] + public string IndexShow { get; set; } + [JsonProperty("cover")] + public string Cover { get; set; } + [JsonProperty("title")] + public string Title { get; set; } + [JsonProperty("long_title")] + public string LongTitle { get; set; } + [JsonProperty("pub_time")] + public string PubTime { get; set; } + [JsonProperty("duration")] + public long Duration { get; set; } + } +} diff --git a/DownKyi.Core/BiliApi/Users/Models/BangumiFollowOrigin.cs b/DownKyi.Core/BiliApi/Users/Models/BangumiFollowOrigin.cs new file mode 100644 index 0000000..8690651 --- /dev/null +++ b/DownKyi.Core/BiliApi/Users/Models/BangumiFollowOrigin.cs @@ -0,0 +1,26 @@ +using DownKyi.Core.BiliApi.Models; +using Newtonsoft.Json; +using System.Collections.Generic; + +namespace DownKyi.Core.BiliApi.Users.Models +{ + // https://api.bilibili.com/x/space/bangumi/follow/list?vmid={mid}&type={type:D}&pn={pn}&ps={ps} + public class BangumiFollowOrigin : BaseModel + { + [JsonProperty("data")] + public BangumiFollowData Data { get; set; } + } + + public class BangumiFollowData : BaseModel + { + [JsonProperty("list")] + public List List { get; set; } + [JsonProperty("pn")] + public int Pn { get; set; } + [JsonProperty("ps")] + public int Ps { get; set; } + [JsonProperty("total")] + public int Total { get; set; } + } + +} diff --git a/DownKyi.Core/BiliApi/Users/Models/BangumiType.cs b/DownKyi.Core/BiliApi/Users/Models/BangumiType.cs new file mode 100644 index 0000000..a8480e5 --- /dev/null +++ b/DownKyi.Core/BiliApi/Users/Models/BangumiType.cs @@ -0,0 +1,8 @@ +namespace DownKyi.Core.BiliApi.Users.Models +{ + public enum BangumiType + { + ANIME = 1, // 番剧 + EPISODE = 2 // 剧集、电影 + } +} diff --git a/DownKyi.Core/BiliApi/Users/Models/FollowingGroup.cs b/DownKyi.Core/BiliApi/Users/Models/FollowingGroup.cs new file mode 100644 index 0000000..22267b3 --- /dev/null +++ b/DownKyi.Core/BiliApi/Users/Models/FollowingGroup.cs @@ -0,0 +1,26 @@ +using DownKyi.Core.BiliApi.Models; +using Newtonsoft.Json; +using System.Collections.Generic; + +namespace DownKyi.Core.BiliApi.Users.Models +{ + // https://api.bilibili.com/x/relation/tags + public class FollowingGroupOrigin : BaseModel + { + [JsonProperty("data")] + public List Data { get; set; } + } + + public class FollowingGroup : BaseModel + { + [JsonProperty("tagid")] + public int TagId { get; set; } + [JsonProperty("name")] + public string Name { get; set; } + [JsonProperty("count")] + public int Count { get; set; } + [JsonProperty("tip")] + public string Tip { get; set; } + } + +} diff --git a/DownKyi.Core/BiliApi/Users/Models/FollowingGroupContent.cs b/DownKyi.Core/BiliApi/Users/Models/FollowingGroupContent.cs new file mode 100644 index 0000000..7f1597f --- /dev/null +++ b/DownKyi.Core/BiliApi/Users/Models/FollowingGroupContent.cs @@ -0,0 +1,14 @@ +using DownKyi.Core.BiliApi.Models; +using Newtonsoft.Json; +using System.Collections.Generic; + +namespace DownKyi.Core.BiliApi.Users.Models +{ + // https://api.bilibili.com/x/relation/tag?tagid={tagId}&pn={pn}&ps={ps}&order_type={orderType} + public class FollowingGroupContent : BaseModel + { + [JsonProperty("data")] + public List Data { get; set; } + } + +} diff --git a/DownKyi.Core/BiliApi/Users/Models/FollowingOrder.cs b/DownKyi.Core/BiliApi/Users/Models/FollowingOrder.cs new file mode 100644 index 0000000..a480070 --- /dev/null +++ b/DownKyi.Core/BiliApi/Users/Models/FollowingOrder.cs @@ -0,0 +1,8 @@ +namespace DownKyi.Core.BiliApi.Users.Models +{ + public enum FollowingOrder + { + DEFAULT = 1, // 按照关注顺序排列,默认 + ATTENTION // 按照最常访问排列 + } +} diff --git a/DownKyi.Core/BiliApi/Users/Models/MyInfo.cs b/DownKyi.Core/BiliApi/Users/Models/MyInfo.cs new file mode 100644 index 0000000..0141dcf --- /dev/null +++ b/DownKyi.Core/BiliApi/Users/Models/MyInfo.cs @@ -0,0 +1,75 @@ +using DownKyi.Core.BiliApi.Models; +using Newtonsoft.Json; + +namespace DownKyi.Core.BiliApi.Users.Models +{ + // https://api.bilibili.com/x/space/myinfo + public class MyInfoOrigin : 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 MyInfo Data { get; set; } + } + + public class MyInfo : BaseModel + { + [JsonProperty("mid")] + public long Mid { get; set; } + [JsonProperty("name")] + public string Name { get; set; } + [JsonProperty("sex")] + public string Sex { get; set; } + [JsonProperty("face")] + public string Face { get; set; } + [JsonProperty("sign")] + public string Sign { get; set; } + // rank + [JsonProperty("level")] + public int Level { get; set; } + // jointime + [JsonProperty("moral")] + public int Moral { get; set; } + [JsonProperty("silence")] + public int Silence { get; set; } + [JsonProperty("email_status")] + public int EmailStatus { get; set; } + [JsonProperty("tel_status")] + public int TelStatus { get; set; } + [JsonProperty("identification")] + public int Identification { get; set; } + [JsonProperty("vip")] + public UserInfoVip Vip { get; set; } + // pendant + // nameplate + // official + [JsonProperty("birthday")] + public long Birthday { get; set; } + [JsonProperty("is_tourist")] + public int IsTourist { get; set; } + [JsonProperty("is_fake_account")] + public int IsFakeAccount { get; set; } + [JsonProperty("pin_prompting")] + public int PinPrompting { get; set; } + [JsonProperty("is_deleted")] + public int IsDeleted { get; set; } + // in_reg_audit + // is_rip_user + // profession + // face_nft + // face_nft_new + // is_senior_member + [JsonProperty("level_exp")] + public UserInfoLevelExp LevelExp { get; set; } + [JsonProperty("coins")] + public float Coins { get; set; } + [JsonProperty("following")] + public int Following { get; set; } + [JsonProperty("follower")] + public int Follower { get; set; } + } +} diff --git a/DownKyi.Core/BiliApi/Users/Models/NicknameStatus.cs b/DownKyi.Core/BiliApi/Users/Models/NicknameStatus.cs new file mode 100644 index 0000000..3257b56 --- /dev/null +++ b/DownKyi.Core/BiliApi/Users/Models/NicknameStatus.cs @@ -0,0 +1,14 @@ +using DownKyi.Core.BiliApi.Models; +using Newtonsoft.Json; + +namespace DownKyi.Core.BiliApi.Users.Models +{ + // https://api.bilibili.com/x/relation/stat?nickName={nickName} + public class NicknameStatus : BaseModel + { + [JsonProperty("code")] + public int Code { get; set; } + [JsonProperty("message")] + public string Message { get; set; } + } +} diff --git a/DownKyi.Core/BiliApi/Users/Models/PublicationOrder.cs b/DownKyi.Core/BiliApi/Users/Models/PublicationOrder.cs new file mode 100644 index 0000000..380fa87 --- /dev/null +++ b/DownKyi.Core/BiliApi/Users/Models/PublicationOrder.cs @@ -0,0 +1,9 @@ +namespace DownKyi.Core.BiliApi.Users.Models +{ + public enum PublicationOrder + { + PUBDATE = 1, // 最新发布,默认 + CLICK, // 最多播放 + STOW // 最多收藏 + } +} diff --git a/DownKyi.Core/BiliApi/Users/Models/RelationBlack.cs b/DownKyi.Core/BiliApi/Users/Models/RelationBlack.cs new file mode 100644 index 0000000..95205cc --- /dev/null +++ b/DownKyi.Core/BiliApi/Users/Models/RelationBlack.cs @@ -0,0 +1,13 @@ +using DownKyi.Core.BiliApi.Models; +using Newtonsoft.Json; +using System.Collections.Generic; + +namespace DownKyi.Core.BiliApi.Users.Models +{ + // https://api.bilibili.com/x/relation/blacks?pn={pn}&ps={ps} + public class RelationBlack : BaseModel + { + [JsonProperty("data")] + public List Data { get; set; } + } +} diff --git a/DownKyi.Core/BiliApi/Users/Models/RelationFollow.cs b/DownKyi.Core/BiliApi/Users/Models/RelationFollow.cs new file mode 100644 index 0000000..4911ffc --- /dev/null +++ b/DownKyi.Core/BiliApi/Users/Models/RelationFollow.cs @@ -0,0 +1,25 @@ +using DownKyi.Core.BiliApi.Models; +using Newtonsoft.Json; +using System.Collections.Generic; + +namespace DownKyi.Core.BiliApi.Users.Models +{ + // https://api.bilibili.com/x/relation/followers?vmid={mid}&pn={pn}&ps={ps} + // https://api.bilibili.com/x/relation/followings?vmid={mid}&pn={pn}&ps={ps}&order_type={orderType} + public class RelationFollowOrigin : BaseModel + { + [JsonProperty("data")] + public RelationFollow Data { get; set; } + } + + public class RelationFollow : BaseModel + { + [JsonProperty("list")] + public List List { get; set; } + //[JsonProperty("re_version")] + //public long reVersion { get; set; } + [JsonProperty("total")] + public int Total { get; set; } + } + +} diff --git a/DownKyi.Core/BiliApi/Users/Models/RelationFollowInfo.cs b/DownKyi.Core/BiliApi/Users/Models/RelationFollowInfo.cs new file mode 100644 index 0000000..0548df8 --- /dev/null +++ b/DownKyi.Core/BiliApi/Users/Models/RelationFollowInfo.cs @@ -0,0 +1,29 @@ +using DownKyi.Core.BiliApi.Models; +using Newtonsoft.Json; +using System.Collections.Generic; + +namespace DownKyi.Core.BiliApi.Users.Models +{ + public class RelationFollowInfo : BaseModel + { + [JsonProperty("mid")] + public long Mid { get; set; } + [JsonProperty("attribute")] + public int Attribute { get; set; } + [JsonProperty("mtime")] + public long Mtime { get; set; } + [JsonProperty("tag")] + public List Tag { get; set; } + [JsonProperty("special")] + public int Special { get; set; } + // contract_info + [JsonProperty("uname")] + public string Name { get; set; } + [JsonProperty("face")] + public string Face { get; set; } + [JsonProperty("sign")] + public string Sign { get; set; } + // official_verify + // vip + } +} diff --git a/DownKyi.Core/BiliApi/Users/Models/RelationWhisper.cs b/DownKyi.Core/BiliApi/Users/Models/RelationWhisper.cs new file mode 100644 index 0000000..19e1b4d --- /dev/null +++ b/DownKyi.Core/BiliApi/Users/Models/RelationWhisper.cs @@ -0,0 +1,14 @@ +using DownKyi.Core.BiliApi.Models; +using Newtonsoft.Json; +using System.Collections.Generic; + +namespace DownKyi.Core.BiliApi.Users.Models +{ + // https://api.bilibili.com/x/relation/whispers?pn={pn}&ps={ps} + public class RelationWhisper : BaseModel + { + [JsonProperty("data")] + public List Data { get; set; } + } + +} diff --git a/DownKyi.Core/BiliApi/Users/Models/SpaceChannel.cs b/DownKyi.Core/BiliApi/Users/Models/SpaceChannel.cs new file mode 100644 index 0000000..6e7f635 --- /dev/null +++ b/DownKyi.Core/BiliApi/Users/Models/SpaceChannel.cs @@ -0,0 +1,21 @@ +using DownKyi.Core.BiliApi.Models; +using Newtonsoft.Json; +using System.Collections.Generic; + +namespace DownKyi.Core.BiliApi.Users.Models +{ + // https://api.bilibili.com/x/space/channel/list?mid={mid} + public class SpaceChannelOrigin : BaseModel + { + [JsonProperty("data")] + public SpaceChannel Data { get; set; } + } + + public class SpaceChannel : BaseModel + { + [JsonProperty("count")] + public int Count { get; set; } + [JsonProperty("list")] + public List List { get; set; } + } +} diff --git a/DownKyi.Core/BiliApi/Users/Models/SpaceChannelArchive.cs b/DownKyi.Core/BiliApi/Users/Models/SpaceChannelArchive.cs new file mode 100644 index 0000000..8a4a068 --- /dev/null +++ b/DownKyi.Core/BiliApi/Users/Models/SpaceChannelArchive.cs @@ -0,0 +1,47 @@ +using DownKyi.Core.BiliApi.Models; +using Newtonsoft.Json; + +namespace DownKyi.Core.BiliApi.Users.Models +{ + public class SpaceChannelArchive : BaseModel + { + [JsonProperty("aid")] + public long Aid { get; set; } + // videos + [JsonProperty("tid")] + public int Tid { get; set; } + [JsonProperty("tname")] + public string Tname { get; set; } + // copyright + [JsonProperty("pic")] + public string Pic { get; set; } + [JsonProperty("title")] + public string Title { get; set; } + [JsonProperty("pubdate")] + public long Pubdate { get; set; } + [JsonProperty("ctime")] + public long Ctime { get; set; } + [JsonProperty("desc")] + public string Desc { get; set; } + // state + [JsonProperty("duration")] + public long Duration { get; set; } + // mission_id + // rights + [JsonProperty("owner")] + public VideoOwner Owner { get; set; } + [JsonProperty("stat")] + public SpaceChannelArchiveStat Stat { get; set; } + // dynamic + [JsonProperty("cid")] + public long Cid { get; set; } + [JsonProperty("dimension")] + public Dimension Dimension { get; set; } + // season_id + // short_link_v2 + [JsonProperty("bvid")] + public string Bvid { get; set; } + // inter_video + // is_live_playback + } +} diff --git a/DownKyi.Core/BiliApi/Users/Models/SpaceChannelArchiveStat.cs b/DownKyi.Core/BiliApi/Users/Models/SpaceChannelArchiveStat.cs new file mode 100644 index 0000000..6845276 --- /dev/null +++ b/DownKyi.Core/BiliApi/Users/Models/SpaceChannelArchiveStat.cs @@ -0,0 +1,31 @@ +using DownKyi.Core.BiliApi.Models; +using Newtonsoft.Json; + +namespace DownKyi.Core.BiliApi.Users.Models +{ + public class SpaceChannelArchiveStat : BaseModel + { + [JsonProperty("aid")] + public long Aid { get; set; } + [JsonProperty("view")] + public long View { get; set; } + [JsonProperty("danmaku")] + public long Danmaku { get; set; } + [JsonProperty("reply")] + public long Reply { get; set; } + [JsonProperty("favorite")] + public long Favorite { get; set; } + [JsonProperty("coin")] + public long Coin { get; set; } + [JsonProperty("share")] + public long Share { get; set; } + [JsonProperty("now_rank")] + public long NowRank { get; set; } + [JsonProperty("his_rank")] + public long HisRank { get; set; } + [JsonProperty("like")] + public long Like { get; set; } + [JsonProperty("dislike")] + public long Dislike { get; set; } + } +} diff --git a/DownKyi.Core/BiliApi/Users/Models/SpaceChannelList.cs b/DownKyi.Core/BiliApi/Users/Models/SpaceChannelList.cs new file mode 100644 index 0000000..d2164f1 --- /dev/null +++ b/DownKyi.Core/BiliApi/Users/Models/SpaceChannelList.cs @@ -0,0 +1,24 @@ +using DownKyi.Core.BiliApi.Models; +using Newtonsoft.Json; + +namespace DownKyi.Core.BiliApi.Users.Models +{ + public class SpaceChannelList : BaseModel + { + [JsonProperty("cid")] + public long Cid { get; set; } + [JsonProperty("mid")] + public long Mid { get; set; } + [JsonProperty("name")] + public string Name { get; set; } + [JsonProperty("intro")] + public string Intro { get; set; } + [JsonProperty("mtime")] + public long Mtime { get; set; } + [JsonProperty("count")] + public int Count { get; set; } + [JsonProperty("cover")] + public string Cover { get; set; } + // is_live_playback + } +} diff --git a/DownKyi.Core/BiliApi/Users/Models/SpaceChannelVideo.cs b/DownKyi.Core/BiliApi/Users/Models/SpaceChannelVideo.cs new file mode 100644 index 0000000..9c27763 --- /dev/null +++ b/DownKyi.Core/BiliApi/Users/Models/SpaceChannelVideo.cs @@ -0,0 +1,21 @@ +using DownKyi.Core.BiliApi.Models; +using Newtonsoft.Json; + +namespace DownKyi.Core.BiliApi.Users.Models +{ + // https://api.bilibili.com/x/space/channel/video?mid={mid}&cid={cid}&pn={pn}&ps={ps} + public class SpaceChannelVideoOrigin : BaseModel + { + [JsonProperty("data")] + public SpaceChannelVideo Data { get; set; } + } + + public class SpaceChannelVideo : BaseModel + { + // episodic_button + [JsonProperty("list")] + public SpaceChannelVideoList List { get; set; } + [JsonProperty("page")] + public SpaceChannelVideoPage Page { get; set; } + } +} diff --git a/DownKyi.Core/BiliApi/Users/Models/SpaceChannelVideoList.cs b/DownKyi.Core/BiliApi/Users/Models/SpaceChannelVideoList.cs new file mode 100644 index 0000000..fed996b --- /dev/null +++ b/DownKyi.Core/BiliApi/Users/Models/SpaceChannelVideoList.cs @@ -0,0 +1,27 @@ +using DownKyi.Core.BiliApi.Models; +using Newtonsoft.Json; +using System.Collections.Generic; + +namespace DownKyi.Core.BiliApi.Users.Models +{ + public class SpaceChannelVideoList : BaseModel + { + [JsonProperty("cid")] + public long Cid { get; set; } + [JsonProperty("mid")] + public long Mid { get; set; } + [JsonProperty("name")] + public string Name { get; set; } + [JsonProperty("intro")] + public string Intro { get; set; } + [JsonProperty("mtime")] + public long Mtime { get; set; } + [JsonProperty("count")] + public int Count { get; set; } + [JsonProperty("cover")] + public string Cover { get; set; } + // is_live_playback + [JsonProperty("archives")] + public List Archives { get; set; } + } +} diff --git a/DownKyi.Core/BiliApi/Users/Models/SpaceChannelVideoPage.cs b/DownKyi.Core/BiliApi/Users/Models/SpaceChannelVideoPage.cs new file mode 100644 index 0000000..5bcd872 --- /dev/null +++ b/DownKyi.Core/BiliApi/Users/Models/SpaceChannelVideoPage.cs @@ -0,0 +1,15 @@ +using DownKyi.Core.BiliApi.Models; +using Newtonsoft.Json; + +namespace DownKyi.Core.BiliApi.Users.Models +{ + public class SpaceChannelVideoPage : BaseModel + { + [JsonProperty("count")] + public int Count { get; set; } + [JsonProperty("num")] + public int Num { get; set; } + [JsonProperty("size")] + public int Size { get; set; } + } +} diff --git a/DownKyi.Core/BiliApi/Users/Models/SpaceCheese.cs b/DownKyi.Core/BiliApi/Users/Models/SpaceCheese.cs new file mode 100644 index 0000000..9d0b5d0 --- /dev/null +++ b/DownKyi.Core/BiliApi/Users/Models/SpaceCheese.cs @@ -0,0 +1,27 @@ +using DownKyi.Core.BiliApi.Models; +using Newtonsoft.Json; + +namespace DownKyi.Core.BiliApi.Users.Models +{ + public class SpaceCheese : BaseModel + { + [JsonProperty("cover")] + public string Cover { get; set; } + [JsonProperty("ep_count")] + public int EpCount { get; set; } + [JsonProperty("link")] + public string Link { get; set; } + [JsonProperty("page")] + public int Page { get; set; } + [JsonProperty("play")] + public int Play { get; set; } + [JsonProperty("season_id")] + public long SeasonId { get; set; } + [JsonProperty("status")] + public string Status { get; set; } + [JsonProperty("subtitle")] + public string SubTitle { get; set; } + [JsonProperty("title")] + public string Title { get; set; } + } +} diff --git a/DownKyi.Core/BiliApi/Users/Models/SpaceCheeseOrigin.cs b/DownKyi.Core/BiliApi/Users/Models/SpaceCheeseOrigin.cs new file mode 100644 index 0000000..36c2ef1 --- /dev/null +++ b/DownKyi.Core/BiliApi/Users/Models/SpaceCheeseOrigin.cs @@ -0,0 +1,21 @@ +using DownKyi.Core.BiliApi.Models; +using Newtonsoft.Json; +using System.Collections.Generic; + +namespace DownKyi.Core.BiliApi.Users.Models +{ + // https://api.bilibili.com/pugv/app/web/season/page?mid={mid}&pn={pn}&ps={ps} + public class SpaceCheeseOrigin : BaseModel + { + [JsonProperty("data")] + public SpaceCheeseData Data { get; set; } + } + + public class SpaceCheeseData : BaseModel + { + [JsonProperty("items")] + public List Items { get; set; } + [JsonProperty("page")] + public SpaceCheesePage Page { get; set; } + } +} diff --git a/DownKyi.Core/BiliApi/Users/Models/SpaceCheesePage.cs b/DownKyi.Core/BiliApi/Users/Models/SpaceCheesePage.cs new file mode 100644 index 0000000..8ad28d5 --- /dev/null +++ b/DownKyi.Core/BiliApi/Users/Models/SpaceCheesePage.cs @@ -0,0 +1,17 @@ +using DownKyi.Core.BiliApi.Models; +using Newtonsoft.Json; + +namespace DownKyi.Core.BiliApi.Users.Models +{ + public class SpaceCheesePage : BaseModel + { + [JsonProperty("next")] + public bool Next { get; set; } + [JsonProperty("num")] + public int Num { get; set; } + [JsonProperty("size")] + public int Size { get; set; } + [JsonProperty("total")] + public int Total { get; set; } + } +} diff --git a/DownKyi.Core/BiliApi/Users/Models/SpacePublication.cs b/DownKyi.Core/BiliApi/Users/Models/SpacePublication.cs new file mode 100644 index 0000000..23f007b --- /dev/null +++ b/DownKyi.Core/BiliApi/Users/Models/SpacePublication.cs @@ -0,0 +1,21 @@ +using DownKyi.Core.BiliApi.Models; +using Newtonsoft.Json; + +namespace DownKyi.Core.BiliApi.Users.Models +{ + // https://api.bilibili.com/x/space/arc/search + public class SpacePublicationOrigin : BaseModel + { + [JsonProperty("data")] + public SpacePublication Data { get; set; } + } + + public class SpacePublication : BaseModel + { + [JsonProperty("list")] + public SpacePublicationList List { get; set; } + [JsonProperty("page")] + public SpacePublicationPage Page { get; set; } + } + +} diff --git a/DownKyi.Core/BiliApi/Users/Models/SpacePublicationList.cs b/DownKyi.Core/BiliApi/Users/Models/SpacePublicationList.cs new file mode 100644 index 0000000..7bf26b8 --- /dev/null +++ b/DownKyi.Core/BiliApi/Users/Models/SpacePublicationList.cs @@ -0,0 +1,14 @@ +using DownKyi.Core.BiliApi.Models; +using Newtonsoft.Json; +using System.Collections.Generic; + +namespace DownKyi.Core.BiliApi.Users.Models +{ + public class SpacePublicationList : BaseModel + { + [JsonProperty("tlist")] + public SpacePublicationListType Tlist { get; set; } + [JsonProperty("vlist")] + public List Vlist { get; set; } + } +} diff --git a/DownKyi.Core/BiliApi/Users/Models/SpacePublicationListType.cs b/DownKyi.Core/BiliApi/Users/Models/SpacePublicationListType.cs new file mode 100644 index 0000000..6e88c75 --- /dev/null +++ b/DownKyi.Core/BiliApi/Users/Models/SpacePublicationListType.cs @@ -0,0 +1,51 @@ +using DownKyi.Core.BiliApi.Models; +using Newtonsoft.Json; + +namespace DownKyi.Core.BiliApi.Users.Models +{ + public class SpacePublicationListType : BaseModel + { + [JsonProperty("1")] + public SpacePublicationListTypeVideoZone Douga { get; set; } + [JsonProperty("13")] + public SpacePublicationListTypeVideoZone Anime { get; set; } + [JsonProperty("167")] + public SpacePublicationListTypeVideoZone Guochuang { get; set; } + [JsonProperty("3")] + public SpacePublicationListTypeVideoZone Music { get; set; } + [JsonProperty("129")] + public SpacePublicationListTypeVideoZone Dance { get; set; } + [JsonProperty("4")] + public SpacePublicationListTypeVideoZone Game { get; set; } + [JsonProperty("36")] + public SpacePublicationListTypeVideoZone Technology { get; set; } + [JsonProperty("188")] + public SpacePublicationListTypeVideoZone Digital { get; set; } + [JsonProperty("224")] + public SpacePublicationListTypeVideoZone Sports { get; set; } + [JsonProperty("223")] + public SpacePublicationListTypeVideoZone Car { get; set; } + [JsonProperty("160")] + public SpacePublicationListTypeVideoZone Life { get; set; } + [JsonProperty("211")] + public SpacePublicationListTypeVideoZone Food { get; set; } + [JsonProperty("217")] + public SpacePublicationListTypeVideoZone Animal { get; set; } + [JsonProperty("119")] + public SpacePublicationListTypeVideoZone Kichiku { get; set; } + [JsonProperty("155")] + public SpacePublicationListTypeVideoZone Fashion { get; set; } + [JsonProperty("202")] + public SpacePublicationListTypeVideoZone Information { get; set; } + [JsonProperty("5")] + public SpacePublicationListTypeVideoZone Ent { get; set; } + [JsonProperty("181")] + public SpacePublicationListTypeVideoZone Cinephile { get; set; } + [JsonProperty("177")] + public SpacePublicationListTypeVideoZone Documentary { get; set; } + [JsonProperty("23")] + public SpacePublicationListTypeVideoZone Movie { get; set; } + [JsonProperty("11")] + public SpacePublicationListTypeVideoZone Tv { get; set; } + } +} diff --git a/DownKyi.Core/BiliApi/Users/Models/SpacePublicationListTypeVideoZone.cs b/DownKyi.Core/BiliApi/Users/Models/SpacePublicationListTypeVideoZone.cs new file mode 100644 index 0000000..2349c3a --- /dev/null +++ b/DownKyi.Core/BiliApi/Users/Models/SpacePublicationListTypeVideoZone.cs @@ -0,0 +1,15 @@ +using DownKyi.Core.BiliApi.Models; +using Newtonsoft.Json; + +namespace DownKyi.Core.BiliApi.Users.Models +{ + public class SpacePublicationListTypeVideoZone : BaseModel + { + [JsonProperty("tid")] + public int Tid { get; set; } + [JsonProperty("count")] + public int Count { get; set; } + [JsonProperty("name")] + public string Name { get; set; } + } +} diff --git a/DownKyi.Core/BiliApi/Users/Models/SpacePublicationListVideo.cs b/DownKyi.Core/BiliApi/Users/Models/SpacePublicationListVideo.cs new file mode 100644 index 0000000..d5b91f7 --- /dev/null +++ b/DownKyi.Core/BiliApi/Users/Models/SpacePublicationListVideo.cs @@ -0,0 +1,51 @@ +using DownKyi.Core.BiliApi.Models; +using Newtonsoft.Json; + +namespace DownKyi.Core.BiliApi.Users.Models +{ + public class SpacePublicationListVideo : BaseModel + { + //[JsonProperty("comment")] + //public int Comment { get; set; } + [JsonProperty("typeid")] + public int Typeid { get; set; } + [JsonProperty("play")] + public int Play { get; set; } + [JsonProperty("pic")] + public string Pic { get; set; } + //[JsonProperty("subtitle")] + //public string Subtitle { get; set; } + //[JsonProperty("description")] + //public string Description { get; set; } + //[JsonProperty("copyright")] + //public string Copyright { get; set; } + [JsonProperty("title")] + public string Title { get; set; } + //[JsonProperty("review")] + //public int Review { get; set; } + //[JsonProperty("author")] + //public string Author { get; set; } + [JsonProperty("mid")] + public long Mid { get; set; } + [JsonProperty("created")] + public long Created { get; set; } + [JsonProperty("length")] + public string Length { get; set; } + //[JsonProperty("video_review")] + //public int VideoReview { get; set; } + [JsonProperty("aid")] + public long Aid { get; set; } + [JsonProperty("bvid")] + public string Bvid { get; set; } + //[JsonProperty("hide_click")] + //public bool HideClick { get; set; } + //[JsonProperty("is_pay")] + //public int IsPay { get; set; } + //[JsonProperty("is_union_video")] + //public int IsUnionVideo { get; set; } + //[JsonProperty("is_steins_gate")] + //public int IsSteinsGate { get; set; } + //[JsonProperty("is_live_playback")] + //public int IsLivePlayback { get; set; } + } +} diff --git a/DownKyi.Core/BiliApi/Users/Models/SpacePublicationPage.cs b/DownKyi.Core/BiliApi/Users/Models/SpacePublicationPage.cs new file mode 100644 index 0000000..0b94e73 --- /dev/null +++ b/DownKyi.Core/BiliApi/Users/Models/SpacePublicationPage.cs @@ -0,0 +1,15 @@ +using DownKyi.Core.BiliApi.Models; +using Newtonsoft.Json; + +namespace DownKyi.Core.BiliApi.Users.Models +{ + public class SpacePublicationPage : BaseModel + { + [JsonProperty("pn")] + public int Pn { get; set; } + [JsonProperty("ps")] + public int Ps { get; set; } + [JsonProperty("count")] + public int Count { get; set; } + } +} diff --git a/DownKyi.Core/BiliApi/Users/Models/SpaceSettings.cs b/DownKyi.Core/BiliApi/Users/Models/SpaceSettings.cs new file mode 100644 index 0000000..b3fc6af --- /dev/null +++ b/DownKyi.Core/BiliApi/Users/Models/SpaceSettings.cs @@ -0,0 +1,21 @@ +using DownKyi.Core.BiliApi.Models; +using Newtonsoft.Json; + +namespace DownKyi.Core.BiliApi.Users.Models +{ + // https://space.bilibili.com/ajax/settings/getSettings?mid={mid} + public class SpaceSettingsOrigin : BaseModel + { + [JsonProperty("status")] + public bool Status { get; set; } + [JsonProperty("data")] + public SpaceSettings Data { get; set; } + } + + public class SpaceSettings : BaseModel + { + // ... + [JsonProperty("toutu")] + public SpaceSettingsToutu Toutu { get; set; } + } +} diff --git a/DownKyi.Core/BiliApi/Users/Models/SpaceSettingsToutu.cs b/DownKyi.Core/BiliApi/Users/Models/SpaceSettingsToutu.cs new file mode 100644 index 0000000..a89c583 --- /dev/null +++ b/DownKyi.Core/BiliApi/Users/Models/SpaceSettingsToutu.cs @@ -0,0 +1,27 @@ +using DownKyi.Core.BiliApi.Models; +using Newtonsoft.Json; + +namespace DownKyi.Core.BiliApi.Users.Models +{ + public class SpaceSettingsToutu : BaseModel + { + [JsonProperty("sid")] + public int Sid { get; set; } + [JsonProperty("expire")] + public long Expire { get; set; } + [JsonProperty("s_img")] + public string Simg { get; set; } // 完整url为http://i0.hdslb.com/+相对路径 + [JsonProperty("l_img")] + public string Limg { get; set; } // 完整url为http://i0.hdslb.com/+相对路径 + [JsonProperty("android_img")] + public string AndroidImg { get; set; } + [JsonProperty("iphone_img")] + public string IphoneImg { get; set; } + [JsonProperty("ipad_img")] + public string IpadImg { get; set; } + [JsonProperty("thumbnail_img")] + public string ThumbnailImg { get; set; } + [JsonProperty("platform")] + public int Platform { get; set; } + } +} diff --git a/DownKyi.Core/BiliApi/Users/Models/UpStat.cs b/DownKyi.Core/BiliApi/Users/Models/UpStat.cs new file mode 100644 index 0000000..6cb1d28 --- /dev/null +++ b/DownKyi.Core/BiliApi/Users/Models/UpStat.cs @@ -0,0 +1,28 @@ +using DownKyi.Core.BiliApi.Models; +using Newtonsoft.Json; + +namespace DownKyi.Core.BiliApi.Users.Models +{ + // https://api.bilibili.com/x/space/upstat?mid={mid} + public class UpStatOrigin : BaseModel + { + [JsonProperty("data")] + public UpStat Data { get; set; } + } + + public class UpStat : BaseModel + { + [JsonProperty("archive")] + public UpStatArchive Archive { get; set; } + [JsonProperty("article")] + public UpStatArchive Article { get; set; } + [JsonProperty("likes")] + public long Likes { get; set; } + } + + public class UpStatArchive : BaseModel + { + [JsonProperty("view")] + public long View { get; set; } // 视频/文章播放量 + } +} diff --git a/DownKyi.Core/BiliApi/Login/Models/UserInfoForNavigation.cs b/DownKyi.Core/BiliApi/Users/Models/UserInfoForNavigation.cs similarity index 98% rename from DownKyi.Core/BiliApi/Login/Models/UserInfoForNavigation.cs rename to DownKyi.Core/BiliApi/Users/Models/UserInfoForNavigation.cs index 42eedf5..0801dd3 100644 --- a/DownKyi.Core/BiliApi/Login/Models/UserInfoForNavigation.cs +++ b/DownKyi.Core/BiliApi/Users/Models/UserInfoForNavigation.cs @@ -1,7 +1,7 @@ using DownKyi.Core.BiliApi.Models; using Newtonsoft.Json; -namespace DownKyi.Core.BiliApi.Login.Models +namespace DownKyi.Core.BiliApi.Users.Models { // https://api.bilibili.com/x/web-interface/nav [JsonObject] diff --git a/DownKyi.Core/BiliApi/Users/Models/UserInfoForSpace.cs b/DownKyi.Core/BiliApi/Users/Models/UserInfoForSpace.cs new file mode 100644 index 0000000..4545d56 --- /dev/null +++ b/DownKyi.Core/BiliApi/Users/Models/UserInfoForSpace.cs @@ -0,0 +1,55 @@ +using DownKyi.Core.BiliApi.Models; +using Newtonsoft.Json; + +namespace DownKyi.Core.BiliApi.Users.Models +{ + // https://api.bilibili.com/x/space/acc/info?mid={mid} + public class UserInfoForSpaceOrigin : 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 UserInfoForSpace Data { get; set; } + } + + public class UserInfoForSpace : BaseModel + { + [JsonProperty("mid")] + public long Mid { get; set; } + [JsonProperty("name")] + public string Name { get; set; } + [JsonProperty("sex")] + public string Sex { get; set; } + [JsonProperty("face")] + public string Face { get; set; } + // face_nft + [JsonProperty("sign")] + public string Sign { get; set; } + // rank + [JsonProperty("level")] + public int Level { get; set; } + // jointime + // moral + // silence + // coins + //[JsonProperty("fans_badge")] + //public bool FansBadge { get; set; } + // fans_medal + // official + [JsonProperty("vip")] + public UserInfoVip Vip { get; set; } + // pendant + // nameplate + // user_honour_info + [JsonProperty("is_followed")] + public bool IsFollowed { get; set; } + [JsonProperty("top_photo")] + public string TopPhoto { get; set; } + // ... + } + +} diff --git a/DownKyi.Core/BiliApi/Users/Models/UserInfoLevelExp.cs b/DownKyi.Core/BiliApi/Users/Models/UserInfoLevelExp.cs new file mode 100644 index 0000000..ba8193d --- /dev/null +++ b/DownKyi.Core/BiliApi/Users/Models/UserInfoLevelExp.cs @@ -0,0 +1,17 @@ +using DownKyi.Core.BiliApi.Models; +using Newtonsoft.Json; + +namespace DownKyi.Core.BiliApi.Users.Models +{ + public class UserInfoLevelExp : BaseModel + { + [JsonProperty("current_level")] + public int CurrentLevel { get; set; } + [JsonProperty("current_min")] + public int CurrentMin { get; set; } + [JsonProperty("current_exp")] + public int CurrentExp { get; set; } + [JsonProperty("next_exp")] + public int NextExp { get; set; } + } +} diff --git a/DownKyi.Core/BiliApi/Users/Models/UserInfoVip.cs b/DownKyi.Core/BiliApi/Users/Models/UserInfoVip.cs new file mode 100644 index 0000000..0ece787 --- /dev/null +++ b/DownKyi.Core/BiliApi/Users/Models/UserInfoVip.cs @@ -0,0 +1,41 @@ +using DownKyi.Core.BiliApi.Models; +using Newtonsoft.Json; + +namespace DownKyi.Core.BiliApi.Users.Models +{ + public class UserInfoVip : BaseModel + { + [JsonProperty("type")] + public int Type { get; set; } + [JsonProperty("status")] + public int Status { get; set; } + [JsonProperty("due_date")] + public long DueDate { get; set; } + // vip_pay_type + // theme_type + [JsonProperty("label")] + public UserInfoVipLabel Label { get; set; } + [JsonProperty("avatar_subscript")] + public int AvatarSubscript { get; set; } + [JsonProperty("nickname_color")] + public string NicknameColor { get; set; } + // role + [JsonProperty("avatar_subscript_url")] + public string AvatarSubscriptUrl { get; set; } + } + + public class UserInfoVipLabel : BaseModel + { + // path + [JsonProperty("text")] + public string Text { get; set; } + [JsonProperty("label_theme")] + public string LabelTheme { get; set; } + [JsonProperty("text_color")] + public string TextColor { get; set; } + // bg_style + // bg_color + // border_color + } + +} diff --git a/DownKyi.Core/BiliApi/Users/Models/UserRelationStat.cs b/DownKyi.Core/BiliApi/Users/Models/UserRelationStat.cs new file mode 100644 index 0000000..076e4c4 --- /dev/null +++ b/DownKyi.Core/BiliApi/Users/Models/UserRelationStat.cs @@ -0,0 +1,26 @@ +using DownKyi.Core.BiliApi.Models; +using Newtonsoft.Json; + +namespace DownKyi.Core.BiliApi.Users.Models +{ + // https://api.bilibili.com/x/relation/stat?vmid={mid} + public class UserRelationStatOrigin : BaseModel + { + [JsonProperty("data")] + public UserRelationStat Data { get; set; } + } + + public class UserRelationStat : BaseModel + { + [JsonProperty("mid")] + public long Mid { get; set; } + [JsonProperty("following")] + public long Following { get; set; } // 关注数 + [JsonProperty("whisper")] + public long Whisper { get; set; } + [JsonProperty("black")] + public long Black { get; set; } + [JsonProperty("follower")] + public long Follower { get; set; } // 粉丝数 + } +} diff --git a/DownKyi.Core/BiliApi/Users/Nickname.cs b/DownKyi.Core/BiliApi/Users/Nickname.cs new file mode 100644 index 0000000..80da154 --- /dev/null +++ b/DownKyi.Core/BiliApi/Users/Nickname.cs @@ -0,0 +1,38 @@ +using DownKyi.Core.BiliApi.Users.Models; +using DownKyi.Core.Logging; +using Newtonsoft.Json; +using System; + +namespace DownKyi.Core.BiliApi.Users +{ + /// + /// 用户昵称 + /// + public class Nickname + { + /// + /// 检查昵称 + /// + /// + /// + public static NicknameStatus CheckNickname(string nickName) + { + string url = $"https://api.bilibili.com/x/relation/stat?nickName={nickName}"; + string referer = "https://www.bilibili.com"; + string response = WebClient.RequestWeb(url, referer); + + try + { + NicknameStatus nickname = JsonConvert.DeserializeObject(response); + return nickname; + } + catch (Exception e) + { + Utils.Debugging.Console.PrintLine("CheckNickname()发生异常: {0}", e); + LogManager.Error("Nickname", e); + return null; + } + } + + } +} diff --git a/DownKyi.Core/BiliApi/Users/UserInfo.cs b/DownKyi.Core/BiliApi/Users/UserInfo.cs new file mode 100644 index 0000000..30971a0 --- /dev/null +++ b/DownKyi.Core/BiliApi/Users/UserInfo.cs @@ -0,0 +1,89 @@ +using DownKyi.Core.BiliApi.Users.Models; +using DownKyi.Core.Logging; +using Newtonsoft.Json; +using System; + +namespace DownKyi.Core.BiliApi.Users +{ + /// + /// 用户基本信息 + /// + public static class UserInfo + { + /// + /// 导航栏用户信息 + /// + /// + public static UserInfoForNavigation GetUserInfoForNavigation() + { + string url = "https://api.bilibili.com/x/web-interface/nav"; + string referer = "https://www.bilibili.com"; + string response = WebClient.RequestWeb(url, referer); + + try + { + UserInfoForNavigationOrigin userInfo = JsonConvert.DeserializeObject(response); + if (userInfo == null || userInfo.Data == null) { return null; } + + if (userInfo.Data.IsLogin) { return userInfo.Data; } + else { return null; } + } + catch (Exception e) + { + Utils.Debugging.Console.PrintLine("GetUserInfoForNavigation()发生异常: {0}", e); + LogManager.Error("UserInfo", e); + return null; + } + } + + /// + /// 用户空间详细信息 + /// + /// + /// + public static UserInfoForSpace GetUserInfoForSpace(long mid) + { + string url = $"https://api.bilibili.com/x/space/acc/info?mid={mid}"; + string referer = "https://www.bilibili.com"; + string response = WebClient.RequestWeb(url, referer); + + try + { + UserInfoForSpaceOrigin spaceInfo = JsonConvert.DeserializeObject(response); + if (spaceInfo == null || spaceInfo.Data == null) { return null; } + return spaceInfo.Data; + } + catch (Exception e) + { + Utils.Debugging.Console.PrintLine("GetInfoForSpace()发生异常: {0}", e); + LogManager.Error("UserInfo", e); + return null; + } + } + + /// + /// 本用户详细信息 + /// + /// + public static MyInfo GetMyInfo() + { + string url = "https://api.bilibili.com/x/space/myinfo"; + string referer = "https://www.bilibili.com"; + string response = WebClient.RequestWeb(url, referer); + + try + { + MyInfoOrigin myInfo = JsonConvert.DeserializeObject(response); + if (myInfo == null || myInfo.Data == null) { return null; } + return myInfo.Data; + } + catch (Exception e) + { + Utils.Debugging.Console.PrintLine("GetMyInfo()发生异常: {0}", e); + LogManager.Error("UserInfo", e); + return null; + } + } + + } +} diff --git a/DownKyi.Core/BiliApi/Users/UserRelation.cs b/DownKyi.Core/BiliApi/Users/UserRelation.cs new file mode 100644 index 0000000..d6c4c96 --- /dev/null +++ b/DownKyi.Core/BiliApi/Users/UserRelation.cs @@ -0,0 +1,268 @@ +using DownKyi.Core.BiliApi.Users.Models; +using DownKyi.Core.Logging; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; + +namespace DownKyi.Core.BiliApi.Users +{ + /// + /// 用户关系相关 + /// + public static class UserRelation + { + + /// + /// 查询用户粉丝明细 + /// + /// 目标用户UID + /// 页码 + /// 每页项数 + /// + public static RelationFollow GetFollowers(long mid, int pn, int ps) + { + string url = $"https://api.bilibili.com/x/relation/followers?vmid={mid}&pn={pn}&ps={ps}"; + string referer = "https://www.bilibili.com"; + string response = WebClient.RequestWeb(url, referer); + + try + { + RelationFollowOrigin relationFollower = JsonConvert.DeserializeObject(response); + if (relationFollower == null || relationFollower.Data == null) { return null; } + return relationFollower.Data; + } + catch (Exception e) + { + Utils.Debugging.Console.PrintLine("GetFollowers()发生异常: {0}", e); + LogManager.Error("UserRelation", e); + return null; + } + } + + /// + /// 查询用户所有的粉丝明细 + /// + /// 目标用户UID + /// + public static List GetAllFollowers(long mid) + { + List result = new List(); + + int i = 0; + while (true) + { + i++; + int ps = 50; + + RelationFollow data = GetFollowers(mid, i, ps); + if (data == null || data.List == null || data.List.Count == 0) + { break; } + + result.AddRange(data.List); + } + + return result; + } + + /// + /// 查询用户关注明细 + /// + /// 目标用户UID + /// 页码 + /// 每页项数 + /// 排序方式 + /// + public static RelationFollow GetFollowings(long mid, int pn, int ps, FollowingOrder order = FollowingOrder.DEFAULT) + { + string orderType = ""; + if (order == FollowingOrder.ATTENTION) + { + orderType = "attention"; + } + + string url = $"https://api.bilibili.com/x/relation/followings?vmid={mid}&pn={pn}&ps={ps}&order_type={orderType}"; + string referer = "https://www.bilibili.com"; + string response = WebClient.RequestWeb(url, referer); + + try + { + RelationFollowOrigin relationFollower = JsonConvert.DeserializeObject(response); + if (relationFollower == null || relationFollower.Data == null) { return null; } + return relationFollower.Data; + } + catch (Exception e) + { + Utils.Debugging.Console.PrintLine("GetFollowings()发生异常: {0}", e); + LogManager.Error("UserRelation", e); + return null; + } + } + + /// + /// 查询用户所有的关注明细 + /// + /// 目标用户UID + /// 排序方式 + /// + public static List GetAllFollowings(long mid, FollowingOrder order = FollowingOrder.DEFAULT) + { + List result = new List(); + + int i = 0; + while (true) + { + i++; + int ps = 50; + + RelationFollow data = GetFollowings(mid, i, ps, order); + if (data == null || data.List == null || data.List.Count == 0) + { break; } + + result.AddRange(data.List); + } + + return result; + } + + /// + /// 查询悄悄关注明细 + /// + /// 页码 + /// 每页项数 + /// + public static List GetWhispers(int pn, int ps) + { + string url = $"https://api.bilibili.com/x/relation/whispers?pn={pn}&ps={ps}"; + string referer = "https://www.bilibili.com"; + string response = WebClient.RequestWeb(url, referer); + + try + { + RelationWhisper relationWhisper = JsonConvert.DeserializeObject(response); + if (relationWhisper == null || relationWhisper.Data == null) { return null; } + return relationWhisper.Data; + } + catch (Exception e) + { + Utils.Debugging.Console.PrintLine("GetWhispers()发生异常: {0}", e); + LogManager.Error("UserRelation", e); + return null; + } + } + + /// + /// 查询黑名单明细 + /// + /// 页码 + /// 每页项数 + /// + public static List GetBlacks(int pn, int ps) + { + string url = $"https://api.bilibili.com/x/relation/blacks?pn={pn}&ps={ps}"; + string referer = "https://www.bilibili.com"; + string response = WebClient.RequestWeb(url, referer); + + try + { + RelationBlack relationBlack = JsonConvert.DeserializeObject(response); + if (relationBlack == null || relationBlack.Data == null) { return null; } + return relationBlack.Data; + } + catch (Exception e) + { + Utils.Debugging.Console.PrintLine("GetBlacks()发生异常: {0}", e); + LogManager.Error("UserRelation", e); + return null; + } + } + + #region 关注分组相关,只能查询当前登录账户的信息 + + /// + /// 查询关注分组列表 + /// + /// + public static List GetFollowingGroup() + { + string url = $"https://api.bilibili.com/x/relation/tags"; + string referer = "https://www.bilibili.com"; + string response = WebClient.RequestWeb(url, referer); + + try + { + var followingGroup = JsonConvert.DeserializeObject(response); + if (followingGroup == null || followingGroup.Data == null) { return null; } + return followingGroup.Data; + } + catch (Exception e) + { + Utils.Debugging.Console.PrintLine("GetFollowingGroup()发生异常: {0}", e); + LogManager.Error("UserRelation", e); + return null; + } + } + + /// + /// 查询关注分组明细 + /// + /// 分组ID + /// 页数 + /// 每页项数 + /// 排序方式 + /// + public static List GetFollowingGroupContent(int tagId, int pn, int ps, FollowingOrder order = FollowingOrder.DEFAULT) + { + string orderType = ""; + if (order == FollowingOrder.ATTENTION) + { + orderType = "attention"; + } + + string url = $"https://api.bilibili.com/x/relation/tag?tagid={tagId}&pn={pn}&ps={ps}&order_type={orderType}"; + string referer = "https://www.bilibili.com"; + string response = WebClient.RequestWeb(url, referer); + + try + { + FollowingGroupContent content = JsonConvert.DeserializeObject(response); + if (content == null || content.Data == null) { return null; } + return content.Data; + } + catch (Exception e) + { + Utils.Debugging.Console.PrintLine("GetFollowingGroupContent()发生异常: {0}", e); + LogManager.Error("UserRelation", e); + return null; + } + } + + /// + /// 查询所有的关注分组明细 + /// + /// 分组ID + /// 排序方式 + /// + public static List GetAllFollowingGroupContent(int tagId, FollowingOrder order = FollowingOrder.DEFAULT) + { + List result = new List(); + + int i = 0; + while (true) + { + i++; + int ps = 50; + + var data = GetFollowingGroupContent(tagId, i, ps, order); + if (data == null || data.Count == 0) + { break; } + + result.AddRange(data); + } + + return result; + } + + #endregion + + } +} diff --git a/DownKyi.Core/BiliApi/Users/UserSpace.cs b/DownKyi.Core/BiliApi/Users/UserSpace.cs new file mode 100644 index 0000000..ce85ee6 --- /dev/null +++ b/DownKyi.Core/BiliApi/Users/UserSpace.cs @@ -0,0 +1,348 @@ +using DownKyi.Core.BiliApi.Users.Models; +using DownKyi.Core.Logging; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using System; +using System.Collections.Generic; + +namespace DownKyi.Core.BiliApi.Users +{ + /// + /// 用户空间信息 + /// + public static class UserSpace + { + /// + /// 查询空间设置 + /// + /// + /// + public static SpaceSettings GetSpaceSettings(long mid) + { + string url = $"https://space.bilibili.com/ajax/settings/getSettings?mid={mid}"; + string referer = "https://www.bilibili.com"; + string response = WebClient.RequestWeb(url, referer); + + try + { + SpaceSettingsOrigin settings = JsonConvert.DeserializeObject(response); + if (settings == null || settings.Data == null || !settings.Status) { return null; } + return settings.Data; + } + catch (Exception e) + { + Utils.Debugging.Console.PrintLine("GetSpaceSettings()发生异常: {0}", e); + LogManager.Error("UserSpace", e); + return null; + } + } + + #region 投稿 + + /// + /// 获取用户投稿视频的所有分区 + /// + /// 用户id + /// + public static List GetPublicationType(long mid) + { + int pn = 1; + int ps = 1; + SpacePublicationList publication = GetPublication(mid, pn, ps); + return GetPublicationType(publication); + } + + /// + /// 获取用户投稿视频的所有分区 + /// + /// 用户id + /// + public static List GetPublicationType(SpacePublicationList publication) + { + if (publication == null || publication.Tlist == null) + { + return null; + } + + List result = new List(); + JObject typeList = JObject.Parse(publication.Tlist.ToString("N")); + foreach (KeyValuePair item in typeList) + { + SpacePublicationListTypeVideoZone value = JsonConvert.DeserializeObject(item.Value.ToString()); + result.Add(value); + } + return result; + } + + /// + /// 查询用户所有的投稿视频明细 + /// + /// 用户id + /// 排序 + /// 视频分区 + /// 搜索关键词 + /// + public static List GetAllPublication(long mid, int tid = 0, PublicationOrder order = PublicationOrder.PUBDATE, string keyword = "") + { + List result = new List(); + + int i = 0; + while (true) + { + i++; + int ps = 100; + + SpacePublicationList data = GetPublication(mid, i, ps, tid, order, keyword); + if (data == null || data.Vlist == null || data.Vlist.Count == 0) + { break; } + + result.AddRange(data.Vlist); + } + + return result; + } + + /// + /// 查询用户投稿视频明细 + /// + /// 用户id + /// 页码 + /// 每页的视频数 + /// 排序 + /// 视频分区 + /// 搜索关键词 + /// + public static SpacePublicationList GetPublication(long mid, int pn, int ps, int tid = 0, PublicationOrder order = PublicationOrder.PUBDATE, string keyword = "") + { + string url = $"https://api.bilibili.com/x/space/arc/search?mid={mid}&pn={pn}&ps={ps}&order={order.ToString("G").ToLower()}&tid={tid}&keyword={keyword}"; + string referer = "https://www.bilibili.com"; + string response = WebClient.RequestWeb(url, referer); + + try + { + // 忽略play的值为“--”时的类型错误 + JsonSerializerSettings settings = new JsonSerializerSettings + { + Error = (sender, args) => + { + if (Equals(args.ErrorContext.Member, "play") && + args.ErrorContext.OriginalObject.GetType() == typeof(SpacePublicationListVideo)) + { + args.ErrorContext.Handled = true; + } + } + }; + + SpacePublicationOrigin spacePublication = JsonConvert.DeserializeObject(response, settings); + if (spacePublication == null || spacePublication.Data == null) { return null; } + return spacePublication.Data.List; + } + catch (Exception e) + { + Utils.Debugging.Console.PrintLine("GetPublication()发生异常: {0}", e); + LogManager.Error("UserSpace", e); + return null; + } + } + + #endregion + + #region 频道 + + /// + /// 查询用户频道列表 + /// + /// 用户id + /// + public static List GetChannelList(long mid) + { + string url = $"https://api.bilibili.com/x/space/channel/list?mid={mid}"; + string referer = "https://www.bilibili.com"; + string response = WebClient.RequestWeb(url, referer); + + try + { + SpaceChannelOrigin spaceChannel = JsonConvert.DeserializeObject(response); + if (spaceChannel == null || spaceChannel.Data == null) { return null; } + return spaceChannel.Data.List; + } + catch (Exception e) + { + Utils.Debugging.Console.PrintLine("GetChannelList()发生异常: {0}", e); + LogManager.Error("UserSpace", e); + return null; + } + } + + /// + /// 查询用户频道中的所有视频 + /// + /// + /// + /// + public static List GetAllChannelVideoList(long mid, long cid) + { + List result = new List(); + + int i = 0; + while (true) + { + i++; + int ps = 100; + + List data = GetChannelVideoList(mid, cid, i, ps); + if (data == null || data.Count == 0) + { break; } + + result.AddRange(data); + } + return result; + } + + /// + /// 查询用户频道中的视频 + /// + /// + /// + /// + /// + /// + public static List GetChannelVideoList(long mid, long cid, int pn, int ps) + { + string url = $"https://api.bilibili.com/x/space/channel/video?mid={mid}&cid={cid}&pn={pn}&ps={ps}"; + string referer = "https://www.bilibili.com"; + string response = WebClient.RequestWeb(url, referer); + + try + { + SpaceChannelVideoOrigin spaceChannelVideo = JsonConvert.DeserializeObject(response); + if (spaceChannelVideo == null || spaceChannelVideo.Data == null || spaceChannelVideo.Data.List == null) + { return null; } + return spaceChannelVideo.Data.List.Archives; + } + catch (Exception e) + { + Utils.Debugging.Console.PrintLine("GetChannelVideoList()发生异常: {0}", e); + LogManager.Error("UserSpace", e); + return null; + } + } + + #endregion + + #region 课程 + + /// + /// 查询用户发布的课程列表 + /// + /// 目标用户UID + /// 页码 + /// 每页项数 + /// + public static List GetCheese(long mid, int pn, int ps) + { + string url = $"https://api.bilibili.com/pugv/app/web/season/page?mid={mid}&pn={pn}&ps={ps}"; + string referer = "https://www.bilibili.com"; + string response = WebClient.RequestWeb(url, referer); + + try + { + SpaceCheeseOrigin cheese = JsonConvert.DeserializeObject(response); + if (cheese == null || cheese.Data == null || cheese.Data.Items == null) + { return null; } + return cheese.Data.Items; + } + catch (Exception e) + { + Utils.Debugging.Console.PrintLine("GetCheese()发生异常: {0}", e); + LogManager.Error("UserSpace", e); + return null; + } + } + + /// + /// 查询用户发布的所有课程列表 + /// + /// 目标用户UID + /// + public static List GetAllCheese(long mid) + { + List result = new List(); + + int i = 0; + while (true) + { + i++; + int ps = 50; + + List data = GetCheese(mid, i, ps); + if (data == null || data.Count == 0) + { break; } + + result.AddRange(data); + } + return result; + } + + #endregion + + #region 订阅 + + /// + /// 查询用户追番(追剧)明细 + /// + /// 目标用户UID + /// 查询类型 + /// 页码 + /// 每页项数 + /// + public static BangumiFollowData GetBangumiFollow(long mid, BangumiType type, int pn, int ps) + { + string url = $"https://api.bilibili.com/x/space/bangumi/follow/list?vmid={mid}&type={type:D}&pn={pn}&ps={ps}"; + string referer = "https://www.bilibili.com"; + string response = WebClient.RequestWeb(url, referer); + + try + { + BangumiFollowOrigin bangumiFollow = JsonConvert.DeserializeObject(response); + if (bangumiFollow == null || bangumiFollow.Data == null) + { return null; } + return bangumiFollow.Data; + } + catch (Exception e) + { + Utils.Debugging.Console.PrintLine("GetBangumiFollow()发生异常: {0}", e); + LogManager.Error("UserSpace", e); + return null; + } + } + + /// + /// 查询用户所有的追番(追剧)明细 + /// + /// 目标用户UID + /// 查询类型 + /// + public static List GetAllBangumiFollow(long mid, BangumiType type) + { + List result = new List(); + + int i = 0; + while (true) + { + i++; + int ps = 30; + + BangumiFollowData data = GetBangumiFollow(mid, type, i, ps); + if (data == null || data.List == null || data.List.Count == 0) + { break; } + + result.AddRange(data.List); + } + return result; + } + + #endregion + + } +} diff --git a/DownKyi.Core/BiliApi/Users/UserStatus.cs b/DownKyi.Core/BiliApi/Users/UserStatus.cs new file mode 100644 index 0000000..a1485db --- /dev/null +++ b/DownKyi.Core/BiliApi/Users/UserStatus.cs @@ -0,0 +1,66 @@ +using DownKyi.Core.BiliApi.Users.Models; +using DownKyi.Core.Logging; +using Newtonsoft.Json; +using System; + +namespace DownKyi.Core.BiliApi.Users +{ + /// + /// 用户状态数 + /// + public static class UserStatus + { + /// + /// 关系状态数 + /// + /// + /// + public static UserRelationStat GetUserRelationStat(long mid) + { + string url = $"https://api.bilibili.com/x/relation/stat?vmid={mid}"; + string referer = "https://www.bilibili.com"; + string response = WebClient.RequestWeb(url, referer); + + try + { + UserRelationStatOrigin userRelationStat = JsonConvert.DeserializeObject(response); + if (userRelationStat == null || userRelationStat.Data == null) { return null; } + return userRelationStat.Data; + } + catch (Exception e) + { + Utils.Debugging.Console.PrintLine("GetUserRelationStat()发生异常: {0}", e); + LogManager.Error("UserStatus", e); + return null; + } + } + + /// + /// UP主状态数 + /// + /// 注:该接口需要任意用户登录,否则不会返回任何数据 + /// + /// + /// + public static UpStat GetUpStat(long mid) + { + string url = $"https://api.bilibili.com/x/space/upstat?mid={mid}"; + string referer = "https://www.bilibili.com"; + string response = WebClient.RequestWeb(url, referer); + + try + { + UpStatOrigin upStat = JsonConvert.DeserializeObject(response); + if (upStat == null || upStat.Data == null) { return null; } + return upStat.Data; + } + catch (Exception e) + { + Utils.Debugging.Console.PrintLine("GetUpStat()发生异常: {0}", e); + LogManager.Error("UserStatus", e); + return null; + } + } + + } +} diff --git a/DownKyi.Core/BiliApi/Zone/VideoZone.cs b/DownKyi.Core/BiliApi/Zone/VideoZone.cs index 038a120..0ebd65e 100644 --- a/DownKyi.Core/BiliApi/Zone/VideoZone.cs +++ b/DownKyi.Core/BiliApi/Zone/VideoZone.cs @@ -27,6 +27,8 @@ namespace DownKyi.Core.BiliApi.Zone private VideoZone() { + // SpacePublicationListType类需要同步更新 + //动画 zones.Add(new ZoneAttr(1, "douga", "动画")); // 主分区 zones.Add(new ZoneAttr(24, "mad", "MAD·AMV", 1)); //具有一定制作程度的动画或静画的二次创作视频 diff --git a/DownKyi.Core/DownKyi.Core.csproj b/DownKyi.Core/DownKyi.Core.csproj index 52019d0..a5cb204 100644 --- a/DownKyi.Core/DownKyi.Core.csproj +++ b/DownKyi.Core/DownKyi.Core.csproj @@ -153,19 +153,61 @@ - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/DownKyi/DownKyi.csproj b/DownKyi/DownKyi.csproj index 11dd389..3f8e5ca 100644 --- a/DownKyi/DownKyi.csproj +++ b/DownKyi/DownKyi.csproj @@ -95,6 +95,7 @@ + diff --git a/DownKyi/Images/NavigationIcon.cs b/DownKyi/Images/NavigationIcon.cs index bdbe329..235d37a 100644 --- a/DownKyi/Images/NavigationIcon.cs +++ b/DownKyi/Images/NavigationIcon.cs @@ -22,8 +22,25 @@ 0s.49-1.28 0-1.77L9.38 12l7.25-7.25c.48-.48.48-1.28-.01-1.76z", Fill = "#FF000000" }; + + Logout = new VectorImage + { + Height = 18.75,//100, + Width = 24,//128, + Data = @"M21.5,11.3l-2.8-2.7c-0.2-0.2-0.2-0.4-0.2-0.7c0.1-0.3,0.2-0.4,0.5-0.5c0.3-0.1,0.5,0,0.7,0.2l4,3.9 + c0.1,0.1,0.2,0.3,0.2,0.5c0,0.2-0.1,0.4-0.2,0.5l-4,3.9c-0.2,0.2-0.4,0.2-0.7,0.2c-0.3-0.1-0.4-0.2-0.5-0.5c-0.1-0.3,0-0.5,0.2-0.7 + l2.8-2.7h-8.7c-0.2,0-0.4-0.1-0.5-0.2c-0.1-0.1-0.2-0.3-0.2-0.5c0-0.2,0.1-0.4,0.2-0.5c0.1-0.1,0.3-0.2,0.5-0.2 + C12.8,11.3,21.5,11.3,21.5,11.3z M16,18.2c0-0.2,0.1-0.4,0.2-0.5c0.1-0.1,0.3-0.2,0.5-0.2c0.2,0,0.4,0.1,0.5,0.2 + c0.1,0.1,0.2,0.3,0.2,0.5v0.4c0,0.8-0.3,1.5-0.9,2c-0.6,0.5-1.2,0.8-2,0.8H2.9c-0.8,0-1.5-0.3-2-0.8S0,19.3,0,18.5V5.4 + c0-0.8,0.3-1.5,0.8-2s1.2-0.8,2-0.8h11.7c0.8,0,1.5,0.3,2,0.8c0.5,0.5,0.8,1.2,0.8,2v0.4c0,0.3-0.1,0.5-0.4,0.6 + c-0.2,0.1-0.5,0.1-0.7,0C16.1,6.3,16,6.1,16,5.8V5.4c0-0.4-0.1-0.7-0.4-1c-0.3-0.3-0.6-0.4-1-0.4H2.9c-0.4,0-0.7,0.1-1,0.4 + C1.6,4.7,1.4,5,1.4,5.4v13.1c0,0.4,0.2,0.7,0.4,1c0.3,0.3,0.6,0.4,1,0.4h11.7c0.4,0,0.7-0.1,1-0.4c0.3-0.3,0.4-0.6,0.4-1L16,18.2 + L16,18.2z", + Fill = "#FF000000" + }; } public VectorImage ArrowBack { get; private set; } + public VectorImage Logout { get; private set; } } } diff --git a/DownKyi/Images/NormalIcon.cs b/DownKyi/Images/NormalIcon.cs index d785fc1..e8fc100 100644 --- a/DownKyi/Images/NormalIcon.cs +++ b/DownKyi/Images/NormalIcon.cs @@ -106,6 +106,139 @@ Fill = "#FF000000" }; + CoinIcon = new VectorImage + { + Height = 20, + Width = 20, + Data = @"M473.7 358.8 l0 -54.42 l-129.01 0 q-16.12 0 -27.21 -11.09 q-11.09 -11.09 -11.09 -27.72 q0 -16.63 11.09 -27.21 + q11.09 -10.58 27.21 -11.59 l334.62 0 q22.17 1.01 32.76 20.16 q10.58 19.15 0 37.8 q-10.59 18.64 -32.76 19.65 l-129.01 0 + l0 54.42 q93.73 16.13 153.7 83.66 q59.97 67.52 61.98 163.27 l0 23.18 q-1 17.14 -11.59 27.72 q-10.59 10.58 -27.22 10.58 + q-16.63 0 -27.72 -10.58 q-11.08 -10.58 -11.08 -27.72 l0 -23.18 q-1.01 -62.49 -39.31 -108.35 q-38.3 -45.86 -98.77 -59.96 + l0 332.6 q0 16.12 -11.09 27.2 q-11.08 11.09 -27.21 11.09 q-16.13 0 -27.22 -11.09 q-11.08 -11.08 -11.08 -27.2 l0 -332.6 + q-60.47 14.11 -98.77 59.96 q-38.3 45.86 -39.31 108.35 l0 23.18 q0 17.14 -11.09 27.72 q-11.08 10.58 -27.71 10.58 + q-16.63 0 -27.21 -10.58 q-10.59 -10.58 -11.59 -27.72 l0 -23.18 q2.01 -95.75 61.98 -163.27 q59.97 -67.53 153.7 -83.66 + ZM512 1024 q-217.7 -6.05 -361.82 -150.17 q-144.13 -144.13 -150.18 -361.83 q6.05 -217.7 150.18 -361.82 + q144.13 -144.13 361.82 -150.18 q217.7 6.05 361.83 150.18 q144.13 144.13 150.17 361.82 q-6.05 217.7 -150.17 361.83 + q-144.13 144.13 -361.83 150.17 ZM512 946.39 q184.44 -5.04 306.89 -127.5 q122.46 -122.45 127.5 -306.89 + q-5.04 -184.44 -127.5 -306.89 q-122.45 -122.46 -306.89 -127.5 q-184.44 5.04 -306.89 127.5 q-122.46 122.45 -127.5 306.89 + q5.04 184.44 127.5 306.89 q122.45 122.46 306.89 127.5 Z", + Fill = "#FF000000" + }; + + MoneyIcon = new VectorImage + { + Height = 20, + Width = 20, + Data = @"M409.2 444.47 l138.08 0 q28.22 -1.01 46.36 -19.15 q18.14 -18.14 18.14 -45.85 q0 -27.72 -18.14 -46.36 + q-18.14 -18.65 -46.36 -19.66 l-129.01 0 q-4.03 0 -6.55 3.03 q-2.52 3.02 -2.52 6.04 l0 121.95 ZM658.14 469.67 + q48.38 30.24 68.03 80.63 q19.66 50.39 4.03 105.32 q-15.63 54.93 -58.96 87.18 q-43.34 32.25 -99.78 33.25 l-153.19 0 + q-36.29 -1 -60.98 -25.19 q-24.69 -24.19 -25.7 -61.48 l0 -366.87 q1.01 -36.28 25.7 -60.47 q24.69 -24.19 60.98 -25.2 + l129.01 0 q42.33 0 76.6 21.67 q34.26 21.67 52.41 59.47 q18.14 37.79 13.11 78.11 q-5.04 40.31 -31.25 73.57 ZM571.46 522.08 + l-162.26 0 l0 167.31 q1 9.07 9.07 9.07 l153.19 0 q36.29 -1.01 60.48 -26.21 q24.19 -25.2 24.19 -61.99 q0 -36.79 -24.19 -61.48 + q-24.19 -24.7 -60.48 -26.71 ZM512 1024 q-217.7 -6.05 -361.82 -150.17 q-144.13 -144.13 -150.18 -361.83 + q6.05 -217.7 150.18 -361.82 q144.13 -144.13 361.82 -150.18 q217.7 6.05 361.83 150.18 q144.13 144.13 150.17 361.82 + q-6.05 217.7 -150.17 361.83 q-144.13 144.13 -361.83 150.17 ZM512 946.39 q184.44 -5.04 306.89 -127.5 + q122.46 -122.45 127.5 -306.89 q-5.04 -184.44 -127.5 -306.89 q-122.45 -122.46 -306.89 -127.5 q-184.44 5.04 -306.89 127.5 + q-122.46 122.45 -127.5 306.89 q5.04 184.44 127.5 306.89 q122.45 122.46 306.89 127.5 Z", + Fill = "#FF000000" + }; + + BindingEmail = new VectorImage + { + Height = 20, + Width = 20, + Data = @"M512 1024 q-218 -5 -362.5 -149.5 q-144.5 -144.5 -149.5 -362.5 q5 -218 149.5 -362.5 q144.5 -144.5 362.5 -149.5 + q218 5 362.5 149.5 q144.5 144.5 149.5 362.5 q-5 218 -149.5 362.5 q-144.5 144.5 -362.5 149.5 ZM282 278 l214 164 + q8 6 16 6 q8 0 16 -6 l214 -164 l0 257 l-230 77 l-230 -77 l0 -257 ZM305 232 q7 -2 15 -2 l384 0 q8 0 15 2 q-3 2 -5 4 + l-202 154 l-202 -154 q-2 -2 -5 -4 ZM794 518 l0 -262 q-1 -34 -27 -55 q-26 -21 -63 -22 l-384 0 q-37 1 -63 22 + q-26 21 -27 55 l0 262 l-9 -3 q-25 -8 -46 7 q-21 15 -21 41 l0 154 q1 43 29.5 72 q28.5 29 72.5 30 l512 0 q44 -1 72.5 -30 + q28.5 -29 29.5 -72 l0 -154 q0 -26 -21 -41 q-21 -15 -46 -7 l-9 3 ZM205 563 l307 103 l307 -103 l0 154 q0 21 -15 36 + q-15 15 -36 15 l-512 0 q-22 -1 -36.5 -15 q-14.5 -14 -14.5 -36 l0 -154 Z", + Fill = "#FF000000" + }; + + BindingPhone = new VectorImage + { + Height = 20, + Width = 20, + Data = @"M512 1024 q-218 -5 -362.5 -149.5 q-144.5 -144.5 -149.5 -362.5 q5 -218 149.5 -362.5 q144.5 -144.5 362.5 -149.5 + q218 5 362.5 149.5 q144.5 144.5 149.5 362.5 q-5 218 -149.5 362.5 q-144.5 144.5 -362.5 149.5 ZM307 614 l0 -307 + l410 0 l0 461 q0 21 -15 36 q-15 15 -36 15 l-308 0 q-21 0 -35.5 -14.5 q-14.5 -14.5 -15.5 -36.5 l0 -102 l333 0 + q11 -1 18 -8 q7 -7 7 -18 q0 -11 -7 -18 q-7 -7 -18 -8 l-333 0 ZM307 256 q0 -21 15 -36 q15 -15 36 -15 l308 0 + q21 0 36 15 q15 15 15 36 l-410 0 ZM358 154 q-43 1 -72 29.5 q-29 28.5 -30 72.5 l0 512 q1 44 30 72.5 q29 28.5 72 29.5 + l308 0 q43 -1 72 -29.5 q29 -28.5 30 -72.5 l0 -512 q-1 -44 -30 -72.5 q-29 -28.5 -72 -29.5 l-308 0 ZM512 794 + q22 -1 36.5 -15.5 q14.5 -14.5 14.5 -36 q0 -21.5 -14.5 -36 q-14.5 -14.5 -36.5 -14.5 q-22 0 -36.5 14.5 q-14.5 14.5 -14.5 36 + q0 21.5 14.5 36 q14.5 14.5 36.5 15.5 Z", + Fill = "#FF000000" + }; + + FavoriteOutline = new VectorImage + { + Height = 24, + Width = 24, + Data = @"M755.8 1021.89 q-13.98 -1 -28.45 -4.5 q-14.47 -3.5 -29.45 -8.49 l-146.74 -76.87 q-18.97 -13.97 -39.93 -13.97 + q-20.97 0 -35.94 13.97 l-146.75 76.87 q-33.94 14.97 -69.38 12.98 q-35.44 -2 -65.39 -25.96 q-23.96 -19.96 -35.44 -49.41 + q-11.48 -29.45 -2.5 -59.4 l31.95 -184.68 q3.99 -22.96 -3.49 -40.43 q-7.49 -17.47 -22.47 -36.43 l-126.77 -133.77 + q-24.96 -19.96 -32.45 -50.41 q-7.49 -30.45 6.49 -64.39 q9.98 -28.95 34.94 -49.91 q24.96 -20.97 54.9 -26.96 + l171.71 -24.95 q19.96 -1 36.93 -12.98 q16.97 -11.98 26.95 -31.94 l69.88 -159.73 q14.98 -33.94 45.42 -53.91 + q30.44 -19.97 69.38 -15.97 q34.94 0 60.39 20.96 q25.45 20.96 35.44 55.9 l76.86 152.74 q9.98 18.96 26.96 32.44 + q16.98 13.48 36.93 18.47 l172.7 25.95 q28.95 4.99 51.91 22.96 q22.96 17.97 36.93 46.92 q9.99 28.95 5 59.89 + q-5 30.95 -23.96 54.91 l-127.78 133.77 q-14.97 14.97 -22.46 33.94 q-7.49 18.97 -3.49 42.92 l31.94 184.68 + q4.99 34.94 -8.49 65.39 q-13.48 30.45 -42.43 50.41 q-13.98 8.98 -32.44 13.98 q-18.47 5 -37.44 5 ZM513.22 817.24 + q23.96 0 46.92 5.99 q22.96 5.99 42.93 19.97 l139.75 75.87 q9.99 4.99 15.48 2.99 q5.49 -2 10.48 -2.49 + q4.99 -0.5 7.99 -4.99 q3 -4.5 -2 -14.48 l-31.95 -184.68 q-4.99 -47.92 6.49 -87.35 q11.48 -39.43 44.42 -72.37 + l127.78 -133.77 q3.99 -4.99 2.5 -9.98 q-1.5 -4.99 -2 -9.48 q-0.5 -4.5 -4.49 -5.49 q-3.99 -1 -8.99 -1 l-171.7 -24.96 + q-43.92 -5.99 -79.86 -32.44 q-35.94 -26.45 -60.89 -70.38 l-69.88 -159.72 q0 -8.99 -4 -10.98 q-4 -2 -8.99 -2 + q-4.99 0 -9.48 2 q-4.49 1.99 -9.48 10.98 l-69.88 159.72 q-24.96 43.92 -61.39 70.38 q-36.44 26.45 -79.37 32.44 + l-172.7 24.96 q-4.99 0 -8.48 3.99 q-3.5 3.99 -3.99 8.98 q-0.49 5 0.5 8.99 q1 3.99 5.99 3.99 l127.78 133.77 + q32.94 33.94 44.42 71.88 q11.48 37.93 6.49 80.85 l-25.95 185.68 q0 4.99 1 9.49 q1 4.5 5.99 9.49 q5 4.99 13.48 4.99 + q8.49 0 18.47 -4.99 l139.76 -76.87 q10.98 -4.99 31.44 -11.48 q20.47 -6.49 45.42 -7.49 Z", + Fill = "#FF000000" + }; + + BangumiFollow = new VectorImage + { + Height = 24, + Width = 24, + Data = @"M512 945.07 q-6.15 0 -13.53 -2.46 q-7.39 -2.46 -13.54 -4.92 q-43.07 -32 -190.74 -153.83 q-147.67 -121.83 -211.65 -200.59 + q-51.69 -68.91 -67.69 -119.97 q-16 -51.06 -14.77 -116.29 q3.69 -146.44 91.06 -244.88 q87.37 -98.45 220.27 -102.14 + q56.6 0 107.67 20.3 q51.07 20.3 92.91 58.46 q41.84 -38.15 92.91 -58.46 q51.07 -20.3 107.67 -20.3 + q132.9 3.69 220.27 102.14 q87.37 98.45 91.06 244.88 q1.23 61.53 -14.76 113.21 q-16 51.68 -67.68 123.05 + q-63.98 76.3 -212.88 199.36 q-148.9 123.06 -189.51 155.06 q-6.15 2.46 -13.54 4.92 q-7.38 2.46 -13.53 2.46 ZM322.49 78.76 + q-97.21 3.69 -168.58 85.52 q-71.37 81.83 -75.07 197.5 q-1.23 35.69 8 79.99 q9.23 44.3 51.07 105.83 q44.3 52.91 163.66 148.9 + l210.43 169.81 l210.43 -169.81 q119.36 -95.99 163.66 -148.9 q43.07 -61.53 52.3 -107.06 q9.23 -45.53 6.77 -78.76 + q-3.7 -115.67 -75.07 -197.5 q-71.37 -81.83 -168.58 -85.52 q-49.23 0 -87.38 21.53 q-38.14 21.53 -78.75 57.21 + q-11.07 8.62 -17.23 10.47 q-6.15 1.84 -6.15 1.84 l-4.92 -1.23 q-6.16 -1.23 -14.77 -7.39 q-43.07 -35.68 -81.83 -58.44 + q-38.76 -22.77 -87.99 -23.99 Z", + Fill = "#FF000000" + }; + + Toview = new VectorImage + { + Height = 24, + Width = 24, + Data = @"M837.18 92.91 q38.96 1 65.44 27.48 q26.48 26.48 27.48 65.43 l0 651.36 q-1 39.96 -27.48 65.94 + q-26.48 25.98 -65.44 26.98 l-651.36 0 q-38.96 -1 -65.43 -26.98 q-26.48 -25.98 -27.48 -65.94 l0 -651.36 + q1 -38.96 27.48 -65.43 q26.48 -26.48 65.43 -27.48 l651.36 0 ZM837.18 0 l-651.36 0 q-78.92 2 -131.37 54.45 + q-52.45 52.45 -54.45 131.37 l0 651.36 q2 78.93 54.45 131.38 q52.45 52.44 131.37 54.44 l651.36 0 q78.93 -2 131.88 -54.44 + q52.94 -52.45 54.94 -131.38 l0 -651.36 q-3 -78.92 -55.44 -131.37 q-52.45 -52.45 -131.38 -54.45 ZM697.32 744.27 + q-12.99 0 -24.98 -7.99 l-242.76 -159.84 q-20.98 -13.99 -20.98 -38.96 l0 -278.73 q0 -19.98 12.99 -33.47 + q12.99 -13.49 32.97 -13.49 q19.98 0 32.96 13.49 q12.99 13.49 13.99 33.47 l0 252.75 l221.78 143.86 + q17.99 7.99 24.98 24.98 q6.99 16.99 0 35.96 q-6.99 14.99 -20.98 22.48 q-13.99 7.49 -29.97 5.49 Z", + Fill = "#FF000000" + }; + + History = new VectorImage + { + Height = 24, + Width = 24, + Data = @"M512 0 q-217 6 -361.5 150.5 q-144.5 144.5 -150.5 361.5 q6 217 150.5 361.5 q144.5 144.5 361.5 150.5 + q217 -6 361.5 -150.5 q144.5 -144.5 150.5 -361.5 q-6 -217 -150.5 -361.5 q-144.5 -144.5 -361.5 -150.5 ZM512 939 + q-183 -5 -302.5 -124.5 q-119.5 -119.5 -124.5 -302.5 q5 -183 124.5 -302.5 q119.5 -119.5 302.5 -124.5 + q183 5 302.5 124.5 q119.5 119.5 124.5 302.5 q-5 183 -124.5 302.5 q-119.5 119.5 -302.5 124.5 ZM512 256 + l-85 0 l0 341 l341 0 l0 -85 l-256 0 l0 -256 Z", + Fill = "#FF000000" + }; } public VectorImage Play { get; private set; } @@ -117,5 +250,15 @@ public VectorImage Folder { get; private set; } public VectorImage Downloading { get; private set; } public VectorImage DownloadFinished { get; private set; } + + public VectorImage CoinIcon { get; private set; } + public VectorImage MoneyIcon { get; private set; } + public VectorImage BindingEmail { get; private set; } + public VectorImage BindingPhone { get; private set; } + + public VectorImage FavoriteOutline { get; private set; } + public VectorImage BangumiFollow { get; private set; } + public VectorImage Toview { get; private set; } + public VectorImage History { get; private set; } } } diff --git a/DownKyi/Languages/Default.xaml b/DownKyi/Languages/Default.xaml index 565c157..8d11b77 100644 --- a/DownKyi/Languages/Default.xaml +++ b/DownKyi/Languages/Default.xaml @@ -32,6 +32,12 @@ 登录成功!(3秒后自动回到主页) 未保存登录信息!(3秒后自动回到主页) + + 我的个人空间 + 退出登录 + 请稍等,马上就好~ + 等级 + 复制封面图片 复制封面URL diff --git a/DownKyi/Themes/ColorBrush.xaml b/DownKyi/Themes/ColorBrush.xaml index 181e106..a35e8a0 100644 --- a/DownKyi/Themes/ColorBrush.xaml +++ b/DownKyi/Themes/ColorBrush.xaml @@ -18,6 +18,9 @@ + + + @@ -30,14 +33,20 @@ + + + + + + @@ -45,4 +54,6 @@ + + \ No newline at end of file diff --git a/DownKyi/Themes/Colors/ColorDefault.xaml b/DownKyi/Themes/Colors/ColorDefault.xaml index 7ce177c..168440b 100644 --- a/DownKyi/Themes/Colors/ColorDefault.xaml +++ b/DownKyi/Themes/Colors/ColorDefault.xaml @@ -18,6 +18,9 @@ #C800A1D6 #7F00A1D6 #3300A1D6 + + #FFFB7299 + #FF00A1D6 #FFFFFFFF #FFFFFFFF @@ -30,14 +33,20 @@ #33BDBDBD #7F000000 + #33999999 #FFF4F4F4 #FFF4F4F4 + #FF999999 #7F999999 + #FFE4E4E4 + #FFF3CB85 + #7FD0D0D0 + #7FFFFFFF #7FD0D0D0 white @@ -45,4 +54,6 @@ #FF999999 #FF757575 + #FFFFAE00 + \ No newline at end of file diff --git a/DownKyi/Utils/DictionaryResource.cs b/DownKyi/Utils/DictionaryResource.cs index a6fa53c..4d9b8a8 100644 --- a/DownKyi/Utils/DictionaryResource.cs +++ b/DownKyi/Utils/DictionaryResource.cs @@ -15,9 +15,6 @@ namespace DownKyi.Utils /// public static string GetColor(string resourceKey) { - //Color color = (Color)Application.Current.Resources[resourceKey]; - //return color.ToString(); - return Application.Current == null ? "#00000000" : ((Color)Application.Current.Resources[resourceKey]).ToString(); } diff --git a/DownKyi/ViewModels/PageViewModels/SpaceItem.cs b/DownKyi/ViewModels/PageViewModels/SpaceItem.cs new file mode 100644 index 0000000..091cb9f --- /dev/null +++ b/DownKyi/ViewModels/PageViewModels/SpaceItem.cs @@ -0,0 +1,29 @@ +using DownKyi.Images; +using Prism.Mvvm; + +namespace DownKyi.ViewModels.PageViewModels +{ + public class SpaceItem : BindableBase + { + private VectorImage image; + public VectorImage Image + { + get => image; + set => SetProperty(ref image, value); + } + + private string title; + public string Title + { + get => title; + set => SetProperty(ref title, value); + } + + private string subtitle; + public string Subtitle + { + get => subtitle; + set => SetProperty(ref subtitle, value); + } + } +} diff --git a/DownKyi/ViewModels/ViewIndexViewModel.cs b/DownKyi/ViewModels/ViewIndexViewModel.cs index 5cc547d..7da23ea 100644 --- a/DownKyi/ViewModels/ViewIndexViewModel.cs +++ b/DownKyi/ViewModels/ViewIndexViewModel.cs @@ -1,5 +1,5 @@ using DownKyi.Core.BiliApi.BiliUtils; -using DownKyi.Core.BiliApi.Login; +using DownKyi.Core.BiliApi.Users; using DownKyi.Core.Logging; using DownKyi.Core.Settings; using DownKyi.Core.Settings.Models; @@ -26,69 +26,68 @@ namespace DownKyi.ViewModels private Visibility loginPanelVisibility; public Visibility LoginPanelVisibility { - get { return loginPanelVisibility; } - set { SetProperty(ref loginPanelVisibility, value); } + get => loginPanelVisibility; + set => SetProperty(ref loginPanelVisibility, value); } private string userName; public string UserName { - get { return userName; } - set { SetProperty(ref userName, value); } + get => userName; + set => SetProperty(ref userName, value); } private BitmapImage header; public BitmapImage Header { - get { return header; } - set { SetProperty(ref header, value); } + get => header; + set => SetProperty(ref header, value); } private VectorImage textLogo; public VectorImage TextLogo { - get { return textLogo; } - set { SetProperty(ref textLogo, value); } + get => textLogo; + set => SetProperty(ref textLogo, value); } private string inputText; public string InputText { - get { return inputText; } - set { SetProperty(ref inputText, value); } + get => inputText; + set => SetProperty(ref inputText, value); } private VectorImage generalSearch; public VectorImage GeneralSearch { - get { return generalSearch; } - set { SetProperty(ref generalSearch, value); } + get => generalSearch; + set => SetProperty(ref generalSearch, value); } private VectorImage settings; public VectorImage Settings { - get { return settings; } - set { SetProperty(ref settings, value); } + get => settings; + set => SetProperty(ref settings, value); } private VectorImage downloadManager; public VectorImage DownloadManager { - get { return downloadManager; } - set { SetProperty(ref downloadManager, value); } + get => downloadManager; + set => SetProperty(ref downloadManager, value); } private VectorImage toolbox; public VectorImage Toolbox { - get { return toolbox; } - set { SetProperty(ref toolbox, value); } + get => toolbox; + set => SetProperty(ref toolbox, value); } #endregion - public ViewIndexViewModel(IEventAggregator eventAggregator) : base(eventAggregator) { #region 属性初始化 @@ -315,7 +314,7 @@ namespace DownKyi.ViewModels await Task.Run(new Action(() => { // 获取用户信息 - var userInfo = LoginInfo.GetUserInfoForNavigation(); + var userInfo = UserInfo.GetUserInfoForNavigation(); if (userInfo != null) { SettingsManager.GetInstance().SetUserInfo(new UserInfoSettings diff --git a/DownKyi/ViewModels/ViewMySpaceViewModel.cs b/DownKyi/ViewModels/ViewMySpaceViewModel.cs index 8348413..6796ead 100644 --- a/DownKyi/ViewModels/ViewMySpaceViewModel.cs +++ b/DownKyi/ViewModels/ViewMySpaceViewModel.cs @@ -1,10 +1,20 @@ -using Prism.Commands; +using DownKyi.Core.BiliApi.Login; +using DownKyi.Core.BiliApi.Users; +using DownKyi.Core.BiliApi.Users.Models; +using DownKyi.Core.Storage; +using DownKyi.CustomControl; +using DownKyi.Events; +using DownKyi.Images; +using DownKyi.Utils; +using DownKyi.ViewModels.PageViewModels; +using Prism.Commands; using Prism.Events; -using Prism.Mvvm; using Prism.Regions; using System; -using System.Collections.Generic; -using System.Linq; +using System.Collections.ObjectModel; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Media.Imaging; namespace DownKyi.ViewModels { @@ -13,10 +23,549 @@ namespace DownKyi.ViewModels public const string Tag = "PageMySpace"; // mid - private long mid; + private long mid = -1; + + #region 页面属性申明 + + private VectorImage arrowBack; + public VectorImage ArrowBack + { + get => arrowBack; + set => SetProperty(ref arrowBack, value); + } + + private VectorImage logout; + public VectorImage Logout + { + get => logout; + set => SetProperty(ref logout, value); + } + + private GifImage loading; + public GifImage Loading + { + get => loading; + set => SetProperty(ref loading, value); + } + + private Visibility noDataVisibility; + public Visibility NoDataVisibility + { + get => noDataVisibility; + set => SetProperty(ref noDataVisibility, value); + } + + private Visibility loadingVisibility; + public Visibility LoadingVisibility + { + get => loadingVisibility; + set => SetProperty(ref loadingVisibility, value); + } + + private Visibility viewVisibility; + public Visibility ViewVisibility + { + get => viewVisibility; + set => SetProperty(ref viewVisibility, value); + } + + private Visibility contentVisibility; + public Visibility ContentVisibility + { + get => contentVisibility; + set => SetProperty(ref contentVisibility, value); + } + + private string topNavigationBg; + public string TopNavigationBg + { + get => topNavigationBg; + set => SetProperty(ref topNavigationBg, value); + } + + private BitmapImage background; + public BitmapImage Background + { + get => background; + set => SetProperty(ref background, value); + } + + private BitmapImage header; + public BitmapImage Header + { + get => header; + set => SetProperty(ref header, value); + } + + private string userName; + public string UserName + { + get => userName; + set => SetProperty(ref userName, value); + } + + private BitmapImage sex; + public BitmapImage Sex + { + get => sex; + set => SetProperty(ref sex, value); + } + + private BitmapImage level; + public BitmapImage Level + { + get => level; + set => SetProperty(ref level, value); + } + + private Visibility vipTypeVisibility; + public Visibility VipTypeVisibility + { + get => vipTypeVisibility; + set => SetProperty(ref vipTypeVisibility, value); + } + + private string vipType; + public string VipType + { + get => vipType; + set => SetProperty(ref vipType, value); + } + + private string sign; + public string Sign + { + get => sign; + set => SetProperty(ref sign, value); + } + + private VectorImage coinIcon; + public VectorImage CoinIcon + { + get => coinIcon; + set => SetProperty(ref coinIcon, value); + } + + private string coin; + public string Coin + { + get => coin; + set => SetProperty(ref coin, value); + } + + private VectorImage moneyIcon; + public VectorImage MoneyIcon + { + get => moneyIcon; + set => SetProperty(ref moneyIcon, value); + } + + private string money; + public string Money + { + get => money; + set => SetProperty(ref money, value); + } + + private VectorImage bindingEmail; + public VectorImage BindingEmail + { + get => bindingEmail; + set => SetProperty(ref bindingEmail, value); + } + + private Visibility bindingEmailVisibility; + public Visibility BindingEmailVisibility + { + get => bindingEmailVisibility; + set => SetProperty(ref bindingEmailVisibility, value); + } + + private VectorImage bindingPhone; + public VectorImage BindingPhone + { + get => bindingPhone; + set => SetProperty(ref bindingPhone, value); + } + + private Visibility bindingPhoneVisibility; + public Visibility BindingPhoneVisibility + { + get => bindingPhoneVisibility; + set => SetProperty(ref bindingPhoneVisibility, value); + } + + private string levelText; + public string LevelText + { + get => levelText; + set => SetProperty(ref levelText, value); + } + + private string currentExp; + public string CurrentExp + { + get => currentExp; + set => SetProperty(ref currentExp, value); + } + + private int expProgress; + public int ExpProgress + { + get => expProgress; + set => SetProperty(ref expProgress, value); + } + + private int maxExp; + public int MaxExp + { + get => maxExp; + set => SetProperty(ref maxExp, value); + } + + private ObservableCollection statusList; + public ObservableCollection StatusList + { + get => statusList; + set => SetProperty(ref statusList, value); + } + + private ObservableCollection packageList; + public ObservableCollection PackageList + { + get => packageList; + set => SetProperty(ref packageList, value); + } + + private int selectedPackage; + public int SelectedPackage + { + get => selectedPackage; + set => SetProperty(ref selectedPackage, value); + } + + #endregion public ViewMySpaceViewModel(IEventAggregator eventAggregator) : base(eventAggregator) { + #region 属性初始化 + + // 返回按钮 + ArrowBack = NavigationIcon.Instance().ArrowBack; + ArrowBack.Fill = DictionaryResource.GetColor("ColorTextDark"); + + // 退出登录按钮 + Logout = NavigationIcon.Instance().Logout; + Logout.Fill = DictionaryResource.GetColor("ColorTextDark"); + + // 初始化loading gif + Loading = new GifImage(Properties.Resources.loading); + Loading.StartAnimate(); + + TopNavigationBg = "#00FFFFFF"; // 透明 + + // B站图标 + CoinIcon = NormalIcon.Instance().CoinIcon; + CoinIcon.Fill = DictionaryResource.GetColor("ColorPrimary"); + MoneyIcon = NormalIcon.Instance().MoneyIcon; + MoneyIcon.Fill = DictionaryResource.GetColor("ColorMoney"); + BindingEmail = NormalIcon.Instance().BindingEmail; + BindingEmail.Fill = DictionaryResource.GetColor("ColorPrimary"); + BindingPhone = NormalIcon.Instance().BindingPhone; + BindingPhone.Fill = DictionaryResource.GetColor("ColorPrimary"); + + StatusList = new ObservableCollection(); + PackageList = new ObservableCollection(); + + #endregion + } + + #region 命令申明 + + // 返回事件 + private DelegateCommand backSpaceCommand; + public DelegateCommand BackSpaceCommand => backSpaceCommand ?? (backSpaceCommand = new DelegateCommand(ExecuteBackSpace)); + + /// + /// 返回事件 + /// + private void ExecuteBackSpace() + { + NavigationParam parameter = new NavigationParam + { + ViewName = ParentView, + ParentViewName = null, + Parameter = null + }; + eventAggregator.GetEvent().Publish(parameter); + } + + // 退出登录事件 + private DelegateCommand logoutCommand; + public DelegateCommand LogoutCommand => logoutCommand ?? (logoutCommand = new DelegateCommand(ExecuteLogoutCommand)); + + /// + /// 退出登录事件 + /// + private void ExecuteLogoutCommand() + { + // 注销 + LoginHelper.Logout(); + + // 返回上一页 + NavigationParam parameter = new NavigationParam + { + ViewName = ParentView, + ParentViewName = null, + Parameter = "logout" + }; + eventAggregator.GetEvent().Publish(parameter); + } + + // 页面选择事件 + private DelegateCommand packageListCommand; + public DelegateCommand PackageListCommand => packageListCommand ?? (packageListCommand = new DelegateCommand(ExecutePackageListCommand)); + + /// + /// 页面选择事件 + /// + /// + private void ExecutePackageListCommand() + { + if (SelectedPackage == -1) + { + return; + } + + switch (SelectedPackage) + { + case 0: + Console.WriteLine(SelectedPackage); + break; + case 1: + Console.WriteLine(SelectedPackage); + break; + case 2: + Console.WriteLine(SelectedPackage); + break; + case 3: + Console.WriteLine(SelectedPackage); + break; + default: + break; + } + + SelectedPackage = -1; + } + + #endregion + + /// + /// 初始化页面 + /// + private void InitView() + { + TopNavigationBg = "#00FFFFFF"; // 透明 + ArrowBack.Fill = DictionaryResource.GetColor("ColorTextDark"); + Logout.Fill = DictionaryResource.GetColor("ColorTextDark"); + Background = null; + + Header = null; + UserName = ""; + Sex = null; + Level = null; + VipTypeVisibility = Visibility.Collapsed; + VipType = ""; + Sign = ""; + + Coin = "0.0"; + Money = "0.0"; + + LevelText = ""; + CurrentExp = "--/--"; + + StatusList.Clear(); + StatusList.Add(new SpaceItem { Title = "关注数", Subtitle = "--" }); + StatusList.Add(new SpaceItem { Title = "悄悄关注数", Subtitle = "--" }); + StatusList.Add(new SpaceItem { Title = "粉丝数", Subtitle = "--" }); + StatusList.Add(new SpaceItem { Title = "黑名单数", Subtitle = "--" }); + StatusList.Add(new SpaceItem { Title = "节操值", Subtitle = "--" }); + StatusList.Add(new SpaceItem { Title = "封禁状态", Subtitle = "N/A" }); + + PackageList.Clear(); + PackageList.Add(new SpaceItem { Image = NormalIcon.Instance().FavoriteOutline, Title = "收藏夹" }); + PackageList.Add(new SpaceItem { Image = NormalIcon.Instance().BangumiFollow, Title = "我的订阅" }); + PackageList.Add(new SpaceItem { Image = NormalIcon.Instance().Toview, Title = "稍后再看" }); + PackageList.Add(new SpaceItem { Image = NormalIcon.Instance().History, Title = "历史记录" }); + NormalIcon.Instance().FavoriteOutline.Fill = DictionaryResource.GetColor("ColorPrimary"); + NormalIcon.Instance().BangumiFollow.Fill = DictionaryResource.GetColor("ColorPrimary"); + NormalIcon.Instance().Toview.Fill = DictionaryResource.GetColor("ColorPrimary"); + NormalIcon.Instance().History.Fill = DictionaryResource.GetColor("ColorPrimary"); + + SelectedPackage = -1; + + ContentVisibility = Visibility.Collapsed; + ViewVisibility = Visibility.Collapsed; + LoadingVisibility = Visibility.Visible; + NoDataVisibility = Visibility.Collapsed; + } + + /// + /// 更新用户信息 + /// + private async void UpdateSpaceInfo() + { + bool isNoData = true; + Uri toutuUri = null; + string headerUri = null; + Uri sexUri = null; + Uri levelUri = null; + + await Task.Run(() => + { + + // 背景图片 + SpaceSettings spaceSettings = UserSpace.GetSpaceSettings(mid); + if (spaceSettings != null) + { + StorageCover storageCover = new StorageCover(); + string toutu = storageCover.GetCover($"https://i0.hdslb.com/{spaceSettings.Toutu.Limg}"); + toutuUri = new Uri(toutu); + } + else + { + toutuUri = new Uri("pack://application:,,,/Resources/backgound/9-绿荫秘境.png"); + } + + // 我的用户信息 + MyInfo myInfo = UserInfo.GetMyInfo(); + if (myInfo != null) + { + isNoData = false; + + // 头像 + StorageHeader storageHeader = new StorageHeader(); + headerUri = storageHeader.GetHeader(mid, myInfo.Name, myInfo.Face); + // 用户名 + UserName = myInfo.Name; + // 性别 + if (myInfo.Sex == "男") + { + sexUri = new Uri($"pack://application:,,,/Resources/sex/male.png"); + } + else if (myInfo.Sex == "女") + { + sexUri = new Uri($"pack://application:,,,/Resources/sex/female.png"); + } + // 显示vip信息 + if (myInfo.Vip.Label.Text == null || myInfo.Vip.Label.Text == "") + { + VipTypeVisibility = Visibility.Collapsed; + } + else + { + VipTypeVisibility = Visibility.Visible; + VipType = myInfo.Vip.Label.Text; + } + // 等级 + levelUri = new Uri($"pack://application:,,,/Resources/level/lv{myInfo.Level}.png"); + // 签名 + Sign = myInfo.Sign; + // 绑定邮箱&手机 + if (myInfo.EmailStatus == 0) + { BindingEmailVisibility = Visibility.Collapsed; } + if (myInfo.TelStatus == 0) + { BindingPhoneVisibility = Visibility.Collapsed; } + // 等级 + LevelText = $"{DictionaryResource.GetString("Level")}{myInfo.LevelExp.CurrentLevel}"; + if (myInfo.LevelExp.NextExp == -1) + { + CurrentExp = $"{myInfo.LevelExp.CurrentExp}/--"; + } + else + { + CurrentExp = $"{myInfo.LevelExp.CurrentExp}/{myInfo.LevelExp.NextExp}"; + } + // 经验 + MaxExp = myInfo.LevelExp.NextExp; + ExpProgress = myInfo.LevelExp.CurrentExp; + // 节操值 + StatusList[4].Subtitle = myInfo.Moral.ToString(); + // 封禁状态 + if (myInfo.Silence == 0) + { StatusList[5].Subtitle = "正常"; } + else if (myInfo.Silence == 1) + { StatusList[5].Subtitle = "封停"; } + } + else + { + // 没有数据 + isNoData = true; + } + + }); + + if (isNoData) + { + TopNavigationBg = "#00FFFFFF"; // 透明 + ArrowBack.Fill = DictionaryResource.GetColor("ColorTextDark"); + Logout.Fill = DictionaryResource.GetColor("ColorTextDark"); + Background = null; + + ViewVisibility = Visibility.Collapsed; + LoadingVisibility = Visibility.Collapsed; + NoDataVisibility = Visibility.Visible; + return; + } + else + { + // 头像 + StorageHeader storageHeader = new StorageHeader(); + Header = storageHeader.GetHeaderThumbnail(headerUri, 64, 64); + // 性别 + Sex = new BitmapImage(sexUri); + // 等级 + Level = new BitmapImage(levelUri); + + ArrowBack.Fill = DictionaryResource.GetColor("ColorText"); + Logout.Fill = DictionaryResource.GetColor("ColorText"); + TopNavigationBg = DictionaryResource.GetColor("ColorMask100"); + Background = new BitmapImage(toutuUri); + + ViewVisibility = Visibility.Visible; + LoadingVisibility = Visibility.Collapsed; + NoDataVisibility = Visibility.Collapsed; + } + + await Task.Run(() => + { + // 导航栏信息 + UserInfoForNavigation navData = UserInfo.GetUserInfoForNavigation(); + if (navData != null) + { + ContentVisibility = Visibility.Visible; + + // 硬币 + Coin = navData.Money == 0 ? "0.0" : navData.Money.ToString("F1"); + // B币 + Money = navData.Wallet.BcoinBalance == 0 ? "0.0" : navData.Wallet.BcoinBalance.ToString("F1"); + } + + //用户的关系状态数 + UserRelationStat relationStat = UserStatus.GetUserRelationStat(mid); + if (relationStat != null) + { + // 关注数 + StatusList[0].Subtitle = relationStat.Following.ToString(); + // 悄悄关注数 + StatusList[1].Subtitle = relationStat.Whisper.ToString(); + // 粉丝数 + StatusList[2].Subtitle = relationStat.Follower.ToString(); + // 黑名单数 + StatusList[3].Subtitle = relationStat.Black.ToString(); + } + }); + } /// @@ -34,6 +583,9 @@ namespace DownKyi.ViewModels return; } mid = parameter; + + InitView(); + UpdateSpaceInfo(); } } diff --git a/DownKyi/ViewModels/ViewVideoDetailViewModel.cs b/DownKyi/ViewModels/ViewVideoDetailViewModel.cs index 11486e3..3937afb 100644 --- a/DownKyi/ViewModels/ViewVideoDetailViewModel.cs +++ b/DownKyi/ViewModels/ViewVideoDetailViewModel.cs @@ -114,6 +114,7 @@ namespace DownKyi.ViewModels #region 属性初始化 + // 初始化loading gif Loading = new GifImage(Properties.Resources.loading); Loading.StartAnimate(); LoadingVisibility = Visibility.Collapsed; diff --git a/DownKyi/Views/ViewMySpace.xaml b/DownKyi/Views/ViewMySpace.xaml index 6f40d3f..9bb24d7 100644 --- a/DownKyi/Views/ViewMySpace.xaml +++ b/DownKyi/Views/ViewMySpace.xaml @@ -2,9 +2,422 @@ x:Class="DownKyi.Views.ViewMySpace" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:i="http://schemas.microsoft.com/xaml/behaviors" xmlns:prism="http://prismlibrary.com/" prism:ViewModelLocator.AutoWireViewModel="True"> + + + + - 我的用户空间 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +