From 0fa28611d0f1eed2b012332cbbd3c36b76ad0fa5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A7=9A=E5=BD=AA?= <1315508912@qq.com> Date: Mon, 18 Dec 2023 22:57:23 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=8F=91=E5=B8=83?= =?UTF-8?q?=E5=9C=A8macOS=E5=92=8Clinux=E4=B8=8A=E7=9A=84=E4=B8=80?= =?UTF-8?q?=E4=BA=9B=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DownKyi.Core/DownKyi.Core.csproj | 3 -- .../FFmpegHelper.cs => FFMpeg/FFMpeg.cs} | 28 ++++++++++++++----- .../Settings/SettingsManager.Video.cs | 18 ++++++++++-- DownKyi.Core/Storage/Constant.cs | 3 ++ DownKyi.Core/Storage/StorageManager.cs | 8 +++++- DownKyi.Core/ffmpeg.config.json | 3 -- DownKyi/App.axaml | 8 +++--- DownKyi/CustomControl/CustomPagerViewModel.cs | 2 +- DownKyi/Services/Download/DownloadService.cs | 6 ++-- .../ViewModels/Settings/ViewAboutViewModel.cs | 2 +- .../ViewModels/Toolbox/ViewDelogoViewModel.cs | 7 ++--- .../Toolbox/ViewExtractMediaViewModel.cs | 6 ++-- DownKyi/Views/Settings/ViewAbout.axaml | 7 +++++ DownKyi/Views/Settings/ViewNetwork.axaml | 17 ++++++----- .../Views/UserSpace/ViewSeasonsSeries.axaml | 7 ++--- DownKyi/Views/ViewSettings.axaml | 7 +++-- README.md | 8 ++++-- 17 files changed, 87 insertions(+), 53 deletions(-) rename DownKyi.Core/{FFmpeg/FFmpegHelper.cs => FFMpeg/FFMpeg.cs} (79%) delete mode 100644 DownKyi.Core/ffmpeg.config.json diff --git a/DownKyi.Core/DownKyi.Core.csproj b/DownKyi.Core/DownKyi.Core.csproj index 6b38c0d..db2b902 100644 --- a/DownKyi.Core/DownKyi.Core.csproj +++ b/DownKyi.Core/DownKyi.Core.csproj @@ -23,9 +23,6 @@ - - PreserveNewest - PreserveNewest diff --git a/DownKyi.Core/FFmpeg/FFmpegHelper.cs b/DownKyi.Core/FFMpeg/FFMpeg.cs similarity index 79% rename from DownKyi.Core/FFmpeg/FFmpegHelper.cs rename to DownKyi.Core/FFMpeg/FFMpeg.cs index da3a3d7..6fa6a87 100644 --- a/DownKyi.Core/FFmpeg/FFmpegHelper.cs +++ b/DownKyi.Core/FFMpeg/FFMpeg.cs @@ -1,12 +1,27 @@ using DownKyi.Core.Logging; using FFMpegCore; using FFMpegCore.Enums; +using FFMpegCore.Helpers; -namespace DownKyi.Core.FFmpeg; +namespace DownKyi.Core.FFMpeg; -public static class FFmpegHelper +public class FFMpeg { private const string Tag = "FFmpegHelper"; + private static readonly FFMpeg instance = new(); + + static FFMpeg() + { + } + + private FFMpeg() + { + GlobalFFOptions.Configure(new FFOptions + { BinaryFolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ffmpeg") }); + FFMpegHelper.VerifyFFMpegExists(GlobalFFOptions.Current); + } + + public static FFMpeg Instance => instance; /// /// 合并音频和视频 @@ -14,7 +29,7 @@ public static class FFmpegHelper /// 音频 /// 视频 /// - public static bool MergeVideo(string audio, string video, string destVideo) + public bool MergeVideo(string audio, string video, string destVideo) { if (!File.Exists(audio) && !File.Exists(video)) return false; FFMpegArguments @@ -56,8 +71,7 @@ public static class FFmpegHelper /// /// /// - public static void Delogo(string video, string destVideo, int x, int y, int width, int height, - Action action) + public void Delogo(string video, string destVideo, int x, int y, int width, int height, Action action) { var arg = FFMpegArguments .FromFileInput(video) @@ -77,7 +91,7 @@ public static class FFmpegHelper /// 源视频 /// 目标音频 /// 输出信息 - public static void ExtractAudio(string video, string audio, Action action) + public void ExtractAudio(string video, string audio, Action action) { FFMpegArguments .FromFileInput(video) @@ -99,7 +113,7 @@ public static class FFmpegHelper /// 源视频 /// 目标视频 /// 输出信息 - public static void ExtractVideo(string video, string destVideo, Action action) + public void ExtractVideo(string video, string destVideo, Action action) { FFMpegArguments.FromFileInput(video) .OutputToFile( diff --git a/DownKyi.Core/Settings/SettingsManager.Video.cs b/DownKyi.Core/Settings/SettingsManager.Video.cs index 0f63c5e..6c178f3 100644 --- a/DownKyi.Core/Settings/SettingsManager.Video.cs +++ b/DownKyi.Core/Settings/SettingsManager.Video.cs @@ -1,5 +1,6 @@ using DownKyi.Core.FileName; using DownKyi.Core.Settings.Models; +using DownKyi.Core.Storage; namespace DownKyi.Core.Settings; @@ -18,7 +19,7 @@ public partial class SettingsManager private readonly AllowStatus isTranscodingFlvToMp4 = AllowStatus.YES; // 默认下载目录 - private readonly string saveVideoRootPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Media"); + private readonly string saveVideoRootPath = StorageManager.GetMedia(); // 历史下载目录 private readonly List historyVideoRootPaths = new(); @@ -64,6 +65,7 @@ public partial class SettingsManager SetVideoCodecs(videoCodecs); return videoCodecs; } + return appSettings.Video.VideoCodecs; } @@ -91,6 +93,7 @@ public partial class SettingsManager SetQuality(quality); return quality; } + return appSettings.Video.Quality; } @@ -118,6 +121,7 @@ public partial class SettingsManager SetAudioQuality(audioQuality); return audioQuality; } + return appSettings.Video.AudioQuality; } @@ -145,6 +149,7 @@ public partial class SettingsManager IsTranscodingFlvToMp4(isTranscodingFlvToMp4); return isTranscodingFlvToMp4; } + return appSettings.Video.IsTranscodingFlvToMp4; } @@ -172,6 +177,7 @@ public partial class SettingsManager SetSaveVideoRootPath(saveVideoRootPath); return saveVideoRootPath; } + return appSettings.Video.SaveVideoRootPath; } @@ -199,6 +205,7 @@ public partial class SettingsManager SetHistoryVideoRootPaths(historyVideoRootPaths); return historyVideoRootPaths; } + return appSettings.Video.HistoryVideoRootPaths; } @@ -226,6 +233,7 @@ public partial class SettingsManager IsUseSaveVideoRootPath(isUseSaveVideoRootPath); return isUseSaveVideoRootPath; } + return appSettings.Video.IsUseSaveVideoRootPath; } @@ -253,6 +261,7 @@ public partial class SettingsManager SetVideoContent(videoContent); return videoContent; } + return appSettings.Video.VideoContent; } @@ -280,6 +289,7 @@ public partial class SettingsManager SetFileNameParts(fileNameParts); return fileNameParts; } + return appSettings.Video.FileNameParts; } @@ -301,12 +311,14 @@ public partial class SettingsManager public string GetFileNamePartTimeFormat() { appSettings = GetSettings(); - if (appSettings.Video.FileNamePartTimeFormat == null || appSettings.Video.FileNamePartTimeFormat == string.Empty) + if (appSettings.Video.FileNamePartTimeFormat == null || + appSettings.Video.FileNamePartTimeFormat == string.Empty) { // 第一次获取,先设置默认值 SetFileNamePartTimeFormat(fileNamePartTimeFormat); return fileNamePartTimeFormat; } + return appSettings.Video.FileNamePartTimeFormat; } @@ -334,6 +346,7 @@ public partial class SettingsManager SetOrderFormat(orderFormat); return orderFormat; } + return appSettings.Video.OrderFormat; } @@ -347,5 +360,4 @@ public partial class SettingsManager appSettings.Video.OrderFormat = orderFormat; return SetSettings(); } - } \ No newline at end of file diff --git a/DownKyi.Core/Storage/Constant.cs b/DownKyi.Core/Storage/Constant.cs index f2bfe3b..a7d0cbf 100644 --- a/DownKyi.Core/Storage/Constant.cs +++ b/DownKyi.Core/Storage/Constant.cs @@ -86,4 +86,7 @@ internal static class Constant // 用户头像文件索引 public static string HeaderIndex { get; } = $"{Header}/Index.db"; + + // 下载 + public static string Media { get; } = $"{Root}/Media"; } \ No newline at end of file diff --git a/DownKyi.Core/Storage/StorageManager.cs b/DownKyi.Core/Storage/StorageManager.cs index 3407ec9..f425c2f 100644 --- a/DownKyi.Core/Storage/StorageManager.cs +++ b/DownKyi.Core/Storage/StorageManager.cs @@ -11,7 +11,7 @@ public static class StorageManager CreateDirectory(Constant.Aria); return Constant.Aria; } - + /// /// 获取日志的文件路径 /// @@ -146,6 +146,12 @@ public static class StorageManager return Constant.HeaderIndex; } + public static string GetMedia() + { + CreateDirectory(Constant.Media); + return Constant.Media; + } + /// /// 若文件夹不存在,则创建文件夹 diff --git a/DownKyi.Core/ffmpeg.config.json b/DownKyi.Core/ffmpeg.config.json deleted file mode 100644 index 9631df7..0000000 --- a/DownKyi.Core/ffmpeg.config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "BinaryFolder": "./ffmpeg" -} \ No newline at end of file diff --git a/DownKyi/App.axaml b/DownKyi/App.axaml index 082f8ce..74e4844 100644 --- a/DownKyi/App.axaml +++ b/DownKyi/App.axaml @@ -29,10 +29,10 @@ Padding="5,0,5,0" Background="White" Margin="5,0,0,0"> - + Foreground="{TemplateBinding Foreground}" /> - + - + + SelectedIndex="{Binding SelectTabId}" + Theme="{StaticResource LeftTabHeaderStyle}"> + CommandParameter="{Binding ElementName=NameLeftTabHeaders,Path=SelectedItem}" /> diff --git a/README.md b/README.md index d6d51b2..90f7216 100644 --- a/README.md +++ b/README.md @@ -5,12 +5,14 @@ - 基于[哔哩下载姬Windows版](https://github.com/leiurayer/downkyi)和[Avalonia UI](https://github.com/AvaloniaUI/Avalonia)制作的跨平台版本(支持Windows、linux、macOS)。 - 开发这个版本目的是由于本人日常使用macOS,当我想下载up视频是偶然间发现了[哔哩下载姬Windows版](https://github.com/leiurayer/downkyi),发现很好用,就是不能支持macOS使用,就想看能不能基于跨平台方案重新开发。 - ## 使用说明 -- 需要.net 6及以上运行环境 +- 软件自带.NET6、ffmpeg、aria2运行环境、无需自行安装 +- 默认下载路径: + - Windows: 软件运行目录下的Media文件夹 + - macOS: ~/Library/Application Support/DownKyi/Media + - linux: ~/.config/DownKyi/Media ## 免责申明 - 1. 本软件只提供视频解析,不提供任何资源上传、存储到服务器的功能。 2. 本软件仅解析来自B站的内容,不会对解析到的音视频进行二次编码,部分视频会进行有限的格式转换、拼接等操作。 3. 本软件解析得到的所有内容均来自B站UP主上传、分享,其版权均归原作者所有。内容提供者、上传者(UP主)应对其提供、上传的内容承担全部责任。