diff --git a/BililiveRecorder.Core/BililiveRecorder.Core.csproj b/BililiveRecorder.Core/BililiveRecorder.Core.csproj
index b5352b7..a5f8668 100644
--- a/BililiveRecorder.Core/BililiveRecorder.Core.csproj
+++ b/BililiveRecorder.Core/BililiveRecorder.Core.csproj
@@ -11,7 +11,6 @@
2.0
- true
none
@@ -19,7 +18,6 @@
-
diff --git a/BililiveRecorder.Core/Config/ConfigParser.cs b/BililiveRecorder.Core/Config/ConfigParser.cs
index 7aea76c..4665222 100644
--- a/BililiveRecorder.Core/Config/ConfigParser.cs
+++ b/BililiveRecorder.Core/Config/ConfigParser.cs
@@ -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))
{
diff --git a/BililiveRecorder.Core/RecordedRoom.cs b/BililiveRecorder.Core/RecordedRoom.cs
index 680e702..f5b7521 100644
--- a/BililiveRecorder.Core/RecordedRoom.cs
+++ b/BililiveRecorder.Core/RecordedRoom.cs
@@ -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)
diff --git a/BililiveRecorder.WPF/BililiveRecorder.WPF.csproj b/BililiveRecorder.WPF/BililiveRecorder.WPF.csproj
index 3abf548..30f35c2 100644
--- a/BililiveRecorder.WPF/BililiveRecorder.WPF.csproj
+++ b/BililiveRecorder.WPF/BililiveRecorder.WPF.csproj
@@ -53,6 +53,9 @@
..\packages\Autofac.4.8.1\lib\net45\Autofac.dll
+
+ ..\packages\CommandLineParser.2.4.3\lib\netstandard2.0\CommandLine.dll
+
..\packages\DeltaCompressionDotNet.1.1.0\lib\net20\DeltaCompressionDotNet.dll
@@ -132,6 +135,7 @@
ClickSelectTextBox.xaml
+
diff --git a/BililiveRecorder.WPF/CommandLineOption.cs b/BililiveRecorder.WPF/CommandLineOption.cs
new file mode 100644
index 0000000..be0ad91
--- /dev/null
+++ b/BililiveRecorder.WPF/CommandLineOption.cs
@@ -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; }
+ }
+}
diff --git a/BililiveRecorder.WPF/MainWindow.xaml.cs b/BililiveRecorder.WPF/MainWindow.xaml.cs
index 939d5bb..d6364e1 100644
--- a/BililiveRecorder.WPF/MainWindow.xaml.cs
+++ b/BililiveRecorder.WPF/MainWindow.xaml.cs
@@ -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(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;
}
diff --git a/BililiveRecorder.WPF/packages.config b/BililiveRecorder.WPF/packages.config
index 3454275..30daf64 100644
--- a/BililiveRecorder.WPF/packages.config
+++ b/BililiveRecorder.WPF/packages.config
@@ -1,6 +1,7 @@
+
diff --git a/VERSION b/VERSION
index 1b87bcd..314c3d7 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-1.1.4
\ No newline at end of file
+1.1.5
\ No newline at end of file