Ejemplo n.º 1
0
        //检测是否在直播
        public static string getBiliRoomId(string ID, string ty)
        {
            //读取设置
            var    originalRoomId = ID;
            string _flvUrl        = "";
            //准备查找下载地址
            //查找真实房间号
            string _roomid = "";

            switch (ty)
            {
            case "bilibili":
                _roomid = GetRoomid(ID);
                break;

            case "youtube":
                try
                {
                    string ASDASD = MMPU.get返回网页内容("https://www.youtube.com/channel/UCcnoKv531otgPrd3NcR0mag/live");
                    ASDASD  = ASDASD.Replace("\\\"},\\\"playbackTracking\\\"", "㈨").Split('㈨')[0].Replace("\\\"hlsManifestUrl\\\":\\\"", "㈨").Split('㈨')[1].Replace("\",\\\"probeUrl\\\"", "㈨").Split('㈨')[0].Replace("\\", "");
                    _roomid = MMPU.get返回网页内容(ASDASD);
                }
                catch (Exception)
                {
                    _roomid = "该房间未在直播";
                }
                break;
            }


            if (_roomid == "该房间未在直播" || string.IsNullOrEmpty(_roomid))
            {
                return("该房间未在直播");
            }
            //查找真实下载地址
            try
            {
                _flvUrl = GetTrueUrl(_roomid);
            }
            catch
            {
                Console.WriteLine("未取得下载地址");
            }
            return(_flvUrl);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 初始化房间列表
        /// </summary>
        public static void InitializeRoomList()
        {
            JObject jo = (JObject)JsonConvert.DeserializeObject(MMPU.ReadFile(MMPU.RoomConfigFile));

            try
            {
                while (true)
                {
                    int a1015 = 0, a1014 = 0;
                    try
                    {
                        Roomlist = new List <Room.RoomCadr>();
                        //1.0.1.5兼容
                        for (int i = 0; ; i++)
                        {
                            if (jo["data"][i]["Types"].ToString() != "youtube")
                            {
                                Roomlist.Add(new Room.RoomCadr()
                                {
                                    Name = jo["data"][i]["Name"].ToString(), RoomNumber = jo["data"][i]["RoomNumber"].ToString(), status = false, Types = jo["data"][i]["Types"].ToString(), VideoStatus = ((jo["data"][i]["VideoStatus"].ToString() == "True") ? true : false)
                                });
                            }

                            a1015++;
                        }
                    }
                    catch (Exception)
                    {
                        try
                        {
                            //1.0.1.4兼容
                            if (a1015 == 0)
                            {
                                for (int i = 0; ; i++)
                                {
                                    Roomlist.Add(new Room.RoomCadr()
                                    {
                                        Name = jo["data"][i]["Name"].ToString(), RoomNumber = jo["data"][i]["RoomNumber"].ToString(), status = false, Types = jo["data"][i]["Types"].ToString()
                                    });


                                    a1014++;
                                }
                            }
                            else
                            {
                                break;
                            }
                        }
                        catch (Exception)
                        {
                            //1.0.1.3兼容
                            if (a1014 == 0)
                            {
                                for (int i = 0; ; i++)
                                {
                                    Roomlist.Add(new Room.RoomCadr()
                                    {
                                        Name = jo["data"][i]["Name"].ToString(), RoomNumber = jo["data"][i]["RoomNumber"].ToString(), status = ((jo["data"][i]["Ty"].ToString() == "True") ? true : false), Types = "bilibili"
                                    });
                                }
                            }
                            else
                            {
                                break;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                string A = ex.ToString();
            }
        }