mirror of
https://github.com/BililiveRecorder/BililiveRecorder.git
synced 2024-11-16 11:42:22 +08:00
Merge branch 'NyaMisty-dev' into dev #139
This commit is contained in:
commit
31859a67cc
|
@ -15,7 +15,7 @@ insert_final_newline = true
|
||||||
|
|
||||||
indent_size = 2
|
indent_size = 2
|
||||||
|
|
||||||
[.csproj]
|
[*.csproj]
|
||||||
|
|
||||||
indent_size = 2
|
indent_size = 2
|
||||||
|
|
||||||
|
|
|
@ -1,20 +1,23 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<LangVersion>9.0</LangVersion>
|
||||||
<StartupObject>BililiveRecorder.Cli.Program</StartupObject>
|
<StartupObject>BililiveRecorder.Cli.Program</StartupObject>
|
||||||
|
<RuntimeIdentifiers>win-x64;osx.10.11-x64;linux-arm64;linux-arm;linux-x64</RuntimeIdentifiers>
|
||||||
|
<PublishDir Condition=" '$(RuntimeIdentifier)' == '' ">publish\any</PublishDir>
|
||||||
|
<PublishDir Condition=" '$(RuntimeIdentifier)' != '' ">publish\$(RuntimeIdentifier)</PublishDir>
|
||||||
|
<SelfContained Condition=" '$(RuntimeIdentifier)' == '' ">false</SelfContained>
|
||||||
|
<SelfContained Condition=" '$(SelfContained)' == '' ">true</SelfContained>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Remove="config.json" />
|
<None Remove="config.json" />
|
||||||
<None Remove="NLog.config" />
|
<None Remove="NLog.config" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="..\TempBuildInfo\BuildInfo.Cli.cs" />
|
<Compile Include="..\TempBuildInfo\BuildInfo.Cli.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="config.json">
|
<Content Include="config.json">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
@ -23,22 +26,17 @@
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Autofac" Version="4.9.4" />
|
<PackageReference Include="Autofac" Version="4.9.4" />
|
||||||
<PackageReference Include="CommandLineParser" Version="2.4.3" />
|
<PackageReference Include="CommandLineParser" Version="2.4.3" />
|
||||||
<PackageReference Include="NLog" Version="4.7.6" />
|
<PackageReference Include="NLog" Version="4.7.6" />
|
||||||
<PackageReference Include="NLog.Config" Version="4.7.6" />
|
<PackageReference Include="NLog.Config" Version="4.7.6" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\BililiveRecorder.Core\BililiveRecorder.Core.csproj" />
|
<ProjectReference Include="..\BililiveRecorder.Core\BililiveRecorder.Core.csproj" />
|
||||||
<ProjectReference Include="..\BililiveRecorder.FlvProcessor\BililiveRecorder.FlvProcessor.csproj" />
|
<ProjectReference Include="..\BililiveRecorder.FlvProcessor\BililiveRecorder.FlvProcessor.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
|
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
|
||||||
<Exec Command="cd $(SolutionDir)
powershell -ExecutionPolicy Bypass -File .\CI\patch_buildinfo.ps1 Cli" />
|
<Exec Command="cd $(SolutionDir)
powershell -ExecutionPolicy Bypass -File .\CI\patch_buildinfo.ps1 Cli" />
|
||||||
</Target>
|
</Target>
|
||||||
|
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
@ -8,40 +8,39 @@ using BililiveRecorder.Core;
|
||||||
using BililiveRecorder.Core.Config;
|
using BililiveRecorder.Core.Config;
|
||||||
using BililiveRecorder.FlvProcessor;
|
using BililiveRecorder.FlvProcessor;
|
||||||
using CommandLine;
|
using CommandLine;
|
||||||
|
using Newtonsoft.Json;
|
||||||
using NLog;
|
using NLog;
|
||||||
|
|
||||||
namespace BililiveRecorder.Cli
|
namespace BililiveRecorder.Cli
|
||||||
{
|
{
|
||||||
class Program
|
internal class Program
|
||||||
{
|
{
|
||||||
private static IContainer Container { get; set; }
|
|
||||||
private static ILifetimeScope RootScope { get; set; }
|
|
||||||
private static IRecorder Recorder { get; set; }
|
|
||||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
static void Main(string[] _)
|
private static void Main(string[] _)
|
||||||
{
|
{
|
||||||
var builder = new ContainerBuilder();
|
var builder = new ContainerBuilder();
|
||||||
builder.RegisterModule<FlvProcessorModule>();
|
builder.RegisterModule<FlvProcessorModule>();
|
||||||
builder.RegisterModule<CoreModule>();
|
builder.RegisterModule<CoreModule>();
|
||||||
builder.RegisterType<CommandConfigV1>().As<ConfigV1>().InstancePerMatchingLifetimeScope("recorder_root");
|
builder.RegisterType<CommandConfigV1>().As<ConfigV1>().InstancePerMatchingLifetimeScope("recorder_root");
|
||||||
Container = builder.Build();
|
var Container = builder.Build();
|
||||||
|
var RootScope = Container.BeginLifetimeScope("recorder_root");
|
||||||
|
|
||||||
RootScope = Container.BeginLifetimeScope("recorder_root");
|
var Recorder = RootScope.Resolve<IRecorder>();
|
||||||
Recorder = RootScope.Resolve<IRecorder>();
|
if (!Recorder.Initialize(Directory.GetCurrentDirectory()))
|
||||||
if (!Recorder.Initialize(System.IO.Directory.GetCurrentDirectory()))
|
|
||||||
{
|
{
|
||||||
Console.WriteLine("Initialize Error");
|
Console.WriteLine("Initialize Error");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Parser.Default
|
Parser.Default
|
||||||
.ParseArguments<CommandConfigV1>(() => (CommandConfigV1)Recorder.Config, Environment.GetCommandLineArgs())
|
.ParseArguments(() => (CommandConfigV1)Recorder.Config, Environment.GetCommandLineArgs())
|
||||||
.WithParsed(Run);
|
.WithParsed(Run);
|
||||||
}
|
|
||||||
|
|
||||||
private static void Run(ConfigV1 option)
|
return;
|
||||||
|
void Run(ConfigV1 option)
|
||||||
{
|
{
|
||||||
|
option.EnabledFeature = EnabledFeature.RecordOnly;
|
||||||
foreach (var room in option.RoomList)
|
foreach (var room in option.RoomList)
|
||||||
{
|
{
|
||||||
if (Recorder.Where(r => r.RoomId == room.Roomid).Count() == 0)
|
if (Recorder.Where(r => r.RoomId == room.Roomid).Count() == 0)
|
||||||
|
@ -50,6 +49,8 @@ namespace BililiveRecorder.Cli
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logger.Info("Using workDir: " + option.WorkDirectory + "\n\tconfig: " + JsonConvert.SerializeObject(option, Formatting.Indented));
|
||||||
|
|
||||||
logger.Info("开始录播");
|
logger.Info("开始录播");
|
||||||
Task.WhenAll(Recorder.Select(x => Task.Run(() => x.Start()))).Wait();
|
Task.WhenAll(Recorder.Select(x => Task.Run(() => x.Start()))).Wait();
|
||||||
Console.CancelKeyPress += (sender, e) =>
|
Console.CancelKeyPress += (sender, e) =>
|
||||||
|
@ -63,50 +64,54 @@ namespace BililiveRecorder.Cli
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ConfigV1Metadata
|
|
||||||
{
|
|
||||||
[Option('o', "dir", Default = ".", HelpText = "Output directory", Required = false)]
|
|
||||||
[Utils.DoNotCopyProperty]
|
|
||||||
public object WorkDirectory { get; set; }
|
|
||||||
|
|
||||||
[Option("cookie", HelpText = "Provide custom cookies", Required = false)]
|
|
||||||
public object Cookie { get; set; }
|
|
||||||
|
|
||||||
[Option("avoidtxy", HelpText = "Avoid Tencent Cloud server", Required = false)]
|
|
||||||
public object AvoidTxy { get; set; }
|
|
||||||
|
|
||||||
[Option("live_api_host", HelpText = "Use custom api host", Required = false)]
|
|
||||||
public object LiveApiHost { get; set; }
|
|
||||||
|
|
||||||
[Option("record_filename_format", HelpText = "Recording name format", Required = false)]
|
|
||||||
public object RecordFilenameFormat { get; set; }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[MetadataType(typeof(ConfigV1Metadata))]
|
public partial class CommandConfigV1 : ConfigV1
|
||||||
class CommandConfigV1 : ConfigV1
|
|
||||||
{
|
{
|
||||||
[Option('i', "id", HelpText = "room id", Required = true)]
|
[Option('i', "id", HelpText = "room id", Required = true)]
|
||||||
[Utils.DoNotCopyProperty]
|
|
||||||
public string _RoomList
|
public string _RoomList
|
||||||
{
|
{
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
var roomids = value.Split(',');
|
var roomids = value.Split(',');
|
||||||
RoomList.Clear();
|
this.RoomList.Clear();
|
||||||
|
|
||||||
foreach (var roomid in roomids)
|
foreach (var roomid in roomids)
|
||||||
{
|
{
|
||||||
var room = new RoomV1();
|
var room = new RoomV1();
|
||||||
room.Roomid = Int32.Parse(roomid);
|
room.Roomid = int.Parse(roomid);
|
||||||
room.Enabled = false;
|
room.Enabled = false;
|
||||||
RoomList.Add(room);
|
this.RoomList.Add(room);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Option('o', "dir", Default = ".", HelpText = "Output directory", Required = false)]
|
||||||
|
public new string WorkDirectory
|
||||||
|
{
|
||||||
|
get => base.WorkDirectory;
|
||||||
|
set => base.WorkDirectory = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Option("cookie", HelpText = "Provide custom cookies", Required = false)]
|
||||||
|
public new string Cookie
|
||||||
|
{
|
||||||
|
get => base.Cookie;
|
||||||
|
set => base.Cookie = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Option("live_api_host", HelpText = "Use custom api host", Required = false)]
|
||||||
|
public new string LiveApiHost
|
||||||
|
{
|
||||||
|
get => base.LiveApiHost;
|
||||||
|
set => base.LiveApiHost = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Option("record_filename_format", HelpText = "Recording name format", Required = false)]
|
||||||
|
public new string RecordFilenameFormat
|
||||||
|
{
|
||||||
|
get => base.RecordFilenameFormat;
|
||||||
|
set => base.RecordFilenameFormat = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
27
appveyor.yml
27
appveyor.yml
|
@ -38,6 +38,13 @@ before_build:
|
||||||
|
|
||||||
build_script:
|
build_script:
|
||||||
- ps: msbuild /nologo /v:m /p:Configuration="$env:CONFIGURATION" /p:SquirrelBuildTarget="$env:DEPLOY_SITE_GIT\BililiveRecorder" /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
|
- ps: msbuild /nologo /v:m /p:Configuration="$env:CONFIGURATION" /p:SquirrelBuildTarget="$env:DEPLOY_SITE_GIT\BililiveRecorder" /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
|
||||||
|
- ps: msbuild /nologo /v:m /t:BililiveRecorder_Cli:Publish /p:Configuration="$env:CONFIGURATION" /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
|
||||||
|
- ps: msbuild /nologo /v:m /t:BililiveRecorder_Cli:Publish /p:Configuration="$env:CONFIGURATION" /p:RuntimeIdentifier="linux-arm" /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
|
||||||
|
- ps: msbuild /nologo /v:m /t:BililiveRecorder_Cli:Publish /p:Configuration="$env:CONFIGURATION" /p:RuntimeIdentifier="linux-arm64" /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
|
||||||
|
- ps: msbuild /nologo /v:m /t:BililiveRecorder_Cli:Publish /p:Configuration="$env:CONFIGURATION" /p:RuntimeIdentifier="linux-x64" /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
|
||||||
|
- ps: msbuild /nologo /v:m /t:BililiveRecorder_Cli:Publish /p:Configuration="$env:CONFIGURATION" /p:RuntimeIdentifier="osx.10.11-x64" /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
|
||||||
|
- ps: msbuild /nologo /v:m /t:BililiveRecorder_Cli:Publish /p:Configuration="$env:CONFIGURATION" /p:RuntimeIdentifier="osx-x64" /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
|
||||||
|
- ps: msbuild /nologo /v:m /t:BililiveRecorder_Cli:Publish /p:Configuration="$env:CONFIGURATION" /p:RuntimeIdentifier="win-x64" /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
|
||||||
|
|
||||||
for:
|
for:
|
||||||
-
|
-
|
||||||
|
@ -59,7 +66,21 @@ for:
|
||||||
configuration: Debug
|
configuration: Debug
|
||||||
artifacts:
|
artifacts:
|
||||||
- path: BililiveRecorder.WPF\bin\Debug
|
- path: BililiveRecorder.WPF\bin\Debug
|
||||||
name: BililiveRecorderDebugBuild
|
name: BililiveRecorderWPFDebugBuild
|
||||||
|
- path: BililiveRecorder.Cli\publish\any
|
||||||
|
name: BililiveRecorderCliDebugBuild
|
||||||
|
- path: BililiveRecorder.Cli\publish\linux-arm
|
||||||
|
name: BililiveRecorderCliDebugBuild-linux-arm
|
||||||
|
- path: BililiveRecorder.Cli\publish\linux-arm64
|
||||||
|
name: BililiveRecorderCliDebugBuild-linux-arm64
|
||||||
|
- path: BililiveRecorder.Cli\publish\linux-x64
|
||||||
|
name: BililiveRecorderCliDebugBuild-linux-x64
|
||||||
|
- path: BililiveRecorder.Cli\publish\osx.10.11-x64
|
||||||
|
name: BililiveRecorderCliDebugBuild-osx.10.11-x64
|
||||||
|
- path: BililiveRecorder.Cli\publish\osx-x64
|
||||||
|
name: BililiveRecorderCliDebugBuild-osx-x64
|
||||||
|
- path: BililiveRecorder.Cli\publish\win-x64
|
||||||
|
name: BililiveRecorderCliDebugBuild-win-x64
|
||||||
|
|
||||||
#on_finish:
|
on_finish:
|
||||||
# - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
|
#- ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user