支持用户空间链接中mid在中间的情况(https://space.bilibili.com/27899754/channel/series)

croire 3 years ago
parent 8f6553d401
commit 67400b45bf

@ -368,9 +368,16 @@ namespace DownKyi.Core.BiliApi.BiliUtils
/// <returns></returns> /// <returns></returns>
public static bool IsUserUrl(string input) public static bool IsUserUrl(string input)
{ {
string baseUrl = $"{SpaceUrl}/"; if (!IsUrl(input)) { return false; }
string id = GetId(input, baseUrl);
return Number.IsInt(id); if (input.Contains("space.bilibili.com"))
{
return true;
}
else
{
return false;
}
} }
/// <summary> /// <summary>
@ -390,9 +397,17 @@ namespace DownKyi.Core.BiliApi.BiliUtils
} }
else if (IsUserUrl(input)) else if (IsUserUrl(input))
{ {
string baseUrl = $"{SpaceUrl}/"; string url = EnableHttps(input);
string id = GetId(input, baseUrl); url = DeleteUrlParam(url);
return Number.GetInt(id); var match = Regex.Match(url, @"\d+");
if (match.Success)
{
return long.Parse(match.Value);
}
else
{
return -1;
}
} }
else else
{ {

Loading…
Cancel
Save