From 199cd64a9e89b56a501239b2a2e66e82e03a0b67 Mon Sep 17 00:00:00 2001 From: Copy Liu Date: Sat, 21 May 2022 18:53:47 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=AF=BB=E6=89=BE=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E6=97=B6=E5=BD=93=E7=84=B6=E9=9C=80=E8=A6=81=E5=8C=85=E5=90=AB?= =?UTF-8?q?=E5=B7=A5=E4=BD=9C=E7=9B=AE=E5=BD=95.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BBDown/BBDownUtil.cs | 32 +++++--------------------------- 1 file changed, 5 insertions(+), 27 deletions(-) diff --git a/BBDown/BBDownUtil.cs b/BBDown/BBDownUtil.cs index 692bdef96..779eaef11 100644 --- a/BBDown/BBDownUtil.cs +++ b/BBDown/BBDownUtil.cs @@ -812,33 +812,11 @@ public static string GetMp4boxMetaString(List points) public static string FindExecutable(string name) { - if (OperatingSystem.IsWindows()) - { - var file = Path.Combine(Program.APP_DIR, name + ".exe"); - if (File.Exists(file)) - return file; - var path = Environment.GetEnvironmentVariable("PATH"); - foreach (var item in path.Split(';')) - { - file = Path.Combine(item, name + ".exe"); - if (File.Exists(file)) - return file; - } - } - else - { - var file = Path.Combine(Program.APP_DIR, name); - if (File.Exists(file)) - return file; - var path = Environment.GetEnvironmentVariable("PATH"); - foreach (var item in path.Split(':')) - { - file = Path.Combine(item, name); - if (File.Exists(file)) - return file; - } - } - return null; + var fileExt = OperatingSystem.IsWindows() ? ".exe" : ""; + var searchPath = new List() { Environment.CurrentDirectory, Program.APP_DIR }; + var envPath = Environment.GetEnvironmentVariable("PATH")?.Split(Path.PathSeparator) ?? + Array.Empty(); + return searchPath.Concat(envPath).Select(p => Path.Combine(p, name + fileExt)).FirstOrDefault(File.Exists); } public static async Task CheckLogin(string cookie) From 4b1ac2b1aa18a37a11752845cf566751691dd47a Mon Sep 17 00:00:00 2001 From: Copy Liu Date: Sat, 21 May 2022 19:00:07 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=90=B9=E6=AF=9B=E6=B1=82=E7=96=B5?= =?UTF-8?q?=E5=9C=B0=E5=8F=AF=E4=BB=A5=E7=94=A8Array=E7=9A=84=E5=9C=B0?= =?UTF-8?q?=E6=96=B9=E7=94=A8Array.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BBDown/BBDownUtil.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BBDown/BBDownUtil.cs b/BBDown/BBDownUtil.cs index 779eaef11..1471dbc1d 100644 --- a/BBDown/BBDownUtil.cs +++ b/BBDown/BBDownUtil.cs @@ -813,7 +813,7 @@ public static string GetMp4boxMetaString(List points) public static string FindExecutable(string name) { var fileExt = OperatingSystem.IsWindows() ? ".exe" : ""; - var searchPath = new List() { Environment.CurrentDirectory, Program.APP_DIR }; + var searchPath = new [] { Environment.CurrentDirectory, Program.APP_DIR }; var envPath = Environment.GetEnvironmentVariable("PATH")?.Split(Path.PathSeparator) ?? Array.Empty(); return searchPath.Concat(envPath).Select(p => Path.Combine(p, name + fileExt)).FirstOrDefault(File.Exists); From 40fd2cbdcf361b3eb23171eca038b304c047a374 Mon Sep 17 00:00:00 2001 From: Copy Liu Date: Sat, 21 May 2022 23:03:11 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=B7=A5=E5=85=B7=E8=B7=AF=E5=BE=84?= =?UTF-8?q?=E4=BB=A5=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6=E6=88=96=E6=8C=87?= =?UTF-8?q?=E5=AE=9A=E4=BD=8D=E7=BD=AE=E4=BC=98=E5=85=88,=20=E6=89=BE?= =?UTF-8?q?=E4=B8=8D=E5=88=B0=E6=97=B6=E5=86=8D=E5=AF=BB=E6=89=BE=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=E5=B7=A5=E5=85=B7.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BBDown/Program.cs | 53 +++++++++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 23 deletions(-) diff --git a/BBDown/Program.cs b/BBDown/Program.cs index ebc7af058..701c4b0a6 100644 --- a/BBDown/Program.cs +++ b/BBDown/Program.cs @@ -471,17 +471,34 @@ private static async Task DoWorkAsync(MyOption myOption) LogDebug("切换工作目录至:{0}", dir); } + if (!string.IsNullOrEmpty(myOption.FFmpegPath) && File.Exists(myOption.FFmpegPath)) + { + BBDownMuxer.FFMPEG = myOption.FFmpegPath; + } + + if (!string.IsNullOrEmpty(myOption.Mp4boxPath) && File.Exists(myOption.Mp4boxPath)) + { + BBDownMuxer.MP4BOX = myOption.Mp4boxPath; + } + + if (!string.IsNullOrEmpty(myOption.Aria2cPath) && File.Exists(myOption.Aria2cPath)) + { + BBDownAria2c.ARIA2C = myOption.Aria2cPath; + } //寻找ffmpeg或mp4box if (!skipMux) { if (useMp4box) { - var binPath = FindExecutable("mp4box"); - if (string.IsNullOrEmpty(binPath)) - throw new Exception("找不到可执行的mp4box文件"); - BBDownMuxer.MP4BOX = binPath; + if (string.IsNullOrEmpty(BBDownMuxer.MP4BOX)) + { + var binPath = FindExecutable("mp4box"); + if (string.IsNullOrEmpty(binPath)) + throw new Exception("找不到可执行的mp4box文件"); + BBDownMuxer.MP4BOX = binPath; + } } - else + else if (string.IsNullOrEmpty(BBDownMuxer.FFMPEG)) { var binPath = FindExecutable("ffmpeg"); if (string.IsNullOrEmpty(binPath)) @@ -493,26 +510,16 @@ private static async Task DoWorkAsync(MyOption myOption) //寻找aria2c if (useAria2c) { - var binPath = FindExecutable("aria2c"); - if (string.IsNullOrEmpty(binPath)) - throw new Exception("找不到可执行的aria2c文件"); - BBDownAria2c.ARIA2C = binPath; - } - - if (!string.IsNullOrEmpty(myOption.FFmpegPath) && File.Exists(myOption.FFmpegPath)) - { - BBDownMuxer.FFMPEG = myOption.FFmpegPath; - } - - if (!string.IsNullOrEmpty(myOption.Mp4boxPath) && File.Exists(myOption.Mp4boxPath)) - { - BBDownMuxer.MP4BOX = myOption.Mp4boxPath; + if (string.IsNullOrEmpty(BBDownAria2c.ARIA2C)) + { + var binPath = FindExecutable("aria2c"); + if (string.IsNullOrEmpty(binPath)) + throw new Exception("找不到可执行的aria2c文件"); + BBDownAria2c.ARIA2C = binPath; + } + } - if (!string.IsNullOrEmpty(myOption.Aria2cPath) && File.Exists(myOption.Aria2cPath)) - { - BBDownAria2c.ARIA2C = myOption.Aria2cPath; - } //audioOnly和videoOnly同时开启则全部忽视 if (audioOnly && videoOnly)