From d43276413817e8770e56c5fbb9340bbdeda1705d Mon Sep 17 00:00:00 2001 From: ywmoyue Date: Tue, 26 Dec 2023 12:36:43 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E4=B8=B4=E6=97=B6=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E9=99=90=E5=88=B6=E5=9C=B0=E5=8C=BA=E7=95=AA=E5=89=A7=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E6=89=93=E5=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BiliLite.UWP/Models/Requests/Api/SeasonApi.cs | 2 +- .../ViewModels/Season/SeasonDetailPageViewModel.cs | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/BiliLite.UWP/Models/Requests/Api/SeasonApi.cs b/src/BiliLite.UWP/Models/Requests/Api/SeasonApi.cs index fd4b2592..a05668e0 100644 --- a/src/BiliLite.UWP/Models/Requests/Api/SeasonApi.cs +++ b/src/BiliLite.UWP/Models/Requests/Api/SeasonApi.cs @@ -13,7 +13,7 @@ public ApiModel Detail(string season_id, bool proxy = false) var api = new ApiModel() { method = RestSharp.Method.Get, - baseUrl = $"{baseUrl}/pgc/view/app/season", + baseUrl = $"{baseUrl}/pgc/view/v2/app/season", parameter = ApiHelper.MustParameter(AppKey, true) + $"&season_id={season_id}" }; api.parameter += ApiHelper.GetSign(api.parameter, AppKey); diff --git a/src/BiliLite.UWP/ViewModels/Season/SeasonDetailPageViewModel.cs b/src/BiliLite.UWP/ViewModels/Season/SeasonDetailPageViewModel.cs index e1ede4fd..54b7479a 100644 --- a/src/BiliLite.UWP/ViewModels/Season/SeasonDetailPageViewModel.cs +++ b/src/BiliLite.UWP/ViewModels/Season/SeasonDetailPageViewModel.cs @@ -157,7 +157,13 @@ public async Task LoadSeasonDetail(string seasonId) } //通过代理访问番剧详情 - var data = await results.GetJson>(); + var apiData = await results.GetJson>(); + var data = new ApiResultModel(); + data.code=apiData.code; + data.message = apiData.message; + data.result = apiData.data; + + //var data = await results.GetJson>(); //代理访问失败,使用Web的Api访问 if (!data.success) { From 45df8082e0c75bb645eb051fd58127ca4e597f50 Mon Sep 17 00:00:00 2001 From: GD-Slime <82302542+GD-Slime@users.noreply.github.com> Date: Wed, 27 Dec 2023 20:24:54 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E6=95=B4=E7=90=86=E6=B8=AF=E6=BE=B3?= =?UTF-8?q?=E5=8F=B0=E7=95=AA=E5=89=A7=E6=92=AD=E6=94=BE=20(#459)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复限制地区番剧访问 --- .../Models/Requests/Api/SeasonApi.cs | 11 --- .../Season/SeasonDetailPageViewModel.cs | 99 +++++-------------- 2 files changed, 26 insertions(+), 84 deletions(-) diff --git a/src/BiliLite.UWP/Models/Requests/Api/SeasonApi.cs b/src/BiliLite.UWP/Models/Requests/Api/SeasonApi.cs index a05668e0..247b6ed1 100644 --- a/src/BiliLite.UWP/Models/Requests/Api/SeasonApi.cs +++ b/src/BiliLite.UWP/Models/Requests/Api/SeasonApi.cs @@ -20,17 +20,6 @@ public ApiModel Detail(string season_id, bool proxy = false) return api; } - public ApiModel DetailWeb(string season_id) - { - var api = new ApiModel() - { - method = RestSharp.Method.Get, - baseUrl = $"https://bangumi.bilibili.com/view/web_api/season", - parameter = $"season_id={season_id}" - }; - - return api; - } /// /// 短评 /// diff --git a/src/BiliLite.UWP/ViewModels/Season/SeasonDetailPageViewModel.cs b/src/BiliLite.UWP/ViewModels/Season/SeasonDetailPageViewModel.cs index 54b7479a..4bd0df62 100644 --- a/src/BiliLite.UWP/ViewModels/Season/SeasonDetailPageViewModel.cs +++ b/src/BiliLite.UWP/ViewModels/Season/SeasonDetailPageViewModel.cs @@ -29,6 +29,7 @@ public class SeasonDetailPageViewModel : BaseViewModel private readonly PlayerAPI m_playerApi; private readonly FollowAPI m_followApi; private readonly IMapper m_mapper; + private static readonly ILogger _logger = GlobalLogger.FromCurrentType(); #endregion @@ -156,75 +157,56 @@ public async Task LoadSeasonDetail(string seasonId) throw new CustomizedErrorException(results.message); } - //通过代理访问番剧详情 - var apiData = await results.GetJson>(); - var data = new ApiResultModel(); - data.code=apiData.code; - data.message = apiData.message; - data.result = apiData.data; - - //var data = await results.GetJson>(); - //代理访问失败,使用Web的Api访问 - if (!data.success) - { - data = await GetWebSeasonDetail(seasonId); - } + //访问番剧详情 + var data = await results.GetJson>(); if (!data.success) { throw new CustomizedErrorException(data.message); } - if (data.result.Limit != null) + try { - var reulstsWeb = await m_seasonApi.DetailWeb(seasonId).Request(); - if (reulstsWeb.status) + //build 75900200 + data.data.Episodes = JsonConvert.DeserializeObject>( + data.data.Modules.FirstOrDefault(x => x["style"].ToString() == "positive")?["data"]?["episodes"] + ?.ToString() ?? "[]"); + data.data.Seasons = JsonConvert.DeserializeObject>( + data.data.Modules.FirstOrDefault(x => x["style"].ToString() == "season")?["data"]?["seasons"] + ?.ToString() ?? "[]"); + var pv = JsonConvert.DeserializeObject>( + data.data.Modules.FirstOrDefault(x => x["style"].ToString() == "section")?["data"]?["episodes"] + ?.ToString() ?? "[]"); + foreach (var item in pv) { - var data_2 = reulstsWeb.GetJObject(); - if (data_2["code"].ToInt32() == 0) - { - data.result.Episodes = await data_2["result"]["episodes"].ToString().DeserializeJson>(); - } + item.SectionType = 1; + data.data.Episodes.Add(item); } } - else + catch (Exception ex) { - try - { - //build 6235200 - data.result.Episodes = JsonConvert.DeserializeObject>(data.result.Modules.FirstOrDefault(x => x["style"].ToString() == "positive")?["data"]?["episodes"]?.ToString() ?? "[]"); - data.result.Seasons = JsonConvert.DeserializeObject>(data.result.Modules.FirstOrDefault(x => x["style"].ToString() == "season")?["data"]?["seasons"]?.ToString() ?? "[]"); - var pv = JsonConvert.DeserializeObject>(data.result.Modules.FirstOrDefault(x => x["style"].ToString() == "section")?["data"]?["episodes"]?.ToString() ?? "[]"); - foreach (var item in pv) - { - item.SectionType = 1; - data.result.Episodes.Add(item); - } - } - catch (Exception) - { - } + _logger.Warn("解析番剧相关数据失败", ex); } - if (data.result.Section != null) + if (data.data.Section != null) { - foreach (var item in data.result.Section) + foreach (var item in data.data.Section) { foreach (var item2 in item.Episodes) { item2.SectionType = 1; } - data.result.Episodes.InsertRange(0, item.Episodes); - //data.result.episodes= data.result.episodes.Concat(item.episodes).ToList(); + data.data.Episodes.InsertRange(0, item.Episodes); + //data.data.episodes= data.data.episodes.Concat(item.episodes).ToList(); } } - var seasonDetail = m_mapper.Map(data.result); + var seasonDetail = m_mapper.Map(data.data); Detail = seasonDetail; - Episodes = data.result.Episodes.Where(x => !x.IsPreview).ToList(); + Episodes = data.data.Episodes.Where(x => !x.IsPreview).ToList(); ShowEpisodes = Episodes.Count > 0; - Previews = data.result.Episodes.Where(x => x.IsPreview).ToList(); + Previews = data.data.Episodes.Where(x => x.IsPreview).ToList(); ShowPreview = Previews.Count > 0; NothingPlay = !ShowEpisodes && !ShowPreview; Loaded = true; @@ -242,35 +224,6 @@ public async Task LoadSeasonDetail(string seasonId) } } - public async Task> GetWebSeasonDetail(string seasonId) - { - var reulsts_web = await m_seasonApi.DetailWeb(seasonId).Request(); - if (!reulsts_web.status) - return new ApiResultModel() - { - code = -101, - message = "无法读取内容" - }; - var data = reulsts_web.GetJObject(); - if (data["code"].ToInt32() != 0) - return new ApiResultModel() - { - code = -101, - message = "无法读取内容" - }; - var objText = data["result"].ToString(); - //处理下会出错的字段 - objText = objText.Replace("\"staff\"", "staff1"); - var model = JsonConvert.DeserializeObject(objText); - model.Episodes = await data["result"]["episodes"].ToString().DeserializeJson>(); - model.UserStatus = new SeasonDetailUserStatusModel() - { - FollowStatus = 0, - Follow = 0 - }; - return new ApiResultModel() { code = 0, message = "", result = model, }; - } - public async void DoFollow() { if (!SettingService.Account.Logined && !await Notify.ShowLoginDialog()) From ae64a1d43b0cba8f0531b1358fe925bc1f89cc5e Mon Sep 17 00:00:00 2001 From: ywmoyue Date: Wed, 27 Dec 2023 20:52:33 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=95=AA=E5=89=A7?= =?UTF-8?q?=E8=AF=A6=E6=83=85=E9=A1=B5=E6=96=87=E5=AD=97=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BiliLite.UWP/Pages/SeasonDetailPage.xaml | 6 +++--- src/BiliLite.UWP/ViewModels/Season/SeasonDetailViewModel.cs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/BiliLite.UWP/Pages/SeasonDetailPage.xaml b/src/BiliLite.UWP/Pages/SeasonDetailPage.xaml index 4e13c04d..20315935 100644 --- a/src/BiliLite.UWP/Pages/SeasonDetailPage.xaml +++ b/src/BiliLite.UWP/Pages/SeasonDetailPage.xaml @@ -18,7 +18,7 @@ - + @@ -192,7 +192,7 @@ - + diff --git a/src/BiliLite.UWP/ViewModels/Season/SeasonDetailViewModel.cs b/src/BiliLite.UWP/ViewModels/Season/SeasonDetailViewModel.cs index fbd67d2e..d12b54bc 100644 --- a/src/BiliLite.UWP/ViewModels/Season/SeasonDetailViewModel.cs +++ b/src/BiliLite.UWP/ViewModels/Season/SeasonDetailViewModel.cs @@ -118,6 +118,6 @@ public SeasonDetailSeasonItemModel CurrentSeason public SeasonDetailPaymentModel Payment { get; set; } [JsonProperty("show_payment")] - public bool ShowPayment => Payment is { Dialog: { } }; + public bool ShowPayment => Payment?.Dialog?.Title != null; } } \ No newline at end of file From f108efeca88317b0def2063b9176694178b7a615 Mon Sep 17 00:00:00 2001 From: GD-Slime <82302542+GD-Slime@users.noreply.github.com> Date: Mon, 1 Jan 2024 10:32:12 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86=E4=B8=AA?= =?UTF-8?q?=E4=BA=BA=E4=B8=BB=E9=A1=B5=E6=90=9C=E7=B4=A2=E8=A7=86=E9=A2=91?= =?UTF-8?q?=E4=B8=BA=E7=A9=BA=E6=97=B6=E7=9A=84=E6=8A=A5=E9=94=99=E5=8F=8D?= =?UTF-8?q?=E9=A6=88=20(#457)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复个人主页搜索视频为空时的报错反馈 --- src/BiliLite.UWP/BiliLite.UWP.csproj | 3 ++- .../Models/Exceptions/NotFoundException.cs | 11 ++++++++ src/BiliLite.UWP/Services/GrpcService.cs | 6 +++++ .../User/UserSubmitVideoViewModel.cs | 25 +++++++++++-------- 4 files changed, 33 insertions(+), 12 deletions(-) create mode 100644 src/BiliLite.UWP/Models/Exceptions/NotFoundException.cs diff --git a/src/BiliLite.UWP/BiliLite.UWP.csproj b/src/BiliLite.UWP/BiliLite.UWP.csproj index b11cf3a7..ed2dbce8 100644 --- a/src/BiliLite.UWP/BiliLite.UWP.csproj +++ b/src/BiliLite.UWP/BiliLite.UWP.csproj @@ -185,6 +185,7 @@ + @@ -1287,4 +1288,4 @@ --> - \ No newline at end of file + diff --git a/src/BiliLite.UWP/Models/Exceptions/NotFoundException.cs b/src/BiliLite.UWP/Models/Exceptions/NotFoundException.cs new file mode 100644 index 00000000..bfbca802 --- /dev/null +++ b/src/BiliLite.UWP/Models/Exceptions/NotFoundException.cs @@ -0,0 +1,11 @@ +using System; + +namespace BiliLite.Models.Exceptions +{ + public class NotFoundException : Exception + { + public NotFoundException(string msg) : base(msg) + { + } + } +} diff --git a/src/BiliLite.UWP/Services/GrpcService.cs b/src/BiliLite.UWP/Services/GrpcService.cs index 97d11b57..4c0d6fcb 100644 --- a/src/BiliLite.UWP/Services/GrpcService.cs +++ b/src/BiliLite.UWP/Services/GrpcService.cs @@ -3,6 +3,7 @@ using Bilibili.App.Dynamic.V2; using Bilibili.App.Interface.V1; using BiliLite.gRPC.Api; +using BiliLite.Models.Exceptions; namespace BiliLite.Services { @@ -24,6 +25,11 @@ public async Task SearchSpaceArchive(string mid, int page = { var reply = SearchArchiveReply.Parser.ParseFrom(result.results); return reply; + } + // 用户搜索一个不存在的关键字导致的 + else if (result.code == -102 && result.message == "请求失败,没有数据返回") + { + throw new NotFoundException(result.message); } else { diff --git a/src/BiliLite.UWP/ViewModels/User/UserSubmitVideoViewModel.cs b/src/BiliLite.UWP/ViewModels/User/UserSubmitVideoViewModel.cs index 80777dc0..beb90779 100644 --- a/src/BiliLite.UWP/ViewModels/User/UserSubmitVideoViewModel.cs +++ b/src/BiliLite.UWP/ViewModels/User/UserSubmitVideoViewModel.cs @@ -141,13 +141,15 @@ public async Task GetSubmitVideo() LoadingSubmitVideo = true; if (string.IsNullOrEmpty(Keyword)) { - var api = m_userDetailApi.SubmitVideosCursor(Mid, order: (SubmitVideoOrder)SelectOrder, cursor: m_lastAid); + var api = m_userDetailApi.SubmitVideosCursor(Mid, order: (SubmitVideoOrder)SelectOrder, + cursor: m_lastAid); CurrentTid = SelectTid.Tid; var results = await api.Request(); if (!results.status) { throw new CustomizedErrorException(results.message); } + var data = results.GetJObject(); if (data["code"].ToInt32() != 0) { @@ -164,18 +166,19 @@ public async Task GetSubmitVideo() AttachSubmitVideoItems(submitVideoItems, (int)searchArchive.Total); } } + catch (CustomizedErrorException ex) + { + Notify.ShowMessageToast(ex.Message); + _logger.Error("获取用户投稿失败", ex); + } + catch (NotFoundException ex) + { + Notify.ShowMessageToast("(っ °Д °;)っ 没有找到相应的视频~"); + } catch (Exception ex) { - if (ex is CustomizedErrorException) - { - Notify.ShowMessageToast(ex.Message); - } - else - { - var handel = HandelError(ex); - Notify.ShowMessageToast(handel.message); - } - + var handel = HandelError(ex); + Notify.ShowMessageToast(handel.message); _logger.Error("获取用户投稿失败", ex); } finally