public void SendEmail(string htmlString)
 {
     try
     {
         MailMessage message = new MailMessage();
         SmtpClient  smtp    = new SmtpClient();
         message.From = new MailAddress("*****@*****.**");
         message.To.Add(new MailAddress(AmiConfiguration.Get().REQ_EMAIL));
         message.Subject            = Strings.SubjectEmail;
         message.IsBodyHtml         = true; //to make message body as html
         message.Body               = htmlString;
         smtp.Port                  = 587;
         smtp.Host                  = "smtp.gmail.com"; //for gmail host
         smtp.EnableSsl             = true;
         smtp.UseDefaultCredentials = false;
         smtp.Credentials           = new NetworkCredential("*****@*****.**", "%@tB53!oqW");
         smtp.DeliveryMethod        = SmtpDeliveryMethod.Network;
         smtp.Send(message);
         this.Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show(Strings.ERROR + ": " + ex.Message, Strings.ERROR, MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
示例#2
0
        public static void GetAccountInfo()
        {
            string   url  = AmiConfiguration.Get().URL_IPTV;
            IPTVData data = IPTVData.Get();
            Uri      uri  = new Uri(AmiConfiguration.Get().URL_IPTV);

            data.HOST = uri.Host;
            data.PORT = uri.Port;
            data.USER = HttpUtility.ParseQueryString(uri.Query).Get("username");
            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 StopPlayEvent(object sender, EventArgs e)
        {
            if (AmiConfiguration.Get().ENABLE_LOG)
            {
                Logger.Current.Debug($"[STOPPLAYEVENT] MPV stopped the streaming with values: exitApp => {exitApp.ToString()} and dockedEvent {dockedEvent.ToString()}");
            }
            //currentChannel = null;
            if (positioncchangedevent)
            {
                player.PositionChanged -= PositionChanged;
                positioncchangedevent   = false;
            }
            btnPlayPause.BackgroundImage       = Image.FromFile("./resources/images/play.png");
            btnPlayPause.BackgroundImageLayout = ImageLayout.Stretch;

            if (!exitApp)
            {
                lbDuration.Invoke((System.Threading.ThreadStart) delegate
                {
                    lbDuration.Text = Strings.Duration + "--/--";
                });
                if (dockedEvent)
                {
                    if (InvokeRequired)
                    {
                        Invoke((MethodInvoker) delegate { principalForm.ShowAgainPlayer(); });
                    }
                }
            }
        }
 public static AmiConfiguration Get()
 {
     if (instance == null)
     {
         instance = new AmiConfiguration();
     }
     return(instance);
 }
 private void btnSend_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(txtTitle.Text))
     {
         MessageBox.Show(Strings.FillReqVOD, Strings.ERROR, MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     if (!String.IsNullOrEmpty(AmiConfiguration.Get().REQ_EMAIL))
     {
         var overview      = "";
         var title         = txtTitle.Text;
         var year          = txtYear.Text;
         var stype         = cmbTypes.SelectedItem.ToString();
         var originalTitle = "";
         var logo          = "https://i.ibb.co/vP1QYdy/No-Cover-Image-01.png";
         if (!chSenAdition.Checked && SEToSend != null)
         {
             overview = SEToSend.SearchData["overview"]?.ToString();
             if (SEToSend.SearchData["poster_path"] != null)
             {
                 logo = Utils.LogoUrl(SEToSend.SearchData["poster_path"].ToString());
             }
             if (stype == Strings.Movie)
             {
                 originalTitle = SEToSend.SearchData["original_title"]?.ToString();
             }
             else
             {
                 originalTitle = SEToSend.SearchData["original_name"]?.ToString();
             }
         }
         string template = File.ReadAllText("./resources/emailtemplate.html");
         template = template.Replace("$$EMAILHEADER$$", Strings.EmailHeader);
         template = template.Replace("$$EMAILTEXT$$", Strings.EmailText);
         template = template.Replace("$$NAMETITLE$$", Strings.FITitle);
         template = template.Replace("$$ONAMETITLE$$", Strings.FIOrigTitle);
         template = template.Replace("$$OVERVIEWTITLE$$", Strings.lbDescriptionTitle);
         template = template.Replace("$$TYPETITLE$$", Strings.Type);
         template = template.Replace("$$YEARTITLE$$", Strings.FIYear);
         template = template.Replace("$$POSTERTITLE$$", Strings.PosterEmail);
         template = template.Replace("$$THANKS$$", Strings.ThanksEmail);
         template = template.Replace("$$USERTITLE$$", Strings.User);
         template = template.Replace("$$NAME$$", title);
         template = template.Replace("$$ONAME$$", originalTitle);
         template = template.Replace("$$OVERVIEW$$", overview);
         template = template.Replace("$$TYPE$$", stype);
         template = template.Replace("$$YEAR$$", year);
         template = template.Replace("$$URL$$", logo);
         template = template.Replace("$$USER$$", IPTVData.Get().USER);
         SendEmail(template);
     }
     else
     {
         MessageBox.Show(Strings.FillReqEmail, Strings.ERROR, MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
示例#6
0
        public static Channels Get()
        {
            if (instance == null)
            {
                instance = new Channels();

                instance.SetUrl(AmiConfiguration.Get().URL_IPTV);
            }
            return(instance);
        }
示例#7
0
 private void PositionChanged(object sender, EventArgs e)
 {
     if (player.IsPlaying)
     {
         if (seekBar.Enabled)
         {
             seekBar.Invoke((System.Threading.ThreadStart) delegate
             {
                 try
                 {
                     seekBar.Value = Convert.ToInt32(player.Position.TotalSeconds);
                 }
                 catch (MpvAPIException ex) {
                     Utils.WriteMPVLog(ex.Message, MpvLogLevel.Warning);
                     Stop();
                     return;
                 }
             });
             string durationText = (player.Duration.Hours < 10 ? "0" + player.Duration.Hours.ToString() : player.Duration.Hours.ToString())
                                   + ":" + (player.Duration.Minutes < 10 ? "0" + player.Duration.Minutes.ToString() : player.Duration.Minutes.ToString())
                                   + ":" + (player.Duration.Seconds < 10 ? "0" + player.Duration.Seconds.ToString() : player.Duration.Seconds.ToString());
             string positionText = (player.Position.Hours < 10 ? "0" + player.Position.Hours.ToString() : player.Position.Hours.ToString())
                                   + ":" + (player.Position.Minutes < 10 ? "0" + player.Position.Minutes.ToString() : player.Position.Minutes.ToString())
                                   + ":" + (player.Position.Seconds < 10 ? "0" + player.Position.Seconds.ToString() : player.Position.Seconds.ToString());
             lbDuration.Invoke((System.Threading.ThreadStart) delegate
             {
                 lbDuration.Text = Strings.Duration + positionText + " / " + durationText;
             });
         }
         if (player.Position.TotalSeconds > 0 && player.Position.TotalSeconds >= player.Duration.TotalSeconds - 300)
         {
             if (!principalForm.GetCurrentChannel().seen)
             {
                 SeenResumeChannels.Get().UpdateOrSetSeen(principalForm.GetCurrentChannel().Title, true, player.Duration.TotalSeconds, DateTime.Now);
                 principalForm.GetCurrentChannel().seen = true;
                 principalForm.RefreshListView();
             }
         }
         if (player.Position.TotalSeconds >= 150)
         {
             if (principalForm.GetCurrentChannel().currentPostion == null)
             {
                 SeenResumeChannels.Get().UpdateOrSetResume(principalForm.GetCurrentChannel().Title, player.Position.TotalSeconds, player.Duration.TotalSeconds, DateTime.Now);
                 principalForm.GetCurrentChannel().currentPostion = player.Position.TotalSeconds;
                 principalForm.RefreshListView();
             }
             principalForm.GetCurrentChannel().currentPostion = player.Position.TotalSeconds;
         }
         if (AmiConfiguration.Get().AUTOPLAY_EPISODES)
         {
             CheckNextEpisode();
         }
     }
 }
 private void btnOK_Click(object sender, EventArgs e)
 {
     if (Utils.Base64Encode(txtPass.Text) == AmiConfiguration.Get().PARENTAL_PASS)
     {
         this.DialogResult = DialogResult.OK;
         this.Close();
     }
     else
     {
         lbAsk.Text = Strings.lbAskPassError + "\n" + Strings.lbAskPass;
     }
 }
示例#9
0
        private void ParseTracksAndSetDefaults()
        {
            LoadAllTracks();
            CleanCmbLangSub();


            string audioConf = AmiConfiguration.Get().DEF_LANG;
            string subConf   = AmiConfiguration.Get().DEF_SUB;

            FillAndSetLangSub(tracksParser[TrackType.AUDIO], cmbLangs, audioConf, 0);
            FillAndSetLangSub(tracksParser[TrackType.SUB], cmbSubs, subConf, 1);
        }
        private void Preferences_Load(object sender, EventArgs e)
        {
            ReloadLang();
            AmiConfiguration amiconf = AmiConfiguration.Get();

            txtURL.Text             = amiconf.URL_IPTV;
            txtEPG.Text             = amiconf.URL_EPG;
            txtRequestEmail.Text    = amiconf.REQ_EMAIL;
            txtParentalControl.Text = Utils.Base64Decode(amiconf.PARENTAL_PASS);
            string audioConf = amiconf.DEF_LANG;

            audio.SelectedItem = Utils.audios[audioConf];
            string subConf = amiconf.DEF_SUB;

            sub.SelectedItem = Utils.subs[subConf];
        }
示例#11
0
        public void RepaintLabels()
        {
            parentalControlToolStripMenuItem.Text = Strings.ParentalControl;
            FileToolStripMenuItem.Text            = Strings.FileTool;
            settingsToolStripMenuItem.Text        = Strings.Settings;
            refreshEPGToolStripMenuItem.Text      = Strings.RefreshEPGTool;
            refreshListToolStripMenuItem.Text     = Strings.RefreshListTool;
            quitToolStripMenuItem.Text            = Strings.QUIT;
            helpToolStripMenuItem.Text            = Strings.HELP;
            aboutToolStripMenuItem.Text           = Strings.AboutUsTitle;
            toolsToolStripMenuItem.Text           = Strings.Tools;
            requestNewVODToolStripMenuItem.Text   = Strings.RequestNewVOD;
            btnClear.Text                     = Strings.CLEAR;
            btnFilter.Text                    = Strings.FILTER;
            btnFixId.Text                     = Strings.FixIdentTitle;
            btnURLInfo.Text                   = Strings.URLinfo;
            lbGroups.Text                     = Strings.GROUPS;
            lbFilterList.Text                 = Strings.FilterList;
            lbDescriptionTitle.Text           = Strings.lbDescriptionTitle + ":";
            lbTitleTitle.Text                 = Strings.lbTitleTitle + ":";
            lbYearsTitle.Text                 = Strings.lbYearsTitle;
            lbVersionText.Text                = Strings.Version;
            lbEPGLoaded.Text                  = Strings.EPGloaded;
            lbEndTimeTitle.Text               = Strings.lbEndTimeTitle;
            lbStarsTitle.Text                 = Strings.lbStarsTitle;
            lbStartTimeTitle.Text             = Strings.lbStartTimeTitle;
            lbList.Text                       = Strings.lbIptvLists + ":";
            chName.Text                       = Strings.lbTitleTitle + ":";
            donationToolStripMenuItem.Text    = Strings.Donation;
            accountInfoToolStripMenuItem.Text = Strings.AccountInfoTitle;
            manageListToolStripMenuItem.Text  = Strings.ManageLists;
            playerForm.ReloadLang();
            ALL_GROUP = Strings.ALLGROUP;
            RepaintEPGLoadedLabel();
            EMPTY_GROUP = Strings.WOGROUP;

            HistoryMenuItem1.Text = Strings.lbHistory;
            if (AmiConfiguration.Get().REMOVE_DONATE)
            {
                donateButton.Visible = false;
            }
            else
            {
                donateButton.Visible = true;
            }
        }
 public void ReloadLang()
 {
     lbDuration.Text = Strings.Duration + "--/--";
     lbVol.Text      = Strings.Volume;
     lbLang.Text     = Strings.Language;
     lbSub.Text      = Strings.Subs;
     pnPrincipal.RowStyles[0].Height = 0;
     pnPrincipal.RowStyles[1].Height = 0;
     if (AmiConfiguration.Get().ENABLE_LOG)
     {
         player.LogLevel = MpvLogLevel.Debug;
     }
     else
     {
         player.LogLevel = MpvLogLevel.Info;
     }
 }
示例#13
0
        private void settingsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Preferences pref = new Preferences();

            pref.PrincipalForm = this;

            pref.ShowDialog();

            EPG_DB epgDB = EPG_DB.Get();

            if (epgDB.Refresh)
            {
                loadingPanel.Visible = true;
                loadingPanel.Size    = this.Size;
                loadingPanel.BringToFront();
                DownloadEPGFile(epgDB, AmiConfiguration.Get().URL_EPG);
            }
        }
        private void Preferences_Load(object sender, EventArgs e)
        {
            ReloadLang();
            AmiConfiguration amiconf = AmiConfiguration.Get();

            txtEPG.Text             = amiconf.URL_EPG;
            txtRequestEmail.Text    = amiconf.REQ_EMAIL;
            txtParentalControl.Text = Utils.Base64Decode(amiconf.PARENTAL_PASS);
            string audioConf = amiconf.DEF_LANG;

            audio.SelectedItem = Utils.audios[audioConf];
            string subConf = amiconf.DEF_SUB;

            sub.SelectedItem           = Utils.subs[subConf];
            chLog.Checked              = amiconf.ENABLE_LOG;
            chDonate.Checked           = amiconf.REMOVE_DONATE;
            chAutoPlayEpisodes.Checked = amiconf.AUTOPLAY_EPISODES;
        }
        private void LoadEPG()
        {
            EPG_DB epg = EPG_DB.Get();

            epg.epgEventFinish += FinishLoadEpg;
            DefaultEpgLabels();
            logoEPG.Image = Image.FromFile("./resources/images/info.png");

            if (File.Exists(Utils.CONF_PATH + "amiiptvepgCache.json"))
            {
                epg = EPG_DB.LoadFromJSON();
            }

            DateTime creation = File.GetLastWriteTimeUtc(Utils.CONF_PATH + "amiiptvepgCache.json");

            if (File.Exists(Utils.CONF_PATH + "amiiptvepgCache.json") &&
                creation.Day < DateTime.Now.Day - 1)
            {
                DownloadEPGFile(epg, AmiConfiguration.Get().URL_EPG);
            }
            else
            {
                if (File.Exists(Utils.CONF_PATH + "amiiptvepgCache.json"))
                {
                    epg = EPG_DB.LoadFromJSON();
                }
                else if (File.Exists(Utils.CONF_PATH + "amiiptvepg.xml"))
                {
                    lbProcessingEPG.Text = Strings.LOADING;
                    epg.ParseDB();
                }
                else
                {
                    DownloadEPGFile(epg, "http://bit.ly/AVappEPG");
                    AmiConfiguration amiConf = AmiConfiguration.Get();
                    amiConf.URL_EPG = "http://bit.ly/AVappEPG";
                    using (StreamWriter file = File.CreateText(Utils.CONF_PATH + "amiIptvConf.json"))
                    {
                        JsonSerializer serializer = new JsonSerializer();
                        serializer.Serialize(file, amiConf);
                    }
                }
            }
        }
 private void parentalControlToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (String.IsNullOrEmpty(AmiConfiguration.Get().PARENTAL_PASS))
     {
         MessageBox.Show(Strings.FillParentalPass, Strings.ERROR, MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else
     {
         using (var askForm = new AskPass())
         {
             var result = askForm.ShowDialog();
             if (result == DialogResult.OK)
             {
                 ParentalControlForm pcontrol = new ParentalControlForm();
                 pcontrol.ShowDialog();
             }
         }
     }
 }
        public void ReloadLang()
        {
            Utils.ReloadLangs();
            AmiConfiguration amiconf = AmiConfiguration.Get();

            cmbUI.Items.Clear();
            if (string.IsNullOrEmpty(amiconf.UI_LANG))
            {
                amiconf.UI_LANG = "SYSTEM";
            }
            cmbUI.Items.Add(Strings.LangSYS);
            cmbUI.Items.Add(Strings.LangSP);
            cmbUI.Items.Add(Strings.LangEN);
            cmbUI.Items.Add(Strings.LangCAT);
            cmbUI.Items.Add(Strings.LangFR);
            cmbUI.Items.Add(Strings.LangTR);
            cmbUI.SelectedIndex = amiconf.availableLangs[amiconf.UI_LANG];

            audio.Items.Clear();
            foreach (string item in Utils.audios.Values)
            {
                audio.Items.Add(item);
            }

            sub.Items.Clear();
            foreach (string item in Utils.subs.Values)
            {
                sub.Items.Add(item);
            }

            lbSettingsDefAud.Text   = Strings.lbSettingsDefAud;
            lbSettingsDefSub.Text   = Strings.lbSettingsDefSub;
            lbSettingsEPG.Text      = Strings.lbSettingsEPG;
            lbSettingsUILang.Text   = Strings.lbSettingsUILang;
            lbRequestEmail.Text     = Strings.lbRequestEmail;
            lbParentalControl.Text  = Strings.lbParentalControl + ":";
            lbAutoPlayEpisodes.Text = Strings.AutoPlayEpisodes + ":";
            lbDonate.Text           = Strings.RemoveDonate + ":";
            lbLog.Text     = Strings.lbLog + ":";
            this.Text      = Strings.PreferencesTitle;
            btnCancel.Text = Strings.CANCEL;
            btnOk.Text     = Strings.SAVE;
        }
        private void settingsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Preferences pref = new Preferences();

            pref.PrincipalForm = this;

            pref.ShowDialog();
            Channels channels = Channels.Get();

            if (channels.NeedRefresh())
            {
                loadingPanel.Visible = true;

                loadingPanel.Size = this.Size;
                loadingPanel.BringToFront();
                new System.Threading.Thread(delegate()
                {
                    channels.RefreshList();
                    fillChannelList();
                    cmbGroups.Invoke((System.Threading.ThreadStart) delegate
                    {
                        cmbGroups.Items.Clear();
                        foreach (string group in lstListsChannels.Keys)
                        {
                            cmbGroups.Items.Add(group);
                        }
                    });
                    loadingPanel.Invoke((System.Threading.ThreadStart) delegate {
                        loadingPanel.Visible = false;
                        loadingPanel.Size    = new Size(20, 20);
                    });
                }).Start();
            }
            EPG_DB epgDB = EPG_DB.Get();

            if (epgDB.Refresh)
            {
                loadingPanel.Visible = true;
                loadingPanel.Size    = this.Size;
                loadingPanel.BringToFront();
                DownloadEPGFile(epgDB, AmiConfiguration.Get().URL_EPG);
            }
        }
        private void LoadChannels()
        {
            Channels channels = Channels.Get();

            channels.SetUrl(AmiConfiguration.Get().URL_IPTV);
            if (File.Exists(Utils.CONF_PATH + "channelCache.json"))
            {
                channels = Channels.LoadFromJSON();
                fillChannelList();
            }
            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.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);
            }

            cmbGroups.Items.Clear();

            foreach (string group in lstListsChannels.Keys)
            {
                cmbGroups.Items.Add(group);
            }
            cmbGroups.SelectedIndex = 0;

            DateTime creationCacheChannel = File.GetLastWriteTimeUtc(Utils.CONF_PATH + "channelCache.json");

            if (File.Exists(Utils.CONF_PATH + "channelCache.json") &&
                creationCacheChannel.Day < DateTime.Now.Day - 1)
            {
                RefreshChList(false);
            }
        }
        private void cmbUI_SelectedIndexChanged(object sender, EventArgs e)
        {
            AmiConfiguration amiConfg = AmiConfiguration.Get();

            foreach (var item in amiConfg.availableLangs)
            {
                if (item.Value == cmbUI.SelectedIndex && amiConfg.UI_LANG != item.Key)
                {
                    amiConfg.UI_LANG = item.Key;
                    if (item.Key == "SYSTEM")
                    {
                        Strings.Culture = CultureInfo.InstalledUICulture;
                    }
                    else
                    {
                        Strings.Culture = new CultureInfo(AmiConfiguration.Get().UI_LANG);
                    }
                    this.Preferences_Load(null, null);
                    PrincipalForm.RepaintLabels();
                }
            }
        }
        private 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   = config.AppSettings.Settings["Url"].Value;
                amiConf.URL_EPG    = config.AppSettings.Settings["Epg"].Value;
                amiConf.ENABLE_LOG = false;
                using (StreamWriter file = File.CreateText(Utils.CONF_PATH + "amiIptvConf.json"))
                {
                    JsonSerializer serializer = new JsonSerializer();
                    serializer.Serialize(file, amiConf);
                }
            }
            else
            {
                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);
                    }
                }
            }
        }
        private void Ok()
        {
            AmiConfiguration amiconf = AmiConfiguration.Get();
            var encode = Utils.Base64Encode(txtParentalControl.Text);

            if (amiconf.PARENTAL_PASS != encode && !string.IsNullOrEmpty(txtParentalControl.Text))
            {
                if (!string.IsNullOrEmpty(amiconf.PARENTAL_PASS))
                {
                    using (var askForm = new AskPass())
                    {
                        var result = askForm.ShowDialog();
                        if (result == DialogResult.Cancel)
                        {
                            return;
                        }
                    }
                }
                amiconf.PARENTAL_PASS = encode;
            }
            if (string.IsNullOrEmpty(txtParentalControl.Text) && !string.IsNullOrEmpty(amiconf.PARENTAL_PASS))
            {
                if (!string.IsNullOrEmpty(amiconf.PARENTAL_PASS))
                {
                    using (var askForm = new AskPass())
                    {
                        var result = askForm.ShowDialog();
                        if (result == DialogResult.Cancel)
                        {
                            return;
                        }
                    }
                }

                amiconf.PARENTAL_PASS = "";
            }
            amiconf.URL_IPTV = "NEW_VERSION";

            /*if (amiconf.URL_IPTV != txtURL.Text)
             * {
             *  amiconf.URL_IPTV = txtURL.Text;
             *  Channels channels = Channels.Get();
             *  channels.SetUrl(txtURL.Text);
             *  channels.SetNeedRefresh(true);
             * }
             * else
             * {
             *  Channels channels = Channels.Get();
             *  channels.SetNeedRefresh(false);
             * }*/
            if (amiconf.REQ_EMAIL != txtRequestEmail.Text)
            {
                amiconf.REQ_EMAIL = txtRequestEmail.Text;
            }

            if (amiconf.URL_EPG != txtEPG.Text)
            {
                amiconf.URL_EPG = txtEPG.Text;
                EPG_DB epgDB = EPG_DB.Get();
                epgDB.Refresh = true;
            }
            if (!amiconf.ENABLE_LOG && chLog.Checked)
            {
                amiconf.ENABLE_LOG = true;
                PrincipalForm.RepaintLabels();
            }
            if (amiconf.ENABLE_LOG && !chLog.Checked)
            {
                amiconf.ENABLE_LOG = false;
                PrincipalForm.RepaintLabels();
            }
            if (!amiconf.AUTOPLAY_EPISODES && chAutoPlayEpisodes.Checked)
            {
                amiconf.AUTOPLAY_EPISODES = true;
                PrincipalForm.RepaintLabels();
            }
            if (amiconf.AUTOPLAY_EPISODES && !chAutoPlayEpisodes.Checked)
            {
                amiconf.AUTOPLAY_EPISODES = false;
                PrincipalForm.RepaintLabels();
                PrincipalForm.HideAutoPlay();
            }
            if (!amiconf.REMOVE_DONATE && chDonate.Checked)
            {
                amiconf.REMOVE_DONATE = true;
                PrincipalForm.RepaintLabels();
            }
            if (amiconf.REMOVE_DONATE && !chDonate.Checked)
            {
                amiconf.REMOVE_DONATE = false;
                PrincipalForm.RepaintLabels();
            }
            if (audio.SelectedItem != null)
            {
                amiconf.DEF_LANG = Utils.GetAudioConfName(audio.SelectedItem.ToString());
            }
            else
            {
                amiconf.DEF_LANG = "spa";
            }
            if (sub.SelectedItem != null)
            {
                amiconf.DEF_SUB = Utils.GetSubConfName(sub.SelectedItem.ToString());
            }
            else
            {
                amiconf.DEF_SUB = "none";
            }

            using (StreamWriter file = File.CreateText(Utils.CONF_PATH + "amiIptvConf.json"))
            {
                JsonSerializer serializer = new JsonSerializer();
                serializer.Serialize(file, amiconf);
            }

            this.Close();
            this.Dispose();
        }
        private void Ok()
        {
            AmiConfiguration amiconf = AmiConfiguration.Get();
            var encode = Utils.Base64Encode(txtParentalControl.Text);

            if (amiconf.PARENTAL_PASS != encode && !string.IsNullOrEmpty(txtParentalControl.Text))
            {
                if (!string.IsNullOrEmpty(amiconf.PARENTAL_PASS))
                {
                    using (var askForm = new AskPass())
                    {
                        var result = askForm.ShowDialog();
                        if (result == DialogResult.Cancel)
                        {
                            return;
                        }
                    }
                }
                amiconf.PARENTAL_PASS = encode;
            }
            if (string.IsNullOrEmpty(txtParentalControl.Text) && !string.IsNullOrEmpty(amiconf.PARENTAL_PASS))
            {
                if (!string.IsNullOrEmpty(amiconf.PARENTAL_PASS))
                {
                    using (var askForm = new AskPass())
                    {
                        var result = askForm.ShowDialog();
                        if (result == DialogResult.Cancel)
                        {
                            return;
                        }
                    }
                }

                amiconf.PARENTAL_PASS = "";
            }
            if (amiconf.URL_IPTV != txtURL.Text)
            {
                amiconf.URL_IPTV = txtURL.Text;
                Channels channels = Channels.Get();
                channels.SetUrl(txtURL.Text);
                channels.SetNeedRefresh(true);
            }
            else
            {
                Channels channels = Channels.Get();
                channels.SetNeedRefresh(false);
            }
            if (amiconf.REQ_EMAIL != txtRequestEmail.Text)
            {
                amiconf.REQ_EMAIL = txtRequestEmail.Text;
            }

            if (amiconf.URL_EPG != txtEPG.Text)
            {
                amiconf.URL_EPG = txtEPG.Text;
                EPG_DB epgDB = EPG_DB.Get();
                epgDB.Refresh = true;
            }
            amiconf.DEF_LANG = Utils.GetAudioConfName(audio.SelectedItem.ToString());
            amiconf.DEF_SUB  = Utils.GetSubConfName(sub.SelectedItem.ToString());

            using (StreamWriter file = File.CreateText(Utils.CONF_PATH + "amiIptvConf.json"))
            {
                JsonSerializer serializer = new JsonSerializer();
                serializer.Serialize(file, amiconf);
            }

            this.Close();
            this.Dispose();
        }
示例#24
0
 public static void SetInstance(AmiConfiguration value)
 {
     instance = value;
 }
        private void MediaLoaded(object sender, EventArgs e)
        {
            if (AmiConfiguration.Get().ENABLE_LOG)
            {
                string msg = "[MediaLoaded-MPV] MPV load streaming with next values: ";
                msg += $"SetPositionOnLoad => {SetPositionOnLoad} ";
                msg += $"currLang => {currLang} ";
                msg += $"isChannel=> {isChannel} ";
                msg += $"positioncchangedevent=> {positioncchangedevent} ";
                msg += $"player.Duration.TotalSeconds=> {player.Duration.TotalSeconds} ";
                Logger.Current.Debug(msg);
            }
            ParseTracksAndSetDefaults();

            if (!isChannel && player.Duration.TotalSeconds > 0)
            {
                seekBar.Invoke((System.Threading.ThreadStart) delegate {
                    seekBar.Enabled = true;
                    seekBar.Value   = 0;
                    seekBar.Maximum = Convert.ToInt32(player.Duration.TotalSeconds);
                    if (SetPositionOnLoad)
                    {
                        seekBar.Value = positionOnLoad;
                    }
                });
                if (!positioncchangedevent)
                {
                    player.PositionChanged += PositionChanged;
                    positioncchangedevent   = true;
                }
            }

            /*else
             * {
             *  cmbLangs.Invoke((System.Threading.ThreadStart)delegate
             *  {
             *      cmbLangs.Enabled = false;
             *      cmbLangs.Items.Clear();
             *  });
             *  cmbSubs.Invoke((System.Threading.ThreadStart)delegate
             *  {
             *      cmbSubs.Enabled = false;
             *      cmbSubs.Items.Clear();
             *
             *  });
             *  seekBar.Invoke((System.Threading.ThreadStart)delegate {
             *      seekBar.Enabled = false;
             *      seekBar.Value = 0;
             *  });
             * }*/
            player.Resume();
            if (SetPositionOnLoad)
            {
                player.SeekAsync(positionOnLoad);
                SetPositionOnLoad = false;
            }
            btnPlayPause.BackgroundImage       = Image.FromFile("./resources/images/pause.png");
            btnPlayPause.BackgroundImageLayout = ImageLayout.Stretch;
            if (currLang > -1)
            {
                cmbLangs.Invoke((System.Threading.ThreadStart) delegate
                {
                    cmbLangs.SelectedIndex = currLang;
                });
                currLang = -1;
            }
            if (currSub > -1)
            {
                cmbSubs.Invoke((System.Threading.ThreadStart) delegate
                {
                    cmbSubs.SelectedIndex = currSub;
                });
                currSub = -1;
            }
            panelvideo.Invoke((System.Threading.ThreadStart) delegate
            {
                panelvideo.Focus();
            });
        }
 private void refreshEPGToolStripMenuItem_Click(object sender, EventArgs e)
 {
     DownloadEPGFile(EPG_DB.Get(), AmiConfiguration.Get().URL_EPG);
 }
示例#27
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());
                    }
                }
            }
        }