fix: 修复发布在macOS和linux上的一些问题

This commit is contained in:
姚彪
2023-12-18 22:57:23 +08:00
parent ae38db96eb
commit 0fa28611d0
17 changed files with 87 additions and 53 deletions

View File

@@ -23,9 +23,6 @@
</ItemGroup>
<ItemGroup>
<None Update="ffmpeg.config.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Binary/$(RuntimeIdentifier)/aria2/*" Link="aria2/%(Filename)%(Extension)" Visible="false">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>

View File

@@ -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;
/// <summary>
/// 合并音频和视频
@@ -14,7 +29,7 @@ public static class FFmpegHelper
/// <param name="audio">音频</param>
/// <param name="video">视频</param>
/// <param name="destVideo"></param>
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
/// <param name="width"></param>
/// <param name="height"></param>
/// <param name="action"></param>
public static void Delogo(string video, string destVideo, int x, int y, int width, int height,
Action<string> action)
public void Delogo(string video, string destVideo, int x, int y, int width, int height, Action<string> action)
{
var arg = FFMpegArguments
.FromFileInput(video)
@@ -77,7 +91,7 @@ public static class FFmpegHelper
/// <param name="video">源视频</param>
/// <param name="audio">目标音频</param>
/// <param name="action">输出信息</param>
public static void ExtractAudio(string video, string audio, Action<string> action)
public void ExtractAudio(string video, string audio, Action<string> action)
{
FFMpegArguments
.FromFileInput(video)
@@ -99,7 +113,7 @@ public static class FFmpegHelper
/// <param name="video">源视频</param>
/// <param name="destVideo">目标视频</param>
/// <param name="action">输出信息</param>
public static void ExtractVideo(string video, string destVideo, Action<string> action)
public void ExtractVideo(string video, string destVideo, Action<string> action)
{
FFMpegArguments.FromFileInput(video)
.OutputToFile(

View File

@@ -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<string> 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();
}
}

View File

@@ -86,4 +86,7 @@ internal static class Constant
// 用户头像文件索引
public static string HeaderIndex { get; } = $"{Header}/Index.db";
// 下载
public static string Media { get; } = $"{Root}/Media";
}

View File

@@ -11,7 +11,7 @@ public static class StorageManager
CreateDirectory(Constant.Aria);
return Constant.Aria;
}
/// <summary>
/// 获取日志的文件路径
/// </summary>
@@ -146,6 +146,12 @@ public static class StorageManager
return Constant.HeaderIndex;
}
public static string GetMedia()
{
CreateDirectory(Constant.Media);
return Constant.Media;
}
/// <summary>
/// 若文件夹不存在,则创建文件夹

View File

@@ -1,3 +0,0 @@
{
"BinaryFolder": "./ffmpeg"
}

View File

@@ -29,10 +29,10 @@
Padding="5,0,5,0"
Background="White"
Margin="5,0,0,0">
<TextBlock
Text="{TemplateBinding Header}"
<TextBlock
Text="{TemplateBinding Header}"
FontSize="{TemplateBinding FontSize}"
Foreground="{TemplateBinding Foreground}"/>
Foreground="{TemplateBinding Foreground}" />
</Border>
<Border
Grid.RowSpan="2"
@@ -51,7 +51,7 @@
<TrayIcon.Icons>
<TrayIcons>
<TrayIcon Icon="/Resources/favicon.ico" ToolTipText="DownKyi">
<TrayIcon Icon="/Resources/favicon.ico" ToolTipText="{StaticResource AppName}">
<!--<TrayIcon.Menu>
<NativeMenu>
<NativeMenuItem Header="退出" />

View File

@@ -14,7 +14,7 @@ public class CustomPagerViewModel : INotifyPropertyChanged
SetView();
}
public event PropertyChangedEventHandler PropertyChanged;
public event PropertyChangedEventHandler? PropertyChanged;
// Current修改的回调
public delegate bool CurrentChangedHandler(int old, int current);

View File

@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Threading;
@@ -10,7 +9,7 @@ using DownKyi.Core.BiliApi.BiliUtils;
using DownKyi.Core.BiliApi.VideoStream;
using DownKyi.Core.BiliApi.VideoStream.Models;
using DownKyi.Core.Danmaku2Ass;
using DownKyi.Core.FFmpeg;
using DownKyi.Core.FFMpeg;
using DownKyi.Core.Logging;
using DownKyi.Core.Settings;
using DownKyi.Core.Storage;
@@ -19,7 +18,6 @@ using DownKyi.Images;
using DownKyi.Models;
using DownKyi.Utils;
using DownKyi.ViewModels.DownloadManager;
using Prism.Services.Dialogs;
using Console = DownKyi.Core.Utils.Debugging.Console;
namespace DownKyi.Services.Download;
@@ -320,7 +318,7 @@ public abstract class DownloadService
}
// 合并音视频
FFmpegHelper.MergeVideo(audioUid, videoUid, finalFile);
FFMpeg.Instance.MergeVideo(audioUid, videoUid, finalFile);
// 获取文件大小
if (File.Exists(finalFile))

View File

@@ -96,7 +96,7 @@ public class ViewAboutViewModel : ViewModelBase
/// </summary>
private void ExecuteAppNameCommand()
{
PlatformHelper.Open("https://github.com/yaobiao131/downkyicore/release");
PlatformHelper.Open("https://github.com/yaobiao131/downkyicore/releases");
}
// 检查更新事件

View File

@@ -1,7 +1,6 @@
using System;
using System.Threading.Tasks;
using System.Threading.Tasks;
using Avalonia.Controls;
using DownKyi.Core.FFmpeg;
using DownKyi.Core.FFMpeg;
using DownKyi.Events;
using DownKyi.Utils;
using Prism.Commands;
@@ -159,7 +158,7 @@ public class ViewDelogoViewModel : ViewModelBase
{
// 执行去水印程序
isDelogo = true;
FFmpegHelper.Delogo(VideoPath, newFileName, LogoX, LogoY, LogoWidth, LogoHeight, output =>
FFMpeg.Instance.Delogo(VideoPath, newFileName, LogoX, LogoY, LogoWidth, LogoHeight, output =>
{
Status += output + "\n";
});

View File

@@ -1,7 +1,7 @@
using System;
using System.Threading.Tasks;
using Avalonia.Controls;
using DownKyi.Core.FFmpeg;
using DownKyi.Core.FFMpeg;
using DownKyi.Events;
using DownKyi.Utils;
using Prism.Commands;
@@ -113,7 +113,7 @@ public class ViewExtractMediaViewModel : ViewModelBase
// 音频文件名
string audioFileName = item.Remove(item.Length - 4, 4) + ".aac";
// 执行提取音频程序
FFmpegHelper.ExtractAudio(item, audioFileName, output =>
FFMpeg.Instance.ExtractAudio(item, audioFileName, output =>
{
Status += output + "\n";
});
@@ -157,7 +157,7 @@ public class ViewExtractMediaViewModel : ViewModelBase
// 视频文件名
string videoFileName = item.Remove(item.Length - 4, 4) + "_onlyVideo.mp4";
// 执行提取视频程序
FFmpegHelper.ExtractVideo(item, videoFileName, new Action<string>((output) =>
FFMpeg.Instance.ExtractVideo(item, videoFileName, new Action<string>((output) =>
{
Status += output + "\n";
}));

View File

@@ -1,6 +1,8 @@
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="DownKyi.Views.Settings.ViewAbout"
xmlns:i="using:Avalonia.Xaml.Interactivity"
xmlns:ia="clr-namespace:Avalonia.Xaml.Interactions.Core;assembly=Avalonia.Xaml.Interactions"
xmlns:prism="http://prismlibrary.com/"
prism:ViewModelLocator.AutoWireViewModel="True"
xmlns:vms="clr-namespace:DownKyi.ViewModels.Settings"
@@ -40,6 +42,11 @@
FontSize="18"
Foreground="{DynamicResource BrushPrimary}"
Text="{Binding AppName}">
<i:Interaction.Behaviors>
<ia:EventTriggerBehavior EventName="PointerReleased">
<ia:InvokeCommandAction Command="{Binding AppNameCommand}" />
</ia:EventTriggerBehavior>
</i:Interaction.Behaviors>
</TextBlock>
</StackPanel>
<StackPanel Margin="0,20,0,0" Orientation="Horizontal">

View File

@@ -2,9 +2,9 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="DownKyi.Views.Settings.ViewNetwork"
xmlns:vms="clr-namespace:DownKyi.ViewModels.Settings"
x:DataType="vms:ViewNetworkViewModel"
xmlns:prism="http://prismlibrary.com/"
prism:ViewModelLocator.AutoWireViewModel="True"
x:DataType="vms:ViewNetworkViewModel"
xmlns:i="using:Avalonia.Xaml.Interactivity"
xmlns:ia="clr-namespace:Avalonia.Xaml.Interactions.Core;assembly=Avalonia.Xaml.Interactions"
xmlns:iac="clr-namespace:DownKyi.CustomAction">
@@ -294,15 +294,13 @@
<HeaderedContentControl
Margin="0,20,0,0"
Padding="10,5"
HorizontalAlignment="Left">
<HeaderedContentControl.Header>
<TextBlock
FontSize="12"
Foreground="{DynamicResource BrushTextDark}"
Text="{DynamicResource AriaDownloadLimit}" />
</HeaderedContentControl.Header>
HorizontalAlignment="Left"
FontSize="12"
Background="LightGray"
Foreground="{DynamicResource BrushTextDark}"
Header="{DynamicResource AriaDownloadLimit}">
<StackPanel>
<StackPanel Margin="10">
<StackPanel Margin="0,10,0,0" Orientation="Horizontal">
<TextBlock
Width="300"
@@ -453,6 +451,7 @@
</ComboBox>
</StackPanel>
</StackPanel>
<StackPanel Margin="10" />
</StackPanel>
</ScrollViewer>
</UserControl>

View File

@@ -9,14 +9,14 @@
xmlns:ia="clr-namespace:Avalonia.Xaml.Interactions.Core;assembly=Avalonia.Xaml.Interactions">
<Grid RowDefinitions="*">
<ListBox
x:Name="nameSeasonsSeries"
x:Name="NameSeasonsSeries"
ItemsSource="{Binding SeasonsSeries}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
SelectedIndex="{Binding SelectedItem}">
<i:Interaction.Behaviors>
<ia:EventTriggerBehavior EventName="SelectionChanged">
<ia:InvokeCommandAction Command="{Binding SeasonsSeriesCommand}"
CommandParameter="{Binding ElementName=nameSeasonsSeries, Path=SelectedItem}" />
CommandParameter="{Binding ElementName=NameSeasonsSeries, Path=SelectedItem}" />
</ia:EventTriggerBehavior>
</i:Interaction.Behaviors>
<ListBox.ItemsPanel>
@@ -50,7 +50,6 @@
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListBoxItem}">
<StackPanel
Grid.Row="0"
Margin="30,0,30,10"
HorizontalAlignment="Left"
Orientation="Vertical">
@@ -62,7 +61,7 @@
Cursor="Hand">
<Border.Background>
<!-- 长宽比1.6 -->
<ImageBrush Source="{Binding Cover}" />
<ImageBrush Source="{Binding Cover}" Stretch="Fill" />
</Border.Background>
<Border
Width="70"

View File

@@ -42,17 +42,18 @@
<!-- 左侧tab header -->
<ListBox
Name="nameLeftTabHeaders"
Name="NameLeftTabHeaders"
Grid.Column="0"
BorderThickness="0"
ItemContainerTheme="{StaticResource LeftTabHeaderItemStyle}"
ItemsSource="{Binding TabHeaders}"
SelectedIndex="{Binding SelectTabId}">
SelectedIndex="{Binding SelectTabId}"
Theme="{StaticResource LeftTabHeaderStyle}">
<i:Interaction.Behaviors>
<ia:EventTriggerBehavior EventName="SelectionChanged">
<InvokeCommandAction
Command="{Binding LeftTabHeadersCommand}"
CommandParameter="{Binding ElementName=nameLeftTabHeaders,Path=SelectedItem}" />
CommandParameter="{Binding ElementName=NameLeftTabHeaders,Path=SelectedItem}" />
</ia:EventTriggerBehavior>
</i:Interaction.Behaviors>
</ListBox>

View File

@@ -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主应对其提供、上传的内容承担全部责任。