Skip to content

Commit

Permalink
登录后自动绑定到自己的直播间
Browse files Browse the repository at this point in the history
  • Loading branch information
developer-ken committed Jan 27, 2024
1 parent 3c105fa commit 33fe391
Showing 1 changed file with 28 additions and 9 deletions.
37 changes: 28 additions & 9 deletions OpenDanmaki.Cli/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using log4net;
using BiliApi;
using log4net;
using log4net.Config;
using QRCoder;
using System.Net;
Expand Down Expand Up @@ -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)
{
Expand All @@ -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)
Expand Down

0 comments on commit 33fe391

Please sign in to comment.