Пример #1
0
 protected override async void OnNavigatedTo(NavigationEventArgs e) {
     base.OnNavigatedFrom(e);
     var param = e.Parameter as FilmItem;
     if(param.Fav) {
         FindName("FilterBtn");
         FindName("PathBtn");
     }
     _Item = param;
     TitlePage = param.Name;
     try {
         if(param.Img.Length > 4)
             PageImg = param.Img;
         if(param.Year != 0)
             PageYear.Text = "Year:" + param.Year;
     }
     catch(Exception) {/*ignore*/ }
     if(string.IsNullOrEmpty(PageYear.Text) || string.IsNullOrEmpty(PageImg)) {
         try {
             await Html.DownloadHtml(param.Url);
         }
         catch(Exception) { }
         LoadPage();
     }
     LoadItems(Deser((param.Fav)?"!Lang\\FAV_"+param.Name: "!Lang"));
     #region Fix Xaml
     ring.IsActive = false;
     ringPanel.Visibility = Visibility.Collapsed;
     GVName.Visibility = Visibility.Visible;
     #endregion
 }
Пример #2
0
        private async void Page_Loaded(object sender,RoutedEventArgs e)
        {
            if (_popularItems.Count > 2) return;
            html = new HtmlHandler();
            bool offline = false;
            try { await html.DownloadHtml(); if(html.HtmlFile == "DIS") offline = true; }
            catch(Exception) { offline = true; }
            #region If Offline
            if(offline) {
                ring.IsActive = false;
                Frame.Navigate(typeof(Offline));
            }
            #endregion
            #region ONLINE
            else {
                #region popular
                var popDiv = html.GetNodeByAttr(html.HtmlDoc,"div","class","popular-films");
                foreach(var node in popDiv.ChildNodes) {
                    if(node.Name != "div")
                        continue;
                    var ul_details = html.GetNodeByAttr(node,"ul","class","details");
                    foreach(var li in ul_details.ChildNodes) {
                        if(li.Name != "li")
                            continue;
                        var a = html.GetNodeByType(li,"a");
                        string link = html.GetAttr(a,"href");
                        string poster = html.GetAttr(html.GetNodeByType(html.GetNodeByAttr(a,"div","class","poster"),"img"),"src").Trim();
                        var ulli = html.GetNodeByAttr(html.GetNodeByType(html.GetNodeByType(li,"ul"),"li"),"div","class","title");
                        string name = html.GetNodeByType(ulli,"a").InnerText;
                        name = name.Replace("'","'");
                        name = name.Replace(" "," ");
                        _popularItems.Add(new FilmItem() { Name = name,Url = link,Img = poster });
                    }
                }
                #endregion
                #region Recent
                var recentDiv = html.GetNodeByAttr(html.HtmlDoc,"div","class","recent-subtitles");
                var ul = html.GetNodeByType(html.GetNodeByAttr(recentDiv,"div","class","content"),"ul");
                foreach(var node in ul.ChildNodes) {
                    if(node.Name != "li")
                        continue;
                    var less = new FilmItem();

                    var a = html.GetNodeByType(html.GetNodeByAttr(node,"div","class","name"),"a");
                    less.Url = html.GetAttr(a,"href");

                    less.Name = a.InnerHtml.Substring(a.InnerHtml.IndexOf("</span>") + 7).Replace(" </a>","").Trim();
                    less.Name = less.Name.Replace("&#39;","'");
                    less.Name = less.Name.Replace("&nbsp;"," ");

                    less.Lang = html.GetNodeByType(a,"span").InnerText.Trim();
                    _recentItems.Add(less);
                }
                #endregion
                #region Fix Xaml
                ring.IsActive = false;
                ringPanel.Visibility = Visibility.Collapsed;
                FindName("mainStack");
                mainStack.Visibility = Visibility.Visible;
                try { HeightHelper.Width = Frame.RenderSize.Width - 28; }
                catch(Exception) { }
                #endregion
            }
            #endregion
        }
Пример #3
0
        private void LoadItems(List<int> lang) {
            HtmlNode tbody = null;
            try {
                tbody = Html.GetNodeByType(Html.HtmlDoc,"tbody");
            }
            catch(Exception) { return; }
            var ls = new ObservableCollection<FilmItem>();
            var hlp = new Helper();
            if(tbody != null)
                foreach(var tr in tbody.ChildNodes) {
                    try {
                        if(tr == null)
                            continue;
                        var a1 = Html.GetNodeByAttr(tr,"td","class","a1");
                        if(a1 == null)
                            continue;
                        FilmItem mdl = new FilmItem();
                        var a = Html.GetNodeByType(a1,"a");
                        mdl.Url = Html.GetAttr(a,"href").ToString();
                        var ch = a.ChildNodes[1];
                        mdl.Lang = hlp.FormatTxt(ch.InnerText ?? "");
                        var attr = Html.GetAttr(ch,"class");
                        mdl.Img = attr.Contains("positive") ? "Green" : "Gray";
                        mdl.Name = hlp.FormatTxt(a.ChildNodes[3].InnerText);

                        mdl.Owner = Html.GetNodeByAttr(tr,"td","class","a5")?.InnerText ?? "";
                        mdl.Owner = "Owner:" + hlp.FormatTxt(mdl.Owner);
                        ls.Add(mdl);
                    }
                    catch(Exception) { }
                }
            var lngls = new string[] {
                 "Arabic",
                 "Brazillian",
                 "Danish",
                 "Dutch",
                 "English",//5
                 "Farsi/Persian",
                 "Finnish",
                 "French",
                 "Hebrew",
                 "Indonesian",//10
                 "Italian",
                 "Norwegian",
                 "Romanian",
                 "Spanish",
                 "Swedish",//15
                 "Swedish",
              };
            foreach(var i in lang) {
                foreach(var j in ls) {
                    if(j.Lang.ToLower().Contains(lngls[i].ToLower()))
                        ls.Remove(j);
                }
            }
            GVName.ItemsSource = ls;
        }