From 33fe39119cfab617e8e2ef64d7a1948d20fdc788 Mon Sep 17 00:00:00 2001 From: developer_ken Date: Sun, 28 Jan 2024 02:28:06 +0800 Subject: [PATCH] =?UTF-8?q?=E7=99=BB=E5=BD=95=E5=90=8E=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E7=BB=91=E5=AE=9A=E5=88=B0=E8=87=AA=E5=B7=B1=E7=9A=84=E7=9B=B4?= =?UTF-8?q?=E6=92=AD=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- OpenDanmaki.Cli/Program.cs | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/OpenDanmaki.Cli/Program.cs b/OpenDanmaki.Cli/Program.cs index da7ca60..8e285a8 100644 --- a/OpenDanmaki.Cli/Program.cs +++ b/OpenDanmaki.Cli/Program.cs @@ -1,4 +1,5 @@ -using log4net; +using BiliApi; +using log4net; using log4net.Config; using QRCoder; using System.Net; @@ -76,8 +77,17 @@ static void Main(string[] args) log.Info("登录成功"); bsession = new BiliApi.BiliSession(cookie); config.BiliCookie = SerializeCookie(cookie); - log.Info("要绑定到哪个直播间?输入直播间号。"); - config.TargetRoomId = int.Parse(Console.ReadLine()); + var userinfo = bsession.getCurrentUserData(); + if (userinfo.liveroomid <= 0) + { + log.Info("要绑定到哪个直播间?输入直播间号。"); + config.TargetRoomId = int.Parse(Console.ReadLine()); + } + else + { + log.Info("将绑定到您的直播间:"+userinfo.liveroomid); + config.TargetRoomId = userinfo.liveroomid; + } } catch (Exception ex) { @@ -90,12 +100,21 @@ static void Main(string[] args) od.StartAsync().Wait(); config.BiliCookie = qr.Serilize(); File.WriteAllText("config.json", config.Serilize()); - Console.BackgroundColor = ConsoleColor.White; - Console.ForegroundColor = ConsoleColor.Black; - Console.WriteLine("http://" + od.Server.Host + ":" + od.Server.Port + "/kboard.html"); - Console.BackgroundColor = ConsoleColor.Black; - Console.ForegroundColor = ConsoleColor.White; - while (true) Thread.Sleep(1000); + if (!File.Exists("./visual_assets/kboard/kboard.html")) + { + log.Warn("前端没有提供kboard.html文件"); + } + else + { + Console.WriteLine("使用直播软件捕获以下地址:"); + Console.BackgroundColor = ConsoleColor.White; + Console.ForegroundColor = ConsoleColor.Black; + Console.Write("http://" + od.Server.Host + ":" + od.Server.Port + "/kboard.html"); + Console.BackgroundColor = ConsoleColor.Black; + Console.ForegroundColor = ConsoleColor.White; + Console.WriteLine(); + } + while (true) Thread.Sleep(10000); } public static string SerializeCookie(CookieCollection cookies)