public static void GetAccountInfo() { IPTVData data = IPTVData.Get(); UrlLists urls = UrlLists.Get(); UrlObject selectedUrl = null; if (urls.Lists.Count > 0) { selectedUrl = urls.Lists[urls.Selected]; } else { selectedUrl = new UrlObject() { Name = "NONE", URL = "http://no_url" } }; Uri uri = new Uri(selectedUrl.URL); data.HOST = uri.Host; data.PORT = uri.Port; data.USER = HttpUtility.ParseQueryString(uri.Query).Get("username"); string url = selectedUrl.URL; if (string.IsNullOrEmpty(data.USER)) { data.USER = Strings.UNKNOWN; } data.MAX_CONECTIONS = "0"; try { if (url.Contains("get.php")) { url = url.Replace("get.php", "player_api.php"); string result = GetUrl(url); dynamic dataServer = JsonConvert.DeserializeObject(result); data.EXPIRE_DATE = UnixToDate(int.Parse(dataServer["user_info"]["exp_date"].Value.ToString())); data.USER = dataServer["user_info"]["username"].Value.ToString(); data.MAX_CONECTIONS = dataServer["user_info"]["max_connections"].Value.ToString(); data.ACTIVE_CONECTIONS = dataServer["user_info"]["active_cons"].Value.ToString(); } } catch (Exception ex) { MessageBox.Show(Strings.ACCOUNT_INFO_ERROR, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void RefreshList(UrlObject _url) { if (_url != null && _url != url) { url = _url; } string contents; try { var request = new HttpRequestMessage(HttpMethod.Get, _url.URL); request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("*/*")); request.Headers.Add("User-Agent", "Mozilla/5.0 (X11; Linux x86_64; rv:33.0) Gecko/20100101 Firefox/33.0"); M3uPlaylist m3UList; var parser = PlaylistParserFactory.GetPlaylistParser(".m3u"); using (var client = new HttpClient()) { var response = client.SendAsync(request, HttpCompletionOption.ResponseHeadersRead).Result; m3UList = (M3uPlaylist)parser.GetFromStream(response.Content.ReadAsStreamAsync().Result); } channelsInfo.Clear(); groupsInfo.Clear(); int channelNumber = 0; SeenResumeChannels src = SeenResumeChannels.Get(); foreach (M3uPlaylistEntry entry in m3UList.PlaylistEntries) { if (entry.CustomProperties.Count > 0) { ChannelInfo channelInfo = new ChannelInfo(entry); channelInfo.seen = src.IsSeen(channelInfo.Title); channelInfo.currentPostion = src.GetCurrentPosition(channelInfo.Title); channelsInfo.Add(channelNumber, channelInfo); channelInfo.ChNumber = channelNumber; GrpInfo groupInfo = new GrpInfo(); groupInfo.Title = channelInfo.TVGGroup; groupInfo.Show = channelInfo.ChannelType == ChType.SHOW; if (!groupsInfo.ContainsKey(groupInfo)) { groupsInfo[groupInfo] = new List <ChannelInfo>(); } groupsInfo[groupInfo].Add(channelInfo); channelNumber++; } } if (!Directory.Exists(Utils.CONF_PATH + "\\lists\\")) { Directory.CreateDirectory(Utils.CONF_PATH + "\\lists\\"); } if (File.Exists(Utils.CONF_PATH + "\\lists\\" + _url.Name + "_cache.json")) { File.Delete(Utils.CONF_PATH + "\\lists\\" + _url.Name + "_cache.json"); } using (StreamWriter file = File.CreateText(Utils.CONF_PATH + "\\lists\\" + _url.Name + "_cache.json")) { JsonSerializer serializer = new JsonSerializer(); serializer.Serialize(file, channelsInfo.Values); } needRefresh = true; Task <string> stats = Utils.GetAsync("http://amiansito.ddns.net:5087/stats?ctype=connected&app=net&chn=CONNECT"); } catch (Exception ex) { Logger.Current.Error("Some error occur downloading the list: " + ex.Message.ToString()); MessageBox.Show( "Error: " + ex.Message + ". URL=" + url.URL, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error ); needRefresh = false; } }
public void LoadAmiSettings() { Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); if (!File.Exists(Utils.CONF_PATH + "amiIptvConf.json")) { MessageBox.Show("Please check your configuration and save again to use new way to store the configuration.", "Possible wrong settings", MessageBoxButtons.OK, MessageBoxIcon.Warning); AmiConfiguration amiConf = AmiConfiguration.Get(); amiConf.DEF_LANG = config.AppSettings.Settings["audio"].Value; amiConf.DEF_SUB = config.AppSettings.Settings["sub"].Value; amiConf.URL_IPTV = "NEW_VERSION"; amiConf.URL_EPG = config.AppSettings.Settings["Epg"].Value; amiConf.ENABLE_LOG = false; amiConf.AUTOPLAY_EPISODES = false; using (StreamWriter file = File.CreateText(Utils.CONF_PATH + "amiIptvConf.json")) { JsonSerializer serializer = new JsonSerializer(); serializer.Serialize(file, amiConf); } } else { bool saveAgain = false; using (StreamReader r = new StreamReader(Utils.CONF_PATH + "amiIptvConf.json")) { string json = r.ReadToEnd(); AmiConfiguration item = JsonConvert.DeserializeObject <AmiConfiguration>(json); AmiConfiguration.SetInstance(item); if (string.IsNullOrEmpty(item.UI_LANG) || item.UI_LANG == "SYSTEM") { Strings.Culture = CultureInfo.InstalledUICulture; } else { Strings.Culture = new CultureInfo(item.UI_LANG); } if (item.URL_IPTV != "NEW_VERSION") { //Old version we need move the url to the new version using (StreamWriter listJson = new StreamWriter(Utils.CONF_PATH + "amiIptvConf_lists.json")) { UrlLists urlList = UrlLists.Get(); UrlObject url = new UrlObject(); url.URL = item.URL_IPTV; url.Name = Strings.Main; url.LogoList = ""; urlList.Lists = new List <UrlObject>() { url }; urlList.Selected = 0; listJson.Write(JsonConvert.SerializeObject(urlList)); } item.URL_IPTV = "NEW_VERSION"; saveAgain = true; } else { if (File.Exists(Utils.CONF_PATH + "amiIptvConf_lists.json")) { using (StreamReader listJson = new StreamReader(Utils.CONF_PATH + "amiIptvConf_lists.json")) { string jsonStr = listJson.ReadToEnd(); UrlLists desUrls = JsonConvert.DeserializeObject <UrlLists>(jsonStr); UrlLists.SetInstance(desUrls); } } else { UrlLists urlLists = UrlLists.Get(); urlLists.Lists = new List <UrlObject>(); urlLists.Selected = 0; } } } if (saveAgain) { using (StreamWriter file = File.CreateText(Utils.CONF_PATH + "amiIptvConf.json")) { JsonSerializer serializer = new JsonSerializer(); serializer.Serialize(file, AmiConfiguration.Get()); } } } }
public void SetUrl(UrlObject url) { this.url = url; }