From aed8ea9c67433abf3b800976f49658c442068b87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=AB=E8=B0=B7=E5=89=91=E4=BB=99?= Date: Tue, 6 Aug 2024 15:21:20 +0800 Subject: [PATCH] =?UTF-8?q?=E9=81=BF=E5=85=8D=E5=90=8E=E7=BC=80=E8=BE=93?= =?UTF-8?q?=E5=85=A5=E7=A9=BA=E5=AD=97=E7=AC=A6=E4=B8=B2=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E5=9B=A0=E4=B8=BA=E6=96=87=E4=BB=B6=E8=A2=AB=E5=8D=A0=E7=94=A8?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E8=A6=86=E7=9B=96=E5=8E=9F=E5=A7=8B=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E7=9A=84=E6=83=85=E5=86=B5=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Audi MMI MP3 Cover Repair.csproj | 2 +- Audi MMI MP3 Cover Repair/Program.cs | 25 ++++++++++++++++--- .../Properties/launchSettings.json | 2 +- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/Audi MMI MP3 Cover Repair/Audi MMI MP3 Cover Repair.csproj b/Audi MMI MP3 Cover Repair/Audi MMI MP3 Cover Repair.csproj index 4b38c5a..f02a8fb 100644 --- a/Audi MMI MP3 Cover Repair/Audi MMI MP3 Cover Repair.csproj +++ b/Audi MMI MP3 Cover Repair/Audi MMI MP3 Cover Repair.csproj @@ -7,7 +7,7 @@ enable enable Properties\aodi.ico - 2.1.0 + 2.1.1 枫谷剑仙 Copyright © 2024 Mapaler 修复奥迪汽车多媒体平台 MP3 歌曲不能显示封面的问题 diff --git a/Audi MMI MP3 Cover Repair/Program.cs b/Audi MMI MP3 Cover Repair/Program.cs index 9a18242..4665adc 100644 --- a/Audi MMI MP3 Cover Repair/Program.cs +++ b/Audi MMI MP3 Cover Repair/Program.cs @@ -38,9 +38,10 @@ qualityOption.AddAlias("-q"); qualityOption.AddValidator(result => { - if (result.GetValueForOption(qualityOption) > 100) + byte quality = result.GetValueForOption(qualityOption); + if (quality > 100 || quality < 0) { - result.ErrorMessage = $"Must be less than 100{Environment.NewLine}必须小于100。"; + result.ErrorMessage = $"JPEG quality can only be between 1-100.{Environment.NewLine}JPEG 质量只能位于 1-100 之间。"; } }); @@ -60,6 +61,13 @@ name: "--postfix", description: $"The postfix of the new filename when same a new file. {Environment.NewLine}储存新文件时的后缀名。", getDefaultValue: () => "-id3"); +debugPostfixOption.AddValidator(result => +{ + if (result.GetValueForOption(saveModifiedAudioOption) && String.IsNullOrWhiteSpace(result.GetValueForOption(debugPostfixOption))) + { + result.ErrorMessage = $"When saving as a new file, you must have a filename postfix that is not empty.{Environment.NewLine}储存为新文件时必须拥有不为空的文件名后缀。"; + } +}); var rootCommand = new RootCommand($"Fixed the issue that the cover picture of MP3 songs on Audi car MMI could not be displayed, and all the pictures in MP3 files were reduced to no larger than {defaultLength}×{defaultLength}, and the position was adjusted to Cover-Front." + Environment.NewLine + $"修复奥迪汽车多媒体平台 MP3 歌曲不能显示封面的问题,将 MP3 文件的图片全部缩小到不大于 {defaultLength}×{defaultLength} ,位置调整到封面(Cover-Front)。"); @@ -205,13 +213,22 @@ static void ReadFile(FileInfo[] files, HandlerOptions aHandlerOptions) // 添加封面 theTrack.EmbeddedPictures.Add(newPicture); - if (saveModifiedAudio) + string newFilename; + + if (saveModifiedAudio && + (newFilename = Path.Combine(file.DirectoryName, $"{Path.GetFileNameWithoutExtension(file.Name)}{debugPostfixPicture}{file.Extension}")) != theTrack.Path) { +#if DEBUG + Console.WriteLine("储存到新文件 {0}", newFilename); +#endif //储存到新文件 - string newFilename = Path.Combine(file.DirectoryName, $"{Path.GetFileNameWithoutExtension(file.Name)}{debugPostfixPicture}{file.Extension}"); + //newFilename = Path.Combine(file.DirectoryName, $"{Path.GetFileNameWithoutExtension(file.Name)}{debugPostfixPicture}{file.Extension}"); theTrack.SaveTo(newFilename); } else { +#if DEBUG + Console.WriteLine("保存到原始文件"); +#endif //保存到原始文件 theTrack.Save(); } diff --git a/Audi MMI MP3 Cover Repair/Properties/launchSettings.json b/Audi MMI MP3 Cover Repair/Properties/launchSettings.json index f180756..e596541 100644 --- a/Audi MMI MP3 Cover Repair/Properties/launchSettings.json +++ b/Audi MMI MP3 Cover Repair/Properties/launchSettings.json @@ -2,7 +2,7 @@ "profiles": { "Audi MMI MP3 Cover Repair": { "commandName": "Project", - "commandLineArgs": "\"C:\\Users\\Mapaler\\Desktop\\あよ - 21世紀少女.mp3\"" + "commandLineArgs": "\"C:\\Users\\Mapaler\\Desktop\\あよ - 21世紀少女.mp3\" --postfix \"\"" } } } \ No newline at end of file