Merge pull request #39 from Bililive/dev

Release 1.1.5
This commit is contained in:
Genteure 2019-01-31 14:33:05 +08:00 committed by GitHub
commit fb21eb20c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 62 additions and 35 deletions

View File

@ -11,7 +11,6 @@
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>2.0</OldToolsVersion>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DebugType>none</DebugType>
@ -19,7 +18,6 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Autofac" Version="4.8.1" />
<PackageReference Include="DnsClient" Version="1.2.0" />
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
<PackageReference Include="NLog" Version="4.5.10" />
</ItemGroup>

View File

@ -8,6 +8,11 @@ namespace BililiveRecorder.Core.Config
{
public static bool Load(string directory, ConfigV1 config = null)
{
if (!Directory.Exists(directory))
{
return false;
}
var filepath = Path.Combine(directory, "config.json");
if (File.Exists(filepath))
{

View File

@ -1,6 +1,5 @@
using BililiveRecorder.Core.Config;
using BililiveRecorder.FlvProcessor;
using DnsClient;
using NLog;
using System;
using System.Collections.Generic;
@ -20,11 +19,6 @@ namespace BililiveRecorder.Core
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
private static readonly Random random = new Random();
private static readonly LookupClient lookupClient = new LookupClient()
{
ThrowDnsErrors = true,
};
private int _roomid;
private int _realRoomid;
private string _streamerName;
@ -215,11 +209,7 @@ namespace BililiveRecorder.Core
{
using (var client = new HttpClient())
{
var raw_uri = new Uri(BililiveAPI.GetPlayUrl(RealRoomid));
client.Timeout = TimeSpan.FromMilliseconds(_config.TimingStreamConnect);
client.DefaultRequestHeaders.Host = raw_uri.Host;
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("*/*"));
client.DefaultRequestHeaders.UserAgent.Clear();
@ -227,13 +217,11 @@ namespace BililiveRecorder.Core
client.DefaultRequestHeaders.Referrer = new Uri("https://live.bilibili.com");
client.DefaultRequestHeaders.Add("Origin", "https://live.bilibili.com");
var ips = lookupClient.Query(raw_uri.DnsSafeHost, QueryType.A).Answers?.ARecords()?.ToArray();
var ip = ips[random.Next(0, ips.Count())].Address;
string flv_path = BililiveAPI.GetPlayUrl(RealRoomid);
logger.Log(RealRoomid, LogLevel.Info, "连接直播服务器 " + new Uri(flv_path).Host);
logger.Log(RealRoomid, LogLevel.Debug, "直播流地址: " + flv_path);
logger.Log(RealRoomid, LogLevel.Info, "连接直播服务器 " + raw_uri.Host + " (" + ip + ")");
logger.Log(RealRoomid, LogLevel.Debug, "直播流地址: " + raw_uri.ToString());
_response = await client.GetAsync(new UriBuilder(raw_uri) { Host = ip.ToString() }.Uri, HttpCompletionOption.ResponseHeadersRead);
_response = await client.GetAsync(flv_path, HttpCompletionOption.ResponseHeadersRead);
}
if (_response.StatusCode != HttpStatusCode.OK)

View File

@ -53,6 +53,9 @@
<Reference Include="Autofac, Version=4.8.1.0, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL">
<HintPath>..\packages\Autofac.4.8.1\lib\net45\Autofac.dll</HintPath>
</Reference>
<Reference Include="CommandLine, Version=2.4.3.0, Culture=neutral, PublicKeyToken=de6f01bd326f8c32, processorArchitecture=MSIL">
<HintPath>..\packages\CommandLineParser.2.4.3\lib\netstandard2.0\CommandLine.dll</HintPath>
</Reference>
<Reference Include="DeltaCompressionDotNet, Version=1.1.0.0, Culture=neutral, PublicKeyToken=1d14d6e5194e7f4a, processorArchitecture=MSIL">
<HintPath>..\packages\DeltaCompressionDotNet.1.1.0\lib\net20\DeltaCompressionDotNet.dll</HintPath>
</Reference>
@ -132,6 +135,7 @@
<Compile Include="ClickSelectTextBox.xaml.cs">
<DependentUpon>ClickSelectTextBox.xaml</DependentUpon>
</Compile>
<Compile Include="CommandLineOption.cs" />
<Compile Include="EnumerableExtensions.cs" />
<Compile Include="ValueConverters.cs" />
<Compile Include="SettingsWindow.xaml.cs">

View File

@ -0,0 +1,10 @@
using CommandLine;
namespace BililiveRecorder.WPF
{
public class CommandLineOption
{
[Option('w', "workdirectory", Default = null, HelpText = "设置工作目录并跳过选择目录 GUI", Required = false)]
public string WorkDirectory { get; set; }
}
}

View File

@ -1,6 +1,7 @@
using Autofac;
using BililiveRecorder.Core;
using BililiveRecorder.FlvProcessor;
using CommandLine;
using Hardcodet.Wpf.TaskbarNotification;
using NLog;
using System;
@ -66,30 +67,50 @@ namespace BililiveRecorder.WPF
{
Title += " " + BuildInfo.Version + " " + BuildInfo.HeadShaShort;
bool skip_ui = false;
string workdir = string.Empty;
try
CommandLineOption commandLineOption = null;
Parser.Default
.ParseArguments<CommandLineOption>(Environment.GetCommandLineArgs())
.WithParsed(x => commandLineOption = x);
if (commandLineOption?.WorkDirectory != null)
{
workdir = File.ReadAllText(LAST_WORK_DIR_FILE);
skip_ui = true;
workdir = commandLineOption.WorkDirectory;
}
catch (Exception) { }
var wdw = new WorkDirectoryWindow()
if (!skip_ui)
{
Owner = this,
WorkPath = workdir,
};
if (wdw.ShowDialog() == true)
{
workdir = wdw.WorkPath;
}
else
{
Environment.Exit(-1);
return;
try
{
workdir = File.ReadAllText(LAST_WORK_DIR_FILE);
}
catch (Exception) { }
var wdw = new WorkDirectoryWindow()
{
Owner = this,
WorkPath = workdir,
};
if (wdw.ShowDialog() == true)
{
workdir = wdw.WorkPath;
}
else
{
Environment.Exit(-1);
return;
}
}
if (!Recorder.Initialize(workdir))
{
MessageBox.Show("初始化错误", "录播姬", MessageBoxButton.OK, MessageBoxImage.Error);
if (!skip_ui)
{
MessageBox.Show("初始化错误", "录播姬", MessageBoxButton.OK, MessageBoxImage.Error);
}
Environment.Exit(-2);
return;
}

View File

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Autofac" version="4.8.1" targetFramework="net462" />
<package id="CommandLineParser" version="2.4.3" targetFramework="net462" />
<package id="DeltaCompressionDotNet" version="1.1.0" targetFramework="net462" />
<package id="Hardcodet.NotifyIcon.Wpf" version="1.0.8" targetFramework="net462" />
<package id="Mono.Cecil" version="0.9.6.1" targetFramework="net462" />

View File

@ -1 +1 @@
1.1.4
1.1.5