From 67400b45bfd8684f2ad4d06dca146f7973b4323d Mon Sep 17 00:00:00 2001 From: croire <1432593898@qq.com> Date: Sun, 13 Feb 2022 00:58:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E7=94=A8=E6=88=B7=E7=A9=BA?= =?UTF-8?q?=E9=97=B4=E9=93=BE=E6=8E=A5=E4=B8=ADmid=E5=9C=A8=E4=B8=AD?= =?UTF-8?q?=E9=97=B4=E7=9A=84=E6=83=85=E5=86=B5=EF=BC=88https://space.bili?= =?UTF-8?q?bili.com/27899754/channel/series=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BiliApi/BiliUtils/ParseEntrance.cs | 27 ++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/DownKyi.Core/BiliApi/BiliUtils/ParseEntrance.cs b/DownKyi.Core/BiliApi/BiliUtils/ParseEntrance.cs index 8b71c8c..4b359c8 100644 --- a/DownKyi.Core/BiliApi/BiliUtils/ParseEntrance.cs +++ b/DownKyi.Core/BiliApi/BiliUtils/ParseEntrance.cs @@ -368,9 +368,16 @@ namespace DownKyi.Core.BiliApi.BiliUtils /// public static bool IsUserUrl(string input) { - string baseUrl = $"{SpaceUrl}/"; - string id = GetId(input, baseUrl); - return Number.IsInt(id); + if (!IsUrl(input)) { return false; } + + if (input.Contains("space.bilibili.com")) + { + return true; + } + else + { + return false; + } } /// @@ -390,9 +397,17 @@ namespace DownKyi.Core.BiliApi.BiliUtils } else if (IsUserUrl(input)) { - string baseUrl = $"{SpaceUrl}/"; - string id = GetId(input, baseUrl); - return Number.GetInt(id); + string url = EnableHttps(input); + url = DeleteUrlParam(url); + var match = Regex.Match(url, @"\d+"); + if (match.Success) + { + return long.Parse(match.Value); + } + else + { + return -1; + } } else {