Example #1
0
        public static int 启动模式 = 0;//0:DDTV,1:DDTVLive

        /// <summary>
        /// 配置文件初始化
        /// </summary>
        /// <param name="模式">//0:DDTV,1:DDTVLive</param>
        public static bool 配置文件初始化(int 模式)
        {
            if (模式 == 0)
            {
                InfoLog.InfoInit("./DDTVLog.out", new InfoLog.InfoClasslBool()
                {
                    Debug  = false,
                    载必要提示  = true,
                    杂项提示   = false,
                    系统错误信息 = true,
                    输出到文件  = false
                });
                启动模式 = 0;
            }
            else if (模式 == 1)
            {
                InfoLog.InfoInit("./DDTVLiveRecLog.out", new InfoLog.InfoClasslBool()
                {
                    Debug  = false,
                    载必要提示  = true,
                    杂项提示   = false,
                    系统错误信息 = true,
                    输出到文件  = true
                });
                启动模式 = 1;
            }
            InfoLog.InfoPrintf("消息系统初始化完成", InfoLog.InfoClass.Debug);
            #region 配置文件设置
            if (模式 == 0)
            {
                //默认音量
                MMPU.默认音量 = int.Parse(MMPU.读取exe默认配置文件("DefaultVolume", "50"));
                //缩小功能
                MMPU.缩小功能 = int.Parse(MMPU.读取exe默认配置文件("Zoom", "1"));
                //最大直播并行数量
                MMPU.最大直播并行数量 = int.Parse(MMPU.读取exe默认配置文件("PlayNum", "5"));
                //默认弹幕颜色
                MMPU.默认弹幕颜色 = MMPU.读取exe默认配置文件("DanMuColor", "0xFF, 0x00, 0x00, 0x00");
                //默认字幕颜色
                MMPU.默认字幕颜色 = MMPU.读取exe默认配置文件("ZiMuColor", "0xFF, 0x00, 0x00, 0x00");
                //默认字幕大小
                MMPU.默认字幕大小 = int.Parse(MMPU.读取exe默认配置文件("ZiMuSize", "24"));
                //默认弹幕大小
                MMPU.默认弹幕大小 = int.Parse(MMPU.读取exe默认配置文件("DanMuSize", "20"));
                //默认弹幕大小
                MMPU.播放缓冲时长 = int.Parse(MMPU.读取exe默认配置文件("BufferDuration", "3"));
                //直播缓存目录
                MMPU.直播缓存目录 = MMPU.读取exe默认配置文件("Livefile", "./tmp/LiveCache/");
                //播放窗口默认高度
                MMPU.播放器默认高度 = int.Parse(MMPU.读取exe默认配置文件("PlayWindowH", "450"));
                //播放窗口默认宽度
                MMPU.播放器默认宽度 = int.Parse(MMPU.读取exe默认配置文件("PlayWindowW", "800"));
                //剪切板监听
                MMPU.剪贴板监听 = MMPU.读取exe默认配置文件("ClipboardMonitoring", "0") == "0" ? false : true;
            }
            else if (模式 == 1)
            {
            }
            //检查配置文件
            bilibili.BiliUser.CheckPath(MMPU.BiliUserFile);

            //房间配置文件
            RoomInit.RoomConfigFile = MMPU.读取exe默认配置文件("RoomConfiguration", "./RoomListConfig.json");
            //房间配置文件
            MMPU.载储存目录 = MMPU.读取exe默认配置文件("file", "./tmp/");
            //直播表刷新默认间隔
            MMPU.直播列表刷新间隔 = int.Parse(MMPU.读取exe默认配置文件("LiveListTime", "5"));


            //直播更新时间
            MMPU.直播更新时间 = int.Parse(MMPU.读取exe默认配置文件("RoomTime", "40"));

            //转码功能使能
            MMPU.转码功能使能 = MMPU.读取exe默认配置文件("AutoTranscoding", "0") == "1" ? true : false;
            #endregion
            InfoLog.InfoPrintf("通用配置加载完成", InfoLog.InfoClass.Debug);
            #region BiliUser配置文件初始化
            //账号登陆cookie

            try
            {
                MMPU.Cookie = string.IsNullOrEmpty(MMPU.读ini配置文件("User", "Cookie", MMPU.BiliUserFile)) ? "" : Encryption.UnAesStr(MMPU.读ini配置文件("User", "Cookie", MMPU.BiliUserFile), MMPU.AESKey, MMPU.AESVal);
            }
            catch (Exception)
            {
                MMPU.Cookie = "";
            }
            //账号UID
            MMPU.UID = MMPU.读ini配置文件("User", "UID", MMPU.BiliUserFile); //string.IsNullOrEmpty(MMPU.读取exe默认配置文件("UID", "")) ? null : MMPU.读取exe默认配置文件("UID", "");
            //账号登陆cookie的有效期
            try
            {
                if (!string.IsNullOrEmpty(MMPU.读ini配置文件("User", "CookieEX", MMPU.BiliUserFile)))
                {
                    MMPU.CookieEX = DateTime.Parse(MMPU.读ini配置文件("User", "CookieEX", MMPU.BiliUserFile));
                    if (DateTime.Compare(DateTime.Now, MMPU.CookieEX) > 0)
                    {
                        MMPU.Cookie = "";

                        if (模式 == 0)
                        {
                            //MessageBox.Show("BILIBILI账号登陆已过期");
                            MMPU.写ini配置文件("User", "Cookie", "", MMPU.BiliUserFile);
                            MMPU.csrf = null;
                            MMPU.写ini配置文件("User", "csrf", "", MMPU.BiliUserFile);
                        }
                    }
                }
            }
            catch (Exception)
            {
                if (模式 == 0)
                {
                    MMPU.写ini配置文件("User", "Cookie", "", MMPU.BiliUserFile);
                }
                MMPU.Cookie = null;
            }
            //账号csrf
            if (string.IsNullOrEmpty(MMPU.Cookie))
            {
                InfoLog.InfoPrintf("\r\n==========================================\r\nbilibili账号cookie为空或已过期,请更新BiliUser.ini信息\r\n==========================================", InfoLog.InfoClass.载必要提示);
                InfoLog.InfoPrintf("\r\n==========================================\r\nbilibili账号cookie为空或已过期,请更新BiliUser.ini信息\r\n==========================================", InfoLog.InfoClass.载必要提示);
                InfoLog.InfoPrintf("\r\n==========================================\r\nbilibili账号cookie为空或已过期,请更新BiliUser.ini信息\r\n==========================================", InfoLog.InfoClass.载必要提示);
                if (模式 == 1)
                {
                    bilibili.BiliUser.登陆();
                    InfoLog.InfoPrintf("\r\nB站账号登陆信息过期或无效,启动失败,请自行打开目录中的[BiliQR.png]或访问[http://本机IP:11419/login]使用B站客户端扫描二维码登陆", InfoLog.InfoClass.载必要提示);

                    while (string.IsNullOrEmpty(MMPU.Cookie))
                    {
                        // break;
                    }
                }
            }
            MMPU.csrf = MMPU.读ini配置文件("User", "csrf", MMPU.BiliUserFile);
            #endregion
            InfoLog.InfoPrintf("Bilibili账号信息加载完成", InfoLog.InfoClass.Debug);
            //初始化房间
            RoomInit.start();
            return(true);
        }
Example #2
0
        public static void BiliUser配置文件初始化(int 模式)
        {
            //账号登陆cookie
            try
            {
                MMPU.Cookie = Encryption.UnAesStr(MMPU.读ini配置文件("User", "Cookie", MMPU.BiliUserFile), MMPU.AESKey, MMPU.AESVal);
                if (!MMPU.Cookie.Contains("=") || !MMPU.Cookie.Contains(";"))
                {
                    MMPU.Cookie = "";
                    MMPU.写ini配置文件("User", "Cookie", "", MMPU.BiliUserFile);
                    MMPU.csrf = null;
                    MMPU.写ini配置文件("User", "csrf", "", MMPU.BiliUserFile);
                }
            }
            catch (Exception)
            {
                Console.WriteLine("读取cookie缓存错误");
                MMPU.Cookie = "";
                MMPU.写ini配置文件("User", "Cookie", "", MMPU.BiliUserFile);
            }
            //账号UID
            MMPU.UID = MMPU.读ini配置文件("User", "UID", MMPU.BiliUserFile); //string.IsNullOrEmpty(MMPU.读取exe默认配置文件("UID", "")) ? null : MMPU.读取exe默认配置文件("UID", "");
            //账号登陆cookie的有效期
            try
            {
                if (!string.IsNullOrEmpty(MMPU.读ini配置文件("User", "CookieEX", MMPU.BiliUserFile)))
                {
                    MMPU.CookieEX = DateTime.Parse(MMPU.读ini配置文件("User", "CookieEX", MMPU.BiliUserFile));
                    if (DateTime.Compare(DateTime.Now, MMPU.CookieEX) > 0)
                    {
                        MMPU.Cookie = "";

                        if (模式 == 0)
                        {
                            //MessageBox.Show("BILIBILI账号登陆已过期");
                            MMPU.写ini配置文件("User", "Cookie", "", MMPU.BiliUserFile);
                            MMPU.csrf = null;
                            MMPU.写ini配置文件("User", "csrf", "", MMPU.BiliUserFile);
                        }
                    }
                }
            }
            catch (Exception)
            {
                if (模式 == 0)
                {
                    MMPU.写ini配置文件("User", "Cookie", "", MMPU.BiliUserFile);
                }
                MMPU.Cookie = null;
            }
            //账号csrf
            if (string.IsNullOrEmpty(MMPU.Cookie))
            {
                InfoLog.InfoPrintf("\r\n===============================\r\nbilibili账号cookie为空或已过期,请更新BiliUser.ini信息\r\n===============================", InfoLog.InfoClass.载必要提示);
                InfoLog.InfoPrintf("\r\n==============\r\nBiliUser.ini文件无效,请使用DDTV本体登陆成功后把DDTV本体里的BiliUser.ini文件覆盖无效的文件\r\n==============", InfoLog.InfoClass.载必要提示);
                if (模式 == 1)
                {
                    InfoLog.InfoPrintf("\r\n如果短信验证方式验证启动失败,请复制DDTV2本体中有效BiliUser.ini覆盖本地文件后重启DDTVLiveRec\r\n[======如果是非windows系统,请检查文件权限======]", InfoLog.InfoClass.载必要提示);
                    try
                    {
                        bilibili.BiliUser.登陆();
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e.ToString());
                    }
                    while (string.IsNullOrEmpty(MMPU.Cookie))
                    {
                        InfoLog.InfoPrintf("\r\n请根据登陆验证提示操作", InfoLog.InfoClass.系统错误信息);
                        //InfoLog.InfoPrintf("\r\n阿B登陆验证失败!!!请重启DDTVLiveRec进行登陆验证", InfoLog.InfoClass.下载必要提示);
                        Thread.Sleep(10000);
                    }
                }
            }
            else
            {
                if (模式 == 0)
                {
                    if (!MMPU.加载网络房间方法.是否正在缓存)
                    {
                        new Task(() =>
                        {
                            加载网络房间方法.更新网络房间缓存();
                        }).Start();
                    }
                }
            }
            MMPU.csrf = MMPU.读ini配置文件("User", "csrf", MMPU.BiliUserFile);
        }
Example #3
0
        public static void BiliUser配置文件初始化(int 模式)
        {
            //账号登陆cookie
            try
            {
                MMPU.Cookie = string.IsNullOrEmpty(MMPU.读ini配置文件("User", "Cookie", MMPU.BiliUserFile)) ? "" : Encryption.UnAesStr(MMPU.读ini配置文件("User", "Cookie", MMPU.BiliUserFile), MMPU.AESKey, MMPU.AESVal);
            }
            catch (Exception)
            {
                MMPU.Cookie = "";
            }
            //账号UID
            MMPU.UID = MMPU.读ini配置文件("User", "UID", MMPU.BiliUserFile); //string.IsNullOrEmpty(MMPU.读取exe默认配置文件("UID", "")) ? null : MMPU.读取exe默认配置文件("UID", "");
            //账号登陆cookie的有效期
            try
            {
                if (!string.IsNullOrEmpty(MMPU.读ini配置文件("User", "CookieEX", MMPU.BiliUserFile)))
                {
                    MMPU.CookieEX = DateTime.Parse(MMPU.读ini配置文件("User", "CookieEX", MMPU.BiliUserFile));
                    if (DateTime.Compare(DateTime.Now, MMPU.CookieEX) > 0)
                    {
                        MMPU.Cookie = "";

                        if (模式 == 0)
                        {
                            //MessageBox.Show("BILIBILI账号登陆已过期");
                            MMPU.写ini配置文件("User", "Cookie", "", MMPU.BiliUserFile);
                            MMPU.csrf = null;
                            MMPU.写ini配置文件("User", "csrf", "", MMPU.BiliUserFile);
                        }
                    }
                }
            }
            catch (Exception)
            {
                if (模式 == 0)
                {
                    MMPU.写ini配置文件("User", "Cookie", "", MMPU.BiliUserFile);
                }
                MMPU.Cookie = null;
            }
            //账号csrf
            if (string.IsNullOrEmpty(MMPU.Cookie))
            {
                InfoLog.InfoPrintf("\r\n==========================================\r\nbilibili账号cookie为空或已过期,请更新BiliUser.ini信息\r\n==========================================", InfoLog.InfoClass.载必要提示);
                InfoLog.InfoPrintf("\r\n==========================================\r\nbilibili账号cookie为空或已过期,请更新BiliUser.ini信息\r\n==========================================", InfoLog.InfoClass.载必要提示);
                InfoLog.InfoPrintf("\r\n==========================================\r\nbilibili账号cookie为空或已过期,请更新BiliUser.ini信息\r\n==========================================", InfoLog.InfoClass.载必要提示);
                if (模式 == 1)
                {
                    bilibili.BiliUser.登陆();
                    InfoLog.InfoPrintf("\r\nB站账号登陆信息过期或无效,启动失败,请自行打开目录中的[BiliQR.png]或访问[http://本机IP:11419/login]使用B站客户端扫描二维码登陆", InfoLog.InfoClass.载必要提示);

                    while (string.IsNullOrEmpty(MMPU.Cookie))
                    {
                        // break;
                    }
                }
            }
            MMPU.csrf = MMPU.读ini配置文件("User", "csrf", MMPU.BiliUserFile);
        }
Example #4
0
        public static void BiliUser配置文件初始化(int 模式)
        {
            //账号登陆cookie
            try
            {
                MMPU.Cookie = string.IsNullOrEmpty(MMPU.读ini配置文件("User", "Cookie", MMPU.BiliUserFile)) ? "" : Encryption.UnAesStr(MMPU.读ini配置文件("User", "Cookie", MMPU.BiliUserFile), MMPU.AESKey, MMPU.AESVal);
            }
            catch (Exception)
            {
                MMPU.Cookie = "";
            }
            //账号UID
            MMPU.UID = MMPU.读ini配置文件("User", "UID", MMPU.BiliUserFile); //string.IsNullOrEmpty(MMPU.读取exe默认配置文件("UID", "")) ? null : MMPU.读取exe默认配置文件("UID", "");
            //账号登陆cookie的有效期
            try
            {
                if (!string.IsNullOrEmpty(MMPU.读ini配置文件("User", "CookieEX", MMPU.BiliUserFile)))
                {
                    MMPU.CookieEX = DateTime.Parse(MMPU.读ini配置文件("User", "CookieEX", MMPU.BiliUserFile));
                    if (DateTime.Compare(DateTime.Now, MMPU.CookieEX) > 0)
                    {
                        MMPU.Cookie = "";

                        if (模式 == 0)
                        {
                            //MessageBox.Show("BILIBILI账号登陆已过期");
                            MMPU.写ini配置文件("User", "Cookie", "", MMPU.BiliUserFile);
                            MMPU.csrf = null;
                            MMPU.写ini配置文件("User", "csrf", "", MMPU.BiliUserFile);
                        }
                    }
                }
            }
            catch (Exception)
            {
                if (模式 == 0)
                {
                    MMPU.写ini配置文件("User", "Cookie", "", MMPU.BiliUserFile);
                }
                MMPU.Cookie = null;
            }
            //账号csrf
            if (string.IsNullOrEmpty(MMPU.Cookie))
            {
                InfoLog.InfoPrintf("\r\n===============================\r\nbilibili账号cookie为空或已过期,请更新BiliUser.ini信息\r\n===============================", InfoLog.InfoClass.载必要提示);
                InfoLog.InfoPrintf("\r\n==============\r\nBiliUser.ini文件无效,请使用DDTV本体登陆成功后把DDTV本体里的BiliUser.ini文件覆盖无效的文件\r\n==============", InfoLog.InfoClass.载必要提示);
                if (模式 == 1)
                {
                    bilibili.BiliUser.登陆();
                    InfoLog.InfoPrintf("\r\nB站账号登陆信息过期或无效,启动失败,请自行打开目录中的[BiliQR.png]使用B站客户端扫描二维码登陆,或复制DDTV2的有效BiliUser.ini覆盖本地文件\r\n[======如果是linux系统,请检查几个文件的权限======]", InfoLog.InfoClass.载必要提示);

                    while (string.IsNullOrEmpty(MMPU.Cookie))
                    {
                        // break;
                    }
                }
            }
            else
            {
                if (模式 == 0)
                {
                    if (!MMPU.加载网络房间方法.是否正在缓存)
                    {
                        new Task(() =>
                        {
                            加载网络房间方法.更新网络房间缓存();
                        }).Start();
                    }
                }
            }
            MMPU.csrf = MMPU.读ini配置文件("User", "csrf", MMPU.BiliUserFile);
        }