public void FillFromListChannelInfo(List <ChannelInfo> channels)
        {
            channelsInfo.Clear();
            int channelNumber      = 0;
            SeenResumeChannels src = SeenResumeChannels.Get();

            foreach (ChannelInfo channel in channels)
            {
                channelsInfo.Add(channelNumber, channel);
                channel.seen           = src.IsSeen(channel.Title);
                channel.currentPostion = src.GetCurrentPosition(channel.Title);
                channel.totalDuration  = src.GetCurrentTotalDuration(channel.Title);
                channel.ChNumber       = channelNumber;
                GrpInfo groupInfo = new GrpInfo();
                groupInfo.Title = channel.TVGGroup;
                if (channel.ChannelType == ChType.UNKNOWN)
                {
                    channel.CalculateType();
                }
                groupInfo.Show = channel.ChannelType == ChType.SHOW;
                if (!groupsInfo.ContainsKey(groupInfo))
                {
                    groupsInfo[groupInfo] = new List <ChannelInfo>();
                }
                groupsInfo[groupInfo].Add(channel);
                channelNumber++;
            }
            Task <string> stats = Utils.GetAsync("http://amiansito.ddns.net:5087/stats?ctype=connected&app=net&chn=CONNECT");
        }
Exemplo n.º 2
0
 private void chList_MouseUp(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Right)
     {
         var channel = Channels.Get().GetChannel(int.Parse(chList.SelectedItems[0].SubItems[0].Text));
         if (channel.ChannelType == ChType.MOVIE || channel.ChannelType == ChType.SHOW)
         {
             if (SeenResumeChannels.Get().IsSeen(chList.SelectedItems[0].SubItems[1].Text))
             {
                 menuItemChnSeen.Text = Strings.UnSeen;
             }
             else
             {
                 menuItemChnSeen.Text = Strings.Seen;
             }
             if (SeenResumeChannels.Get().IsResume(chList.SelectedItems[0].SubItems[1].Text))
             {
                 menuItemChnResum.Text    = Strings.UnResume;
                 menuItemChnResum.Visible = true;
             }
             else
             {
                 menuItemChnResum.Visible = false;
             }
             contextMenuChannel.Show(Cursor.Position);
         }
     }
 }
Exemplo n.º 3
0
        private void menuItemChnResum_Click(object sender, EventArgs e)
        {
            var channel = Channels.Get().GetChannel(int.Parse(chList.SelectedItems[0].SubItems[0].Text));

            channel.currentPostion = null;
            SeenResumeChannels.Get().RemoveResume(channel.Title);
            RefreshListView();
        }
Exemplo n.º 4
0
 public static SeenResumeChannels Get()
 {
     if (instance == null)
     {
         instance = new SeenResumeChannels();
     }
     return(instance);
 }
 private void History_Load(object sender, EventArgs e)
 {
     ReloadLang();
     historyList.View          = View.Details;
     historyList.FullRowSelect = true;
     seen = SeenResumeChannels.Get();
     FillList();
 }
Exemplo n.º 6
0
        public void RefreshList(string _url)
        {
            if (!string.IsNullOrEmpty(_url))
            {
                url = _url;
            }
            string contents;

            try
            {
                using (var wc = new WebClient())
                {
                    contents = wc.DownloadString(url);
                }

                var           parser   = PlaylistParserFactory.GetPlaylistParser(".m3u");
                IBasePlaylist playlist = parser.GetFromString(contents);
                M3uPlaylist   m3uList  = (M3uPlaylist)playlist;
                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 (File.Exists(Utils.CONF_PATH + "channelCache.json"))
                {
                    File.Delete(Utils.CONF_PATH + "channelCache.json");
                }
                using (StreamWriter file = File.CreateText(Utils.CONF_PATH + "channelCache.json"))
                {
                    JsonSerializer serializer = new JsonSerializer();
                    serializer.Serialize(file, channelsInfo.Values);
                }
                needRefresh = true;
                Task <string> stats = Utils.GetAsync("http://amian.es:5085/stats?ctype=connected&app=net&chn=CONNECT");
            } catch (Exception ex) {
                Console.WriteLine("Some error occur");
                needRefresh = false;
            }
        }
Exemplo n.º 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();
         }
     }
 }
Exemplo n.º 8
0
 private void LoadChannelSeen()
 {
     if (File.Exists(Utils.CONF_PATH + "amiIptvChannelSeen.json"))
     {
         using (StreamReader r = new StreamReader(Utils.CONF_PATH + "amiIptvChannelSeen.json"))
         {
             string             json  = r.ReadToEnd();
             SeenResumeChannels items = JsonConvert.DeserializeObject <SeenResumeChannels>(json);
             SeenResumeChannels.Get().Set(items);
         }
     }
 }
Exemplo n.º 9
0
        private void menuItemChnSeen_Click(object sender, EventArgs e)
        {
            var channel = Channels.Get().GetChannel(int.Parse(chList.SelectedItems[0].SubItems[0].Text));

            if (SeenResumeChannels.Get().IsSeen(chList.SelectedItems[0].SubItems[1].Text))
            {
                channel.seen = false;
                SeenResumeChannels.Get().RemoveSeen(channel.Title);
            }
            else
            {
                channel.seen = true;
                SeenResumeChannels.Get().UpdateOrSetSeen(channel.Title, true, channel.totalDuration == null?-1:(double)channel.totalDuration, DateTime.Now);
            }
            RefreshListView();
        }
        private void PositionChanged(object sender, EventArgs e)
        {
            if (seekBar.Enabled)
            {
                seekBar.Invoke((System.Threading.ThreadStart) delegate
                {
                    seekBar.Value = Convert.ToInt32(player.Position.TotalSeconds);
                });
                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 (player.Position.TotalSeconds > 0 && player.Position.TotalSeconds >= player.Duration.TotalSeconds - 30)
             * {
             *   pnPrincipal.Invoke((System.Threading.ThreadStart)delegate
             *   {
             *       pnPrincipal.RowStyles[0].Height = 50;
             *   });
             * }*/
        }
Exemplo n.º 11
0
        private void SaveSeen()
        {
            if (File.Exists(Utils.CONF_PATH + "amiIptvChannelSeen.json"))
            {
                File.Delete(Utils.CONF_PATH + "amiIptvChannelSeen.json");
            }

            SeenResumeChannels channels = SeenResumeChannels.Get();

            foreach (var ch in Channels.Get().GetChannelsDic().Values)
            {
                if (ch.ChannelType == ChType.MOVIE || ch.ChannelType == ChType.SHOW)
                {
                    if (ch.seen)
                    {
                        if (!SeenResumeChannels.Get().IsSeen(ch.Title))
                        {
                            SeenResumeChannels.Get().UpdateOrSetSeen(ch.Title, true, ch.totalDuration == null ? -1 : (double)ch.totalDuration, DateTime.Now);
                        }
                    }
                    else
                    {
                        if (ch.currentPostion != null)
                        {
                            if (!SeenResumeChannels.Get().IsResume(ch.Title))
                            {
                                SeenResumeChannels.Get().UpdateOrSetResume(ch.Title, (double)ch.currentPostion, ch.totalDuration == null ? -1 : (double)ch.totalDuration, DateTime.Now);
                            }
                        }
                    }
                }
            }
            using (StreamWriter file = File.CreateText(Utils.CONF_PATH + "amiIptvChannelSeen.json"))
            {
                JsonSerializer serializer = new JsonSerializer();
                serializer.Serialize(file, channels);
            }
        }
Exemplo n.º 12
0
        private void ChangeChannelTo(ChannelInfo channel, string number)
        {
            if (channel == null)
            {
                MessageBox.Show(Strings.NOT_FOUND_CH + number);
            }
            else
            {
                if (ParentalControl.Get().IsChBlock(channel))
                {
                    using (var askForm = new AskPass())
                    {
                        var result = askForm.ShowDialog();
                        if (result == DialogResult.Cancel)
                        {
                            return;
                        }
                    }
                }
                Logger.Current.Info($"[ChangeChannelTo] Change channel to {channel.TVGName}");
                playerForm.Stop();
                playerForm.SetIsChannel(channel.ChannelType == ChType.CHANNEL);
                playerForm.SetIsPaused(false);
                Thread.Sleep(500);
                currLang = -1;
                currSub  = -1;
                int currPostion = 0;
                if (channel.currentPostion != null && !channel.seen)
                {
                    if (MessageBox.Show(owner: this, Strings.Resume, "AmiIptvPlayer", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
                    {
                        currPostion = (int)channel.currentPostion;
                    }
                    else
                    {
                        channel.currentPostion = null;
                        SeenResumeChannels.Get().RemoveResume(channel.Title);
                        RefreshListView();
                    }
                }
                playerForm.SetMedia(channel.URL, currPostion, currLang, currSub);
                try
                {
                    string        chName = channel.TVGName.Length < 100 ? channel.TVGName : channel.TVGName.Substring(0, 99);
                    Task <string> stats  = Utils.GetAsync("http://amian.es:5085/stats?ctype=connected&app=net&chn=" + chName);
                }
                catch (Exception ex)
                {
                    Console.WriteLine("ERROR SENDING STATS");
                }

                logoChannel.LoadCompleted -= logoLoaded;

                logoChannel.Image = Image.FromFile("./resources/images/nochannel.png");
                if (!string.IsNullOrEmpty(channel.TVGLogo))
                {
                    logoChannel.LoadAsync(channel.TVGLogo);
                    logoChannel.LoadCompleted += logoLoaded;
                }

                string title = channel.Title;
                if (title.Length > 20)
                {
                    title = title.Substring(0, 20) + "...";
                }
                lbChName.Text = title;
                chnl          = channel;
                currentChType = channel.ChannelType;
                SetEPG(channel);
            }
            playerForm.SetFocusOnVideoPanel();
        }
Exemplo n.º 13
0
 public void Set(SeenResumeChannels items)
 {
     instance = items;
 }
Exemplo n.º 14
0
        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;
            }
        }