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 int 启动模式 = 0;//0:DDTV,1:DDTVLive

        /// <summary>
        /// 配置文件初始化
        /// </summary>
        /// <param name="模式">//0:DDTV,1:DDTVLive</param>
        public static bool 配置文件初始化(int 模式)
        {
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; //加上这一句
            if (模式 == 0)
            {
                InfoLog.InfoInit("./DDTVLog.out", new InfoLog.InfoClasslBool()
                {
                    Debug  = false,
                    载必要提示  = true,
                    杂项提示   = true,
                    系统错误信息 = 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;
                //数据源
                MMPU.数据源 = int.Parse(MMPU.读取exe默认配置文件("DataSource", "0"));
                //第一次使用DDTV
                MMPU.是否第一次使用DDTV = MMPU.读取exe默认配置文件("IsFirstTimeUsing", "1") == "0" ? false :true;
            }
            else if (模式 == 1)
            {
            }
            //转码功能使能
            MMPU.转码功能使能 = MMPU.读取exe默认配置文件("AutoTranscoding", "0") == "1" ? true : false;
            //检查配置文件
            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"));


            #endregion
            InfoLog.InfoPrintf("通用配置加载完成", InfoLog.InfoClass.Debug);

            BiliUser配置文件初始化(模式);
            InfoLog.InfoPrintf("Bilibili账号信息加载完成", InfoLog.InfoClass.Debug);
            ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;

            if (MMPU.数据源 == 0)
            {
                DDcenter.DdcClient.Connect();
            }
            RoomInit.start();
            return(true);
        }