diff --git a/BBDown.Core/Parser.cs b/BBDown.Core/Parser.cs index c0310c349..f79ba1cd5 100644 --- a/BBDown.Core/Parser.cs +++ b/BBDown.Core/Parser.cs @@ -85,6 +85,7 @@ private static async Task GetPlayJsonAsync(string aid, string cid, strin paramBuilder.Append($"&cid={cid}&ep_id={epId}&platform=android&prefer_code_type={code}&qn={qn}"); if (isBiliPlus) paramBuilder.Append($"&ts={GetTimeStamp(true)}"); + paramBuilder.Append("&s_locale=zh_SG"); string param = paramBuilder.ToString(); api += (isBiliPlus ? $"{param}&sign={GetSign(param, true)}" : param); diff --git a/BBDown.Core/Util/HTTPUtil.cs b/BBDown.Core/Util/HTTPUtil.cs index a6d42e53e..3a30a4d04 100644 --- a/BBDown.Core/Util/HTTPUtil.cs +++ b/BBDown.Core/Util/HTTPUtil.cs @@ -34,14 +34,16 @@ private static string GetRandomUserAgent() public static string UserAgent { get; set; } = GetRandomUserAgent(); - public static async Task GetWebSourceAsync(string url) + public static async Task GetWebSourceAsync(string url, string? userAgent = null) { using var webRequest = new HttpRequestMessage(HttpMethod.Get, url); - webRequest.Headers.TryAddWithoutValidation("User-Agent", UserAgent); + webRequest.Headers.TryAddWithoutValidation("User-Agent", userAgent ?? UserAgent); webRequest.Headers.TryAddWithoutValidation("Accept-Encoding", "gzip, deflate"); webRequest.Headers.TryAddWithoutValidation("Cookie", (url.Contains("/ep") || url.Contains("/ss")) ? Config.COOKIE + ";CURRENT_FNVAL=4048;" : Config.COOKIE); if (url.Contains("api.bilibili.com")) webRequest.Headers.TryAddWithoutValidation("Referer", "https://www.bilibili.com/"); + if (url.Contains("api.bilibili.tv")) + webRequest.Headers.TryAddWithoutValidation("sec-ch-ua", "\"Google Chrome\";v=\"131\", \"Chromium\";v=\"131\", \"Not_A Brand\";v=\"24\""); webRequest.Headers.CacheControl = CacheControlHeaderValue.Parse("no-cache"); webRequest.Headers.Connection.Clear(); diff --git a/BBDown/BBDownMuxer.cs b/BBDown/BBDownMuxer.cs index b160c44fa..e2de00fd9 100644 --- a/BBDown/BBDownMuxer.cs +++ b/BBDown/BBDownMuxer.cs @@ -189,7 +189,7 @@ public static int MuxAV(bool useMp4box, string bvid, string videoPath, string au if (episodeId != "") argsBuilder.Append($"-metadata album=\"{title}\" "); if (pubTime != 0) argsBuilder.Append($"-metadata creation_time=\"{(DateTimeOffset.FromUnixTimeSeconds(pubTime).ToString("yyyy-MM-ddTHH:mm:ss.ffffffZ"))}\" "); } - argsBuilder.Append("-c copy "); + argsBuilder.Append("-c:v copy -c:a copy "); if (audioOnly && audioPath == "") argsBuilder.Append("-vn "); if (subs != null) argsBuilder.Append("-c:s mov_text "); // fix macOS hev1, see https://discussions.apple.com/thread/253081863?sortBy=rank diff --git a/BBDown/BBDownUtil.cs b/BBDown/BBDownUtil.cs index c8d2fc8fe..cde97eda9 100644 --- a/BBDown/BBDownUtil.cs +++ b/BBDown/BBDownUtil.cs @@ -582,13 +582,13 @@ public static async Task CheckLogin(string cookie) private static partial Regex EpRegex(); [GeneratedRegex("/ss(\\d+)")] private static partial Regex SsRegex(); - [GeneratedRegex("space\\.bilibili\\.com/(\\d+)")] + [GeneratedRegex(@"space\.bilibili\.com/(\d+)")] private static partial Regex UidRegex(); - [GeneratedRegex("global\\.bilibili\\.com/play/\\d+/(\\d+)")] + [GeneratedRegex(@"\.bilibili\.tv\/\w+\/play\/\d+\/(\d+)")] private static partial Regex GlobalEpRegex(); [GeneratedRegex("bangumi/media/(md\\d+)")] private static partial Regex BangumiMdRegex(); - [GeneratedRegex("window.__INITIAL_STATE__=([\\s\\S].*?);\\(function\\(\\)")] + [GeneratedRegex(@"window.__INITIAL_STATE__=([\s\S].*?);\(function\(\)")] private static partial Regex StateRegex(); [GeneratedRegex("md(\\d+)")] private static partial Regex MdRegex(); diff --git a/BBDown/Program.cs b/BBDown/Program.cs index b7933a429..62b6e26be 100644 --- a/BBDown/Program.cs +++ b/BBDown/Program.cs @@ -227,16 +227,14 @@ public static (Dictionary encodingPriority, Dictionary GetVideoInfoAsync(MyOption myOption, string aidOri, string input) { - Log("检测账号登录..."); - // 加载认证信息 LoadCredentials(myOption); // 检测是否登录了账号 - bool is_login = await CheckLogin(Config.COOKIE); - if (!myOption.UseIntlApi && !myOption.UseTvApi && Config.AREA == "") + if (myOption is { UseIntlApi: false, UseTvApi: false } && Config.AREA == "") { - if (!is_login) + Log("检测账号登录..."); + if (!await CheckLogin(Config.COOKIE)) { LogWarn("你尚未登录B站账号, 解析可能受到限制"); } @@ -288,7 +286,7 @@ public static (Dictionary encodingPriority, Dictionary