コード例 #1
0
ファイル: bilibili.cs プロジェクト: 4Envy/DDTV2
            public static void 登陆()
            {
                if (MMPU.启动模式 == 0)
                {
                    ByQRCode.QrCodeStatus_Changed += ByQRCode_QrCodeStatus_Changed;
                    ByQRCode.QrCodeRefresh        += ByQRCode_QrCodeRefresh;
                    ByQRCode.LoginByQrCode("#FF000000", "#FFFFFFFF", true).Save("./BiliQR.png", System.Drawing.Imaging.ImageFormat.Png);
                }
                else if (MMPU.启动模式 == 1)
                {
                    Console.WriteLine("配置引导方式:手机登陆");
                    Console.Write("请输入手机号以验证短信验证码:");
                    string tel = Console.ReadLine();
                    try
                    {
                        BySMS.SendSMS(tel);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine($"短信验证登陆失败,请求验证码错误,错误原因:{e.Message}\r\n登陆验证失败,请重启再次尝试登陆或复制DDTV2本体中有效BiliUser.ini覆盖本地文件后重启DDTVLiveRec\r\n[======如果是非windows系统,请检查文件权限======]");
                        return;
                    }
                    Console.Write("验证短信请求已发送,请输入收到的验证码:");
                    string code = Console.ReadLine();
                    try
                    {
                        BiliUser.account = BySMS.Login(code, tel);
                    }
                    catch (Exception)
                    {
                        if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
                        {
                            ByQRCode.QrCodeStatus_Changed += ByQRCode_QrCodeStatus_Changed;
                            ByQRCode.QrCodeRefresh        += ByQRCode_QrCodeRefresh;
                            ByQRCode.LoginByQrCode("#FF000000", "#FFFFFFFF", true).Save("./BiliQR.png", System.Drawing.Imaging.ImageFormat.Png);
                            InfoLog.InfoPrintf("短信验证登陆失败,切换备用二维码扫码登陆方式, 请用阿B手机客户端扫描DDTVLiveRec目录中的[BiliQR.png]文件进行登陆", InfoLog.InfoClass.系统错误信息);
                            return;
                        }
                        else
                        {
                            Console.WriteLine("登陆验证失败,请复制DDTV2本体中有效BiliUser.ini覆盖本地文件后重启DDTVLiveRec\r\n[======如果是非windows系统,请检查文件权限======]");
                            return;
                        }
                    }

                    MMPU.UID = account.Uid;
                    MMPU.写ini配置文件("User", "UID", MMPU.UID, MMPU.BiliUserFile);
                    foreach (var item in account.Cookies)
                    {
                        MMPU.Cookie = MMPU.Cookie + item + ";";
                    }
                    MMPU.CookieEX = account.Expires_Cookies;
                    MMPU.csrf     = account.CsrfToken;

                    MMPU.写ini配置文件("User", "csrf", MMPU.csrf, MMPU.BiliUserFile);
                    MMPU.写ini配置文件("User", "Cookie", Encryption.AesStr(MMPU.Cookie, MMPU.AESKey, MMPU.AESVal), MMPU.BiliUserFile);
                    MMPU.写ini配置文件("User", "CookieEX", MMPU.CookieEX.ToString("yyyy-MM-dd HH:mm:ss"), MMPU.BiliUserFile);
                    InfoLog.InfoPrintf("UID:" + account.Uid + ",登陆成功", InfoLog.InfoClass.载必要提示);
                }
            }
コード例 #2
0
ファイル: Program.cs プロジェクト: tipalol/Sandbox
        static void Main(string[] args)
        {
            //В качестве способа отправки выбираем отправку по SMS
            var shareApplication = new BySMS();
            //Производим Dependency Injection (DI)
            var gallery = new GalleryApplication(shareApplication);

            gallery.Share();
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: roceys/BiliAccount
        private static void Main(string[] args)
        {
            Console.WriteLine($"测试版本:");
            Console.WriteLine($"BiliAccount:{AssemblyName.GetAssemblyName("BiliAccount.dll").Version.ToString()}");
            Console.WriteLine($"BiliAccount.Geetest:{AssemblyName.GetAssemblyName("BiliAccount.Geetest.dll").Version.ToString()}");
            Console.WriteLine($"BiliAccount.Geetest.Controls:{AssemblyName.GetAssemblyName("BiliAccount.Geetest.Controls.dll").Version.ToString()}");
            //Console.WriteLine("账号");
            //string username = Console.ReadLine();
            //Console.WriteLine("密码");
            //string pwd = Console.ReadLine();
            //Account account = ByPassword.LoginByPassword(username, pwd);
            //Console.WriteLine(var_dump(account));
            //if (account.LoginStatus == Account.LoginStatusEnum.NeedSafeVerify) Process.Start(account.Url);

            //ByQRCode.QrCodeStatus_Changed += ByQRCode_QrCodeStatus_Changed;
            //ByQRCode.QrCodeRefresh += ByQRCode_QrCodeRefresh;
            //ByQRCode.LoginByQrCode("#ff000000","#00FFFFFF").Save("tmp.png");

            //string token = Console.ReadLine();
            //Console.WriteLine(BiliAccount.Linq.ByPassword.IsTokenAvailable(token));

            Console.WriteLine("手机号");
            string tel = Console.ReadLine();

            BySMS.SendSMS(tel);
            Console.WriteLine("验证码");
            string  code    = Console.ReadLine();
            Account account = BySMS.Login(code, tel);

            Console.WriteLine(var_dump(account));

            //Console.WriteLine(var_dump(ByPassword.SSO(account.AccessToken)));

            //account.Expires_AccessToken = (DateTime)ByPassword.RefreshToken("76b3e1cb9b0d35a80f8c444dcdcb1a21", "bcb656a377362db92487929a7f258d21");
            //Console.WriteLine(var_dump(account));

            //ByPassword.Revoke(ref account);

            Application.Run();
        }