private void LoadChannels()
        {
            UrlLists urls        = UrlLists.Get();
            Channels channels    = Channels.Get();
            bool     withoutUrls = false;
            bool     refreshList = false;

            if (urls.Lists.Count > 0)
            {
                channels.SetUrl(urls.Lists[urls.Selected]);
            }
            else
            {
                channels.SetUrl(new UrlObject()
                {
                    Name = "NONE", URL = "http://no_url"
                });
                withoutUrls = true;
            }
            if (!withoutUrls && File.Exists(Utils.CONF_PATH + "\\lists\\" + urls.Lists[urls.Selected].Name + "_cache.json"))
            {
                channels = Channels.LoadFromJSON();
                fillChannelList();
                DateTime creationCacheChannel = File.GetLastWriteTimeUtc(Utils.CONF_PATH + "\\lists\\" + urls.Lists[urls.Selected].Name + "_cache.json");
                if (File.Exists(Utils.CONF_PATH + "\\lists\\" + urls.Lists[urls.Selected].Name + "_cache.json") &&
                    creationCacheChannel.Day < DateTime.Now.Day - 1)
                {
                    refreshList = true;
                }
            }
            else
            {
                ChannelInfo ch = new ChannelInfo();
                ch.Title = Strings.DEFAULT_MSG_NO_LIST;
                ListViewItem i = new ListViewItem("0");
                i.SubItems.Add(Strings.DEFAULT_MSG_NO_LIST);
                chList.Invoke((System.Threading.ThreadStart) delegate
                {
                    chList.Items.Add(i);
                });
                var x = new ChannelListItem(ch.Title, ch.ChNumber);
                x.Seen   = ch.seen;
                x.Resume = ch.currentPostion != null;
                lstListsChannels[ALL_GROUP].Add(x);
                lstChannels.Add(x);
                if (urls.Lists.Count > 0 && !File.Exists(Utils.CONF_PATH + "\\lists\\" + urls.Lists[urls.Selected].Name + "_cache.json"))
                {
                    refreshList = true;
                }
            }

            FillGroups();

            if (refreshList)
            {
                RefreshChList(true);
            }
        }
 public static UrlLists Get()
 {
     if (instance == null)
     {
         instance       = new UrlLists();
         instance.Lists = new List <UrlObject>();
     }
     return(instance);
 }
Example #3
0
        private void FillList()
        {
            iptvList.Items.Clear();
            foreach (var url in UrlLists.Get().Lists)
            {
                ListViewItem i = new ListViewItem(url.Name);
                i.SubItems.Add(url.URL);

                iptvList.BeginUpdate();
                iptvList.Items.Add(i);
                iptvList.EndUpdate();
            }
        }
Example #4
0
 private void btnClose_Click(object sender, EventArgs e)
 {
     if (Save)
     {
         using (StreamWriter listJson = new StreamWriter(Utils.CONF_PATH + "amiIptvConf_lists.json"))
         {
             UrlLists urlList = UrlLists.Get();
             urlList.Refresh = true;
             listJson.Write(JsonConvert.SerializeObject(urlList));
         }
     }
     this.Close();
 }
        private void manageListToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ManageLists mgList = new ManageLists();

            mgList.ShowDialog();
            if (UrlLists.Get().Refresh)
            {
                cmbLists.SelectedIndexChanged -= new System.EventHandler(this.cmbLists_SelectedIndexChanged);
                FillIPTVLists();
                UrlLists.Get().Refresh = false;
                cmbLists.SelectedIndexChanged += new System.EventHandler(this.cmbLists_SelectedIndexChanged);
            }
        }
Example #6
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     if (iptvList.SelectedItems.Count < 1)
     {
         MessageBox.Show(Strings.ERROR_SELECT_IPTV_LIST, Strings.WARN, MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else
     {
         foreach (ListViewItem item in iptvList.SelectedItems)
         {
             UrlLists.Get().Remove(item.Text);
             FillList();
         }
     }
 }
        public static Channels LoadFromJSON()
        {
            if (instance == null)
            {
                instance = new Channels();
            }
            UrlLists urls = UrlLists.Get();

            using (StreamReader r = new StreamReader(Utils.CONF_PATH + "\\lists\\" + urls.Lists[urls.Selected].Name + "_cache.json"))
            {
                string             json  = r.ReadToEnd();
                List <ChannelInfo> items = JsonConvert.DeserializeObject <List <ChannelInfo> >(json);
                instance.FillFromListChannelInfo(items);
            }
            return(instance);
        }
        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);
            }
        }
        private void cmbLists_SelectedIndexChanged(object sender, EventArgs e)
        {
            int selected = ((ComboBox)sender).SelectedIndex;

            UrlLists.Get().Selected = selected;
            loadingPanel.Visible = true;

            loadingPanel.Size = this.Size;
            loadingPanel.BringToFront();
            new System.Threading.Thread(delegate()
            {
                LoadChannels();
                loadingPanel.Invoke((System.Threading.ThreadStart) delegate {
                    loadingPanel.Visible = false;
                    loadingPanel.Size    = new Size(20, 20);
                });
            }).Start();
        }
 public static Channels Get()
 {
     if (instance == null)
     {
         instance = new Channels();
         if (UrlLists.Get().Lists.Count > 0)
         {
             instance.SetUrl(UrlLists.Get().Lists[UrlLists.Get().Selected]);
         }
         else
         {
             instance.SetUrl(new UrlObject()
             {
                 Name = "NONE", URL = "http://no_url"
             });
         }
     }
     return(instance);
 }
Example #11
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            UrlLists urls = UrlLists.Get();

            if (string.IsNullOrEmpty(txtUrl.Text) || string.IsNullOrEmpty(txtName.Text))
            {
                MessageBox.Show(Strings.FillUrlError, Strings.ERROR, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                try
                {
                    HttpUtility.ParseQueryString(txtUrl.Text);
                    if (!EditMode)
                    {
                        urls.Add(txtName.Text, txtUrl.Text);
                        ListViewItem i = new ListViewItem(txtName.Text);
                        i.SubItems.Add(txtUrl.Text);
                        iptvList.BeginUpdate();
                        iptvList.Items.Add(i);
                        iptvList.EndUpdate();
                    }
                    else
                    {
                        urls.Remove(EditNameList);
                        urls.Add(txtName.Text, txtUrl.Text);
                        EditMode     = false;
                        EditNameList = "";
                        btnAdd.Text  = Strings.Add;
                        FillList();
                    }
                    txtName.Text = "";
                    txtUrl.Text  = "";
                    Save         = true;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(Strings.FillUrlError + ":" + ex.Message, Strings.ERROR, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
        private void FillIPTVLists()
        {
            UrlLists urls = UrlLists.Get();

            if (urls.Lists.Count > 0)
            {
                if (cmbLists.Items != null)
                {
                    cmbLists.Items.Clear();
                }

                foreach (var item in urls.Lists)
                {
                    cmbLists.Items.Add(item.Name);
                }
                if (urls.Selected >= urls.Lists.Count)
                {
                    urls.Selected = urls.Lists.Count - 1;
                }
                cmbLists.SelectedIndex = urls.Selected;
            }
        }
 public static void SetInstance(UrlLists value)
 {
     instance = value;
 }
Example #14
0
        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 RefreshList()
 {
     RefreshList(UrlLists.Get().Lists[UrlLists.Get().Selected]);
 }