Exemplo n.º 1
0
        public override int DiscoverNextPageCategories(NextPageCategory category)
        {
            // remove the NextPageCategory from the list as we are resolving it now
            category.ParentCategory.SubCategories.Remove(category);
            // query Youtube to get the feed results
            var feed = service.Query(new YouTubeQuery(category.Url));

            foreach (var entry in feed.Entries)
            {
                category.ParentCategory.SubCategories.Add(new RssLink()
                {
                    Name                = entry is SubscriptionEntry ? ((SubscriptionEntry)entry).UserName : entry.Title.Text,
                    Url                 = entry is SubscriptionEntry ? YouTubeQuery.CreateUserUri(((SubscriptionEntry)entry).UserName) : entry.Content.Src.Content,
                    ParentCategory      = category.ParentCategory,
                    EstimatedVideoCount = (entry is PlaylistsEntry) ? (uint?)(entry as PlaylistsEntry).CountHint : null
                });
            }
            // if there are more results add a new NextPageCategory
            if (feed.NextChunk != null)
            {
                category.ParentCategory.SubCategories.Add(new NextPageCategory()
                {
                    ParentCategory = category.ParentCategory, Url = feed.NextChunk
                });
            }
            // return the number of categories we discovered
            return(feed.Entries.Count);
        }
Exemplo n.º 2
0
        private List <Category> GetShows(int page, Category parentCategory = null, string tag = "")
        {
            List <Category> shows = new List <Category>();
            string          url   = string.Format(showsUrl, page, tag);
            JArray          items = JArray.Parse(GetWebData <string>(url));

            foreach (JToken item in items)
            {
                RssLink show = new RssLink();

                show.Name             = (item["name"] == null) ? "" : item["name"].Value <string>();
                show.Url              = (item["nid"] == null) ? "" : item["nid"].Value <string>();
                show.Description      = (item["description"] == null) ? "" : item["description"].Value <string>();
                show.Thumb            = (item["program_image"] == null) ? "" : item["program_image"].Value <string>();
                show.ParentCategory   = parentCategory;
                show.SubCategories    = new List <Category>();
                show.HasSubCategories = true;
                show.Other            = (Func <List <Category> >)(() => GetShow(show));
                shows.Add(show);
            }

            if (items.Count > 39)
            {
                NextPageCategory next = new NextPageCategory();
                next.ParentCategory = parentCategory;
                next.Other          = (Func <List <Category> >)(() => GetShows(page + 1, parentCategory, tag));
                shows.Add(next);
            }
            return(shows);
        }
Exemplo n.º 3
0
        private int AddSubcats(HtmlNode node, RssLink parentCat)
        {
            var subs = node.SelectNodes(".//article");

            foreach (var sub in subs)
            {
                RssLink subcat = new RssLink()
                {
                    ParentCategory = parentCat
                };
                subcat.Name  = HttpUtility.HtmlDecode(sub.SelectSingleNode(".//a[@title]").Attributes["title"].Value.Trim());
                subcat.Url   = FormatDecodeAbsolutifyUrl(parentCat.Url, sub.SelectSingleNode(".//a[@href]").Attributes["href"].Value, null, UrlDecoding.None);
                subcat.Thumb = getThumb(sub.SelectSingleNode(".//picture/img"));

                parentCat.SubCategories.Add(subcat);
            }

            var np = node.SelectSingleNode(".//a[@href and text()='More shows']");

            nextPageAvailable = false;
            if (np != null)
            {
                string url   = CreateUrl(parentCat.Url, np.Attributes["href"].Value);
                var    npCat = new NextPageCategory()
                {
                    Url = url, ParentCategory = parentCat
                };
                parentCat.SubCategories.Add(npCat);
            }

            parentCat.SubCategoriesDiscovered = true;
            return(parentCat.SubCategories.Count);
        }
Exemplo n.º 4
0
        private List <Category> DiscoverSubCategoriesFromListing(string url)
        {
            List <Category> cats = new List <Category>();
            string          data = GetWebData(url);
            Regex           r    = new Regex(@"<div id=""movie-.*?""movieQuality[^>]*?>(?<q>[^<]*)<.*?<a href=""(?<u>[^""]*)"".*?<img src=""(?<i>[^""]*)"".*?>(?<n>[^<]*)</h4", RegexOptions.Singleline);

            foreach (Match m in r.Matches(data))
            {
                RssLink cat = new RssLink()
                {
                    Name             = m.Groups["n"].Value,
                    Thumb            = m.Groups["i"].Value,
                    Url              = m.Groups["u"].Value,
                    Description      = "Quality: " + m.Groups["q"].Value.Trim(),
                    HasSubCategories = false
                };
                cats.Add(cat);
            }
            string nextUrl = GetNextLink(data);

            if (!string.IsNullOrEmpty(nextUrl))
            {
                NextPageCategory next = new NextPageCategory();
                next.Url = nextUrl;
                cats.Add(next);
            }
            return(cats);
        }
Exemplo n.º 5
0
        public override int DiscoverNextPageCategories(NextPageCategory category)
        {
            if (category.ParentCategory == null)
            {
                Settings.Categories.Remove(category);
            }
            else
            {
                category.ParentCategory.SubCategories.Remove(category);
            }
            Func <List <Category> > method = category.Other as Func <List <Category> >;

            if (method != null)
            {
                List <Category> cats = method();
                if (cats != null)
                {
                    if (category.ParentCategory == null)
                    {
                        cats.ForEach((Category c) => Settings.Categories.Add(c));
                    }
                    else
                    {
                        category.ParentCategory.SubCategories.AddRange(cats);
                    }
                    return(cats.Count);
                }
            }
            return(0);
        }
Exemplo n.º 6
0
        private int Series(HtmlDocument doc, Category parentcat, string kind)
        {
            int offset = (int)parentcat.Other;

            var json = GetWebData <JObject>(((RssLink)parentcat).Url + offset.ToString());

            parentcat.SubCategories = new List <Category>();
            foreach (var item in json["items"])
            {
                RssLink cat = new RssLink()
                {
                    Name             = item["title"].Value <string>(),
                    Description      = item["description"].Value <string>(),
                    Thumb            = item["media"]["images"]["640x360"].Value <string>(),
                    Url              = @"https://prod-component-api.nm-services.nelonenmedia.fi/api/" + kind + "/" + item["link"]["target"]["value"].Value <string>() + "?userroles=anonymous&clients=ruutufi%2Cruutufi-react",
                    HasSubCategories = true,
                    ParentCategory   = parentcat
                };
                parentcat.SubCategories.Add(cat);
            }

            if (json["hits"].Value <int>() >= offset + parentcat.SubCategories.Count)
            {
                var nextPage = new NextPageCategory()
                {
                    Url = ((RssLink)parentcat).Url, Other = offset + 20
                };
                parentcat.SubCategories.Add(nextPage);
            }
            parentcat.SubCategoriesDiscovered = true;
            return(parentcat.SubCategories.Count);
        }
Exemplo n.º 7
0
        SubCatHolder getCats(string playlistUrl, Category parentCategory = null)
        {
            SubCatHolder holder = new SubCatHolder();

            holder.SubCategories        = new List <Category>();
            holder.SearchableCategories = new Dictionary <string, string>();

            if (playlistUrl.StartsWith("http://www.navixtreme.com"))
            {
                login();
            }

            NaviXPlaylist pl = NaviXPlaylist.Load(playlistUrl, nxId);

            if (pl != null)
            {
                foreach (NaviXMediaItem item in pl.Items)
                {
                    RssLink cat;
                    if (!string.IsNullOrEmpty(item.URL) && System.Text.RegularExpressions.Regex.IsMatch(item.URL, @"[?&]page=\d+"))
                    {
                        cat = new NextPageCategory();
                    }
                    else
                    {
                        cat = new RssLink();
                    }

                    cat.Name = item.Name;
                    if (!string.IsNullOrEmpty(item.InfoTag))
                    {
                        cat.Name += string.Format(" ({0})", item.InfoTag);
                    }
                    cat.Description = string.IsNullOrEmpty(item.Description) ? pl.Description : item.Description;
                    cat.Url         = item.URL;
                    if (!string.IsNullOrEmpty(item.Thumb))
                    {
                        cat.Thumb = item.Thumb;
                    }
                    else if (!string.IsNullOrEmpty(item.Icon))
                    {
                        cat.Thumb = item.Icon;
                    }
                    else
                    {
                        cat.Thumb = pl.Logo;
                    }
                    cat.HasSubCategories = item.Type == "playlist" || item.Type == "search";
                    cat.ParentCategory   = parentCategory;
                    cat.Other            = item;
                    holder.SubCategories.Add(cat);
                    if (item.Type == "search")
                    {
                        holder.SearchableCategories[cat.Name] = cat.Url;
                    }
                }
            }
            return(holder);
        }
Exemplo n.º 8
0
        public override int DiscoverNextPageCategories(NextPageCategory category)
        {
            category.ParentCategory.SubCategories.Remove(category);
            List <Category> categories = GetSubCategories(category);

            category.ParentCategory.SubCategories.AddRange(categories);
            return(categories.Count);
        }
        public override int DiscoverNextPageCategories(NextPageCategory category)
        {
            category.ParentCategory.SubCategories.Remove(category);
            addSubcats(category.ParentCategory, ((RssLink)category).Url);
            int oldAmount = category.ParentCategory.SubCategories.Count;

            return(category.ParentCategory.SubCategories.Count);
        }
 public override int DiscoverNextPageCategories(NextPageCategory category)
 {
     List<Category> nextPageCats = GetSubCategories(category);
     foreach(Category c in nextPageCats) c.ParentCategory = category.ParentCategory;
     category.ParentCategory.SubCategories.Remove(category);
     category.ParentCategory.SubCategories.AddRange(nextPageCats);
     return nextPageCats.Count;
 }
Exemplo n.º 11
0
        public override int DiscoverNextPageCategories(NextPageCategory category)
        {
            category.ParentCategory.SubCategories.Remove(category);
            int offset = int.Parse(category.GetOtherAsString());

            GetGenrePrograms(category.ParentCategory, category.Url, offset);
            return(category.ParentCategory.SubCategories.Count - offset);
        }
        public override int DiscoverNextPageCategories(NextPageCategory category)
        {
            string data = getSubcatWebData(category.Url);

            category.ParentCategory.SubCategories.Remove(category);
            int oldAmount = category.ParentCategory.SubCategories.Count;

            return(ParseSubCategories(category.ParentCategory, data));
        }
Exemplo n.º 13
0
        public override int DiscoverNextPageCategories(NextPageCategory category)
        {
            Category parentCat = category.ParentCategory;
            parentCat.SubCategories.Remove(category);

            string id = category.Other as string;
            var doc = getDocument(category);
            AddLapsetSubs(doc.DocumentNode.SelectSingleNode(@".//div[@id='" + id + "']"), parentCat);
            parentCat.SubCategoriesDiscovered = true;
            return parentCat.SubCategories.Count;
        }
Exemplo n.º 14
0
        public override int DiscoverNextPageCategories(NextPageCategory category)
        {
            SubCatHolder holder = category.ParentCategory.Other as SubCatHolder;
            if (holder == null)
                return category.ParentCategory.SubCategories.Count;

            holder.SubCategories.Remove(category);
            holder.SubCategories.AddRange(getCats((category as RssLink).Url, category.ParentCategory).SubCategories);
            category.ParentCategory.SubCategories = holder.SubCategories;
            return holder.SubCategories.Count;
        }
Exemplo n.º 15
0
        public override int DiscoverNextPageCategories(NextPageCategory category)
        {
            KijkNextPageCategory kn = (KijkNextPageCategory)category;
            string url = kn.baseUrl + '/' + kn.pagenr + "/10";
            url = FixUrl(baseUrl, url);
            HtmlDocument htmlDoc = GetHtmlDocument(url);

            category.ParentCategory.SubCategories.Remove(category);
            return ParseSubCategories((RssLink)category.ParentCategory,
                NextRealSibling(htmlDoc.DocumentNode.SelectSingleNode("//h2[@class = 'showcase-heading']")), kn.pagenr);
        }
Exemplo n.º 16
0
        public override int DiscoverNextPageCategories(NextPageCategory category)
        {
            Category parent = category.ParentCategory;

            parent.SubCategories.Remove(category);
            List <Category> cats = DiscoverSubCategoriesFromListing(category.Url);

            cats.ForEach(c => c.ParentCategory = parent);
            parent.SubCategories.AddRange(cats);
            return(cats.Count);
        }
Exemplo n.º 17
0
        public override int DiscoverNextPageCategories(NextPageCategory category)
        {
            Uri uri = DotNetFrameworkHelper.UriWithoutUrlDecoding.Create(category.Url);
            string data = MyGetWebData(uri);

            category.ParentCategory.SubCategories.Remove(category);
            var doc = new HtmlDocument();
            doc.LoadHtml(data);

            return AddSubcats(doc.DocumentNode, (RssLink)category.ParentCategory);
        }
Exemplo n.º 18
0
        public override int DiscoverNextPageCategories(NextPageCategory category)
        {
            KijkNextPageCategory kn = (KijkNextPageCategory)category;
            string url = kn.baseUrl + '/' + kn.pagenr + "/10";

            url = FixUrl(baseUrl, url);
            HtmlDocument htmlDoc = GetHtmlDocument(url);

            category.ParentCategory.SubCategories.Remove(category);
            return(ParseSubCategories((RssLink)category.ParentCategory,
                                      NextRealSibling(htmlDoc.DocumentNode.SelectSingleNode("//h2[@class = 'showcase-heading']")), kn.pagenr));
        }
Exemplo n.º 19
0
        public override int DiscoverNextPageCategories(NextPageCategory category)
        {
            Uri    uri  = DotNetFrameworkHelper.UriWithoutUrlDecoding.Create(category.Url);
            string data = MyGetWebData(uri);

            category.ParentCategory.SubCategories.Remove(category);
            var doc = new HtmlDocument();

            doc.LoadHtml(data);

            return(AddSubcats(doc.DocumentNode, (RssLink)category.ParentCategory));
        }
Exemplo n.º 20
0
        public override int DiscoverNextPageCategories(NextPageCategory category)
        {
            List <Category> nextPageCats = GetSubCategories(category);

            foreach (Category c in nextPageCats)
            {
                c.ParentCategory = category.ParentCategory;
            }
            category.ParentCategory.SubCategories.Remove(category);
            category.ParentCategory.SubCategories.AddRange(nextPageCats);
            return(nextPageCats.Count);
        }
Exemplo n.º 21
0
        /// <summary>
        /// Get the next page of categories
        /// </summary>
        /// <param name="category"></param>
        /// <returns></returns>
        public override int DiscoverNextPageCategories(NextPageCategory nextPagecategory)
        {
            string nextPage = string.Empty;

            nextPagecategory.ParentCategory.SubCategories.Remove(nextPagecategory);

            BuildCategories(nextPagecategory, null);

            /* if (results != null)
             *   nextPagecategory.ParentCategory.SubCategories.AddRange(results);
             */
            return(nextPagecategory.ParentCategory.SubCategories.Count);
        }
Exemplo n.º 22
0
        public override int DiscoverNextPageCategories(NextPageCategory category)
        {
            int res = base.DiscoverNextPageCategories(category);

            foreach (RssLink cat in Settings.Categories)
            {
                if (cat.Name.Contains("Season") == true)
                {
                    cat.Name = cat.Name.Substring(0, cat.Name.IndexOf("Season")).Trim();
                }
            }
            return(res);
        }
Exemplo n.º 23
0
        public override int DiscoverNextPageCategories(NextPageCategory category)
        {
            var method = category.Other as Func <List <Category> >;

            if (method != null)
            {
                var newCategories = method.Invoke();
                category.ParentCategory.SubCategories.Remove(category);
                category.ParentCategory.SubCategories.AddRange(newCategories);
                return(newCategories.Count);
            }
            return(0);
        }
Exemplo n.º 24
0
        public override int DiscoverNextPageCategories(NextPageCategory category)
        {
            Category parentCat = category.ParentCategory;

            parentCat.SubCategories.Remove(category);

            string id  = category.Other as string;
            var    doc = getDocument(category);

            AddLapsetSubs(doc.DocumentNode.SelectSingleNode(@".//div[@id='" + id + "']"), parentCat);
            parentCat.SubCategoriesDiscovered = true;
            return(parentCat.SubCategories.Count);
        }
Exemplo n.º 25
0
        /*private void AddToPlayList(Category playLists, string name, string urlob)
         * {
         *  playLists.SubCategories.Add(new RssLink()
         *  {
         *      Name = name,
         *      Url = @"http://www.muzu.tv/browse/loadPlaylistsByCategory?ob=" + urlob,
         *      Other = MuzuType.PlayList,
         *      ParentCategory = playLists,
         *      HasSubCategories = true
         *  }
         *  );
         * }*/

        public override int ParseSubCategories(Category parentCategory, string data)
        {
            int res;

            switch ((MuzuType)parentCategory.Other)
            {
            case MuzuType.SearchChannel:
            {
                string url;
                regEx_dynamicSubCategories = regExSearchChannel;
                url = ((RssLink)parentCategory).Url;
                dynamicSubCategoryUrlFormatString = baseUrl + "api/artist/details?aname={0}&";

                data = GetWebData(url, forceUTF8: true);
                res  = base.ParseSubCategories(parentCategory, data);
                if (parentCategory.SubCategories.Count > 0)
                {
                    NextPageCategory c = parentCategory.SubCategories[parentCategory.SubCategories.Count - 1] as NextPageCategory;
                    if (c != null)
                    {
                        c.Url = HttpUtility.HtmlDecode(c.Url);
                    }
                }
                break;
            }

            case MuzuType.Genres:
            {
                regEx_dynamicSubCategories        = regExGenres;
                dynamicSubCategoryUrlFormatString = baseUrl + @"api/browse?g={0}&";
                res = base.ParseSubCategories(parentCategory, data);
                parentCategory.SubCategories.Sort();
                break;
            }

            case MuzuType.PlayList:
            {
                regEx_dynamicSubCategories        = regexPlayList;
                dynamicSubCategoryUrlFormatString = "{0}";
                res = base.ParseSubCategories(parentCategory, data);
                foreach (Category cat in parentCategory.SubCategories)
                {
                    cat.Other = MuzuType.PlayList;
                }
                break;
            }

            default: throw new NotImplementedException("unhandled muzutype " + (MuzuType)parentCategory.Other);
            }
            return(res);
        }
Exemplo n.º 26
0
        public override int DiscoverNextPageCategories(NextPageCategory category)
        {
            SubCatHolder holder = category.ParentCategory.Other as SubCatHolder;

            if (holder == null)
            {
                return(category.ParentCategory.SubCategories.Count);
            }

            holder.SubCategories.Remove(category);
            holder.SubCategories.AddRange(getCats((category as RssLink).Url, category.ParentCategory).SubCategories);
            category.ParentCategory.SubCategories = holder.SubCategories;
            return(holder.SubCategories.Count);
        }
Exemplo n.º 27
0
        public override int DiscoverNextPageCategories(NextPageCategory category)
        {
            int    dynamicCategoriesCount = 0;
            String baseWebData            = GetWebData(category.Url, forceUTF8: true);

            HtmlAgilityPack.HtmlDocument document = new HtmlAgilityPack.HtmlDocument();
            document.LoadHtml(baseWebData);

            HtmlAgilityPack.HtmlNodeCollection shows = document.DocumentNode.SelectNodes(".//div[@class='movie-border']");

            foreach (var show in shows)
            {
                this.Settings.Categories.Add(
                    new RssLink()
                {
                    Name             = show.SelectSingleNode(".//a/.//h5").InnerText,
                    Url              = Utils.FormatAbsoluteUrl(show.SelectSingleNode(".//a").Attributes["href"].Value, PrimaUtil.baseUrl),
                    HasSubCategories = true
                });

                dynamicCategoriesCount++;
            }

            HtmlAgilityPack.HtmlNode nextPageNode = document.DocumentNode.SelectSingleNode(".//script[contains(text(), 'infinity-scroll')]/text()");

            if (nextPageNode != null)
            {
                String   content = document.DocumentNode.SelectSingleNode(".//script/text()").InnerText.Trim();
                String[] parts   = content.Split(new String[] { "'" }, StringSplitOptions.RemoveEmptyEntries);

                foreach (var part in parts)
                {
                    Uri result;

                    if (Uri.TryCreate(part, UriKind.Absolute, out result))
                    {
                        this.Settings.Categories.Add(new NextPageCategory()
                        {
                            Url = part
                        });
                        dynamicCategoriesCount++;

                        break;
                    }
                }
            }

            this.Settings.DynamicCategoriesDiscovered = true;
            return(dynamicCategoriesCount);
        }
Exemplo n.º 28
0
        public override int DiscoverNextPageCategories(NextPageCategory category)
        {
            int count = 0;
            Func <List <Category> > method = category.Other as Func <List <Category> >;

            category.ParentCategory.SubCategories.Remove(category);
            if (method != null)
            {
                List <Category> cats = method();
                category.ParentCategory.SubCategories.AddRange(cats);
                count = cats.Count;
            }
            return(count);
        }
Exemplo n.º 29
0
        private List <Category> DiscoverAlbumsCategories(LastFmCategory category, int page)
        {
            List <Category> albums     = new List <Category>();
            string          refererUrl = category.Url;
            string          q          = refererUrl.Contains("?") ? "&" : "?";
            string          url        = refererUrl + q + "_pjax=%23content&page=" + page;
            string          data       = GetWebData(url, cookies: Cookies, referer: refererUrl);
            string          rString;

            if (url.Contains("+albums"))
            {
                rString = @"album-grid-album-art""\s+src=""(?<img>[^""]*).*?""album-grid-item-main-text""[^>]*>(?<name>[^<]*).*?data-station-url=""(?<url>[^""]*)";
            }
            else
            {
                rString = @"chartlist-play-image""[^<]*<img src=""(?<img>[^""]*).*?alt=""(?<name>[^""]*)[^<]*<button.*?data-station-url=""(?<url>[^""]*)";
            }
            Regex regex = new Regex(rString, RegexOptions.Singleline);

            foreach (Match m in regex.Matches(data))
            {
                LastFmCategory album = new LastFmCategory()
                {
                    Name           = HttpUtility.HtmlDecode(m.Groups["name"].Value),
                    Url            = "http://www.last.fm" + m.Groups["url"].Value,
                    User           = category.User,
                    ParentCategory = category,
                    Thumb          = m.Groups["img"].Value,
                };
                album.Other = (Func <List <VideoInfo> >)(() => GetJsonVideos(album, 1));
                albums.Add(album);
            }

            regex = new Regex(@"<li class=""next"">(?<next>.*?)</", RegexOptions.Singleline);
            Match nextMatch = regex.Match(data);

            if (nextMatch.Success && !string.IsNullOrWhiteSpace(nextMatch.Groups["next"].Value))
            {
                NextPageCategory npc = new NextPageCategory()
                {
                    Name           = "Next",
                    ParentCategory = category,
                    Other          = (Func <List <Category> >)(() => DiscoverAlbumsCategories(category, page + 1))
                };
                albums.Add(npc);
            }
            return(albums);
        }
Exemplo n.º 30
0
        public override int DiscoverNextPageCategories(NextPageCategory category)
        {
            Settings.Categories.Remove(category);
            var games = GetWebData<JObject>(category.Url);
            foreach (var game in from game in games["top"] select game)
            {
                Settings.Categories.Add(CategoryFromJsonGameObject(game));
            }

            string nextCategoriesPageUrl = games["_links"].Value<string>("next");
            if (!string.IsNullOrEmpty(nextCategoriesPageUrl))
            {
                Settings.Categories.Add(new NextPageCategory() { Url = nextCategoriesPageUrl });
            }

            return Settings.Categories.Count - 1;
        }
Exemplo n.º 31
0
        private void GetGenrePrograms(Category parentCategory, string apiUrl, int offset, int limit = 100, string sortOrder = "a-o")
        {
            string url = string.Format("{0}?o={1}&app_id={2}&app_key={3}&client=yle-areena-web&language={4}&v=5&offset={5}&limit={6}&filter.region={7}",
                                       apiUrl,
                                       sortOrder,
                                       appInfo.AppId,
                                       appInfo.AppKey,
                                       ApiLanguage,
                                       offset,
                                       limit,
                                       ApiRegion);
            List <Category> programs     = new List <Category>();
            JObject         json         = GetWebData <JObject>(url);
            int             noOfpackages = 0;

            foreach (JToken programToken in json["data"].Value <JArray>())
            {
                string type = programToken["pointer"]["type"].Value <string>();
                if (type != "package")
                {
                    YleCategory program = new YleCategory();
                    program.IsSeries       = type == "series";
                    program.Name           = programToken["title"].Value <string>();
                    program.Url            = programToken["labels"].First(t => t["type"].Value <string>() == "itemId")["raw"].Value <string>();
                    program.Description    = programToken["description"].Value <string>();
                    program.Thumb          = string.Format(imageFormat, programToken["image"]["id"].Value <string>());
                    program.ParentCategory = parentCategory;
                    programs.Add(program);
                }
                else
                {
                    noOfpackages++;
                }
            }
            if (programs.Count + noOfpackages >= limit)
            {
                NextPageCategory next = new NextPageCategory();
                next.Url            = apiUrl;
                next.Other          = (offset + limit).ToString();
                next.ParentCategory = parentCategory;
                programs.Add(next);
            }
            parentCategory.SubCategories.AddRange(programs);
        }
Exemplo n.º 32
0
        public override int DiscoverNextPageCategories(NextPageCategory category)
        {
            int res = base.DiscoverNextPageCategories(category);

            foreach (RssLink cat in Settings.Categories)
            {
                Match m  = Regex.Match(cat.Name, @"S\d+E\d+");
                Match m1 = Regex.Match(cat.Name, @"\d\d\d\d\.\d+\.\d+");
                if (m.Success)
                {
                    cat.Name = Regex.Replace(cat.Name, @"S\d+E\d+", "");
                }
                else if (m1.Success)
                {
                    cat.Name = Regex.Replace(cat.Name, m1.Value, "").Trim();
                }
            }
            return(res);
        }
Exemplo n.º 33
0
        public override int DiscoverNextPageCategories(NextPageCategory category)
        {
            Settings.Categories.Remove(category);
            var games = GetWebData <JObject>(category.Url, headers: customHeader);

            foreach (var game in from game in games["top"] select game)
            {
                Settings.Categories.Add(CategoryFromJsonGameObject(game));
            }

            string nextCategoriesPageUrl = games["_links"].Value <string>("next");

            if (!string.IsNullOrEmpty(nextCategoriesPageUrl))
            {
                Settings.Categories.Add(new NextPageCategory()
                {
                    Url = nextCategoriesPageUrl
                });
            }

            return(Settings.Categories.Count - 1);
        }
Exemplo n.º 34
0
        private List <Category> DiscoverArtistCategories(LastFmCategory category, int page)
        {
            string          user       = category.User;
            string          refererUrl = "http://www.last.fm/user/" + user + "/library/artists?date_preset=" + category.Url;
            string          url        = refererUrl + "&_pjax=%23content&page=" + page;
            List <Category> cats       = new List <Category>();
            string          data       = GetWebData(url, cookies: Cookies, referer: refererUrl);
            Regex           regex      = new Regex(@"img src=""(?<img>[^""]*)[^>]*?class=""avatar.*?library/music/(?<url>[^\?]*).*?>(?<name>[^<]*)</a>", RegexOptions.Singleline);

            foreach (Match m in regex.Matches(data))
            {
                RssLink artistCat = new RssLink()
                {
                    Name                    = HttpUtility.HtmlDecode(m.Groups["name"].Value),
                    Thumb                   = m.Groups["img"].Value,
                    HasSubCategories        = true,
                    SubCategories           = new List <Category>(),
                    SubCategoriesDiscovered = true,
                    ParentCategory          = category
                };

                LastFmCategory artistRadio = new LastFmCategory()
                {
                    Name           = "Play artist radio",
                    Url            = "http://www.last.fm/player/station/music/" + m.Groups["url"].Value + "?ajax={0}",
                    User           = user,
                    Thumb          = m.Groups["img"].Value,
                    ParentCategory = artistCat,
                };
                artistRadio.Other = (Func <List <VideoInfo> >)(() => GetJsonVideos(artistRadio, 1));
                artistCat.SubCategories.Add(artistRadio);

                if (user != username)
                {
                    LastFmCategory artistUserScrobbledTracks = new LastFmCategory()
                    {
                        Name           = "Scrobbles (" + username + ")",
                        Url            = "http://www.last.fm/user/" + username + "/library/music/" + m.Groups["url"].Value + "/+tracks",
                        User           = username,
                        Thumb          = m.Groups["img"].Value,
                        ParentCategory = artistCat
                    };
                    artistUserScrobbledTracks.Other = (Func <List <VideoInfo> >)(() => GetHtmlVideos(artistUserScrobbledTracks, 1, new SerializableDictionary <string, string>()
                    {
                        { "date_preset", "ALL_TIME" }
                    }));
                    artistCat.SubCategories.Add(artistUserScrobbledTracks);
                }

                LastFmCategory artistScrobbledTracks = new LastFmCategory()
                {
                    Name           = "Scrobbles (" + user + ")",
                    Url            = "http://www.last.fm/user/" + user + "/library/music/" + m.Groups["url"].Value + "/+tracks",
                    User           = user,
                    Thumb          = m.Groups["img"].Value,
                    ParentCategory = artistCat
                };
                artistScrobbledTracks.Other = (Func <List <VideoInfo> >)(() => GetHtmlVideos(artistScrobbledTracks, 1, new SerializableDictionary <string, string>()
                {
                    { "date_preset", "ALL_TIME" }
                }));
                artistCat.SubCategories.Add(artistScrobbledTracks);

                LastFmCategory artistAlbums = new LastFmCategory()
                {
                    Name             = "Albums",
                    Url              = "http://www.last.fm/music/" + m.Groups["url"].Value + "/+albums",
                    User             = user,
                    Thumb            = m.Groups["img"].Value,
                    HasSubCategories = true,
                    ParentCategory   = artistCat,
                    SubCategories    = new List <Category>()
                };
                artistAlbums.Other = (Func <List <Category> >)(() => DiscoverAlbumsCategories(artistAlbums, 1));
                artistCat.SubCategories.Add(artistAlbums);

                LastFmCategory artistTracks = new LastFmCategory()
                {
                    Name           = "Tracks",
                    Url            = "http://www.last.fm/music/" + m.Groups["url"].Value + "/+tracks",
                    User           = user,
                    Thumb          = m.Groups["img"].Value,
                    ParentCategory = artistCat
                };
                artistTracks.Other = (Func <List <VideoInfo> >)(() => GetHtmlVideos(artistTracks, 1, null));
                artistCat.SubCategories.Add(artistTracks);

                cats.Add(artistCat);
            }
            regex = new Regex(@"<li class=""next"">(?<next>.*?)</li", RegexOptions.Singleline);
            Match nextMatch = regex.Match(data);

            if (nextMatch.Success && !string.IsNullOrWhiteSpace(nextMatch.Groups["next"].Value))
            {
                NextPageCategory npc = new NextPageCategory()
                {
                    Name           = "Next",
                    ParentCategory = category,
                    Other          = (Func <List <Category> >)(() => DiscoverArtistCategories(category, page + 1))
                };
                cats.Add(npc);
            }
            return(cats);
        }
Exemplo n.º 35
0
 public override int DiscoverNextPageCategories(NextPageCategory category)
 {
     return(Series(getDocument(category), category, "series"));
 }
Exemplo n.º 36
0
 public override int DiscoverNextPageCategories(NextPageCategory category)
 {
     Category parent = category.ParentCategory;
     parent.SubCategories.Remove(category);
     List<Category> cats = DiscoverSubCategoriesFromListing(category.Url);
     cats.ForEach(c => c.ParentCategory = parent);
     parent.SubCategories.AddRange(cats);
     return cats.Count;
 }
 private void DisplayCategories_NextPage(NextPageCategory cat)
 {
     Gui2UtilConnector.Instance.ExecuteInBackgroundAndCallback(delegate()
     {
         return SelectedSite.DiscoverNextPageCategories(cat);
     },
     delegate(bool success, object result)
     {
         if (success) SetCategoriesToFacade(cat.ParentCategory, cat.ParentCategory == null ? SelectedSite.Settings.Categories as IList<Category> : cat.ParentCategory.SubCategories, false, true);
     },
     Translation.Instance.GettingNextPageVideos, true);
 }
Exemplo n.º 38
0
        private List<Category> GetApiSubCategories(Category parentCategory, int offset)
        {
            List<Category> subCategories = new List<Category>();
            string categoryKey = (parentCategory.ParentCategory as RssLink).Url;
            string sortOrder = (parentCategory as RssLink).Url;
            string url = string.Format(cUrlCategoryFormat, BaseUrl, AppInfo.AppId, AppInfo.AppKey, categoryKey, sortOrder, ApiRegion, ApiLanguage, ApiContentLanguage, cApiLimit, offset);
            JObject json = GetWebData<JObject>(url);
            JArray data = json["data"].Value<JArray>();
            foreach (JToken item in data)
            {
                if (!onlyNonGeoblockedContent || item["region"].Value<string>() == "World")
                {
                    string title = item["title"][ApiLanguage] == null ? item["title"][ApiOtherLanguage].Value<string>() : item["title"][ApiLanguage].Value<string>();
                    string id = item["id"].Value<string>();
                    string type = item["type"].Value<string>();
                    bool hasSubCats = type == cApiContentTypeTvSeries;
                    string image = (item["imageId"] != null) ? string.Format(cUrlImageFormat, item["imageId"].Value<string>()) : string.Empty;
                    uint clipCount = 0;
                    uint programCount = 0;
                    uint? estimatedVideoCount = null;
                    if (hasSubCats)
                    {
                        clipCount = (item["clipCount"] != null) ? item["clipCount"].Value<uint>() : 0;
                        programCount = (item["programCount"] != null) ? item["programCount"].Value<uint>() : 0;
                        estimatedVideoCount = clipCount + programCount;
                    }
                    RssLink category = new RssLink()
                    {
                        Name = title,
                        Url = hasSubCats ? string.Empty : id,
                        Thumb = image,
                        ParentCategory = parentCategory,
                        EstimatedVideoCount = estimatedVideoCount,
                        HasSubCategories = hasSubCats,
                        SubCategoriesDiscovered = hasSubCats,
                        SubCategories = new List<Category>()
                    };
                    if (hasSubCats)
                    {
                        if (programCount > 0)
                        {
                            category.SubCategories.Add(new RssLink()
                            {
                                Name = dictionary[cApiProgram],
                                Url = id,
                                ParentCategory = category,
                                EstimatedVideoCount = programCount,
                                HasSubCategories = false,
                                Other = type,
                                Thumb = image
                            });
                        }
                        if (clipCount > 0)
                        {
                            category.SubCategories.Add(new RssLink()
                            {
                                Name = dictionary[cApiClip],
                                Url = id,
                                ParentCategory = category,
                                EstimatedVideoCount = clipCount,
                                HasSubCategories = false,
                                Other = type,
                                Thumb = image
                            });
                        }
                    }
                    subCategories.Add(category);
                }

            }
            JToken meta = json["meta"];
            int count = meta["count"].Value<int>();
            if (count > cApiLimit + offset)
            {
                NextPageCategory next = new NextPageCategory() { ParentCategory = parentCategory };
                next.Other = (Func<List<Category>>)(() => GetApiSubCategories(parentCategory, cApiLimit + offset));
                subCategories.Add(next);
            }
            return subCategories;
        }
Exemplo n.º 39
0
        public override int DiscoverNextPageCategories(NextPageCategory category)
        {
            int dynamicCategoriesCount = 0;
            String pageUrl = category.Url;

            String baseWebData = GetWebData(pageUrl, null, null, null, true);
            pageUrl = String.Empty;

            this.Settings.Categories.RemoveAt(this.Settings.Categories.Count - 1);

            int startIndex = baseWebData.IndexOf(NovaUtil.dynamicCategoryStart);
            if (startIndex > 0)
            {
                int endIndex = baseWebData.IndexOf(NovaUtil.dynamicCategoryEnd, startIndex);
                if (endIndex >= 0)
                {
                    baseWebData = baseWebData.Substring(startIndex, endIndex - startIndex);

                    Match match = Regex.Match(baseWebData, NovaUtil.categoryNextPage);
                    if (match.Success)
                    {
                        pageUrl = Utils.FormatAbsoluteUrl(match.Groups["categoryNextPage"].Value, NovaUtil.baseUrl);
                    }

                    while (true)
                    {
                        int showStartIndex = baseWebData.IndexOf(NovaUtil.showStart);
                        if (showStartIndex >= 0)
                        {
                            int showEndIndex = baseWebData.IndexOf(NovaUtil.showEnd, showStartIndex);
                            if (showEndIndex >= 0)
                            {
                                String showData = baseWebData.Substring(showStartIndex, showEndIndex - showStartIndex);

                                String showUrl = String.Empty;
                                String showTitle = String.Empty;
                                String showThumbUrl = String.Empty;

                                match = Regex.Match(showData, NovaUtil.showUrlTitleRegex);
                                if (match.Success)
                                {
                                    showUrl = Utils.FormatAbsoluteUrl(match.Groups["showUrl"].Value, NovaUtil.baseUrl);
                                    showTitle = HttpUtility.HtmlDecode(match.Groups["showTitle"].Value);
                                }

                                match = Regex.Match(showData, NovaUtil.showThumbRegex);
                                if (match.Success)
                                {
                                    showThumbUrl = Utils.FormatAbsoluteUrl(match.Groups["showThumbUrl"].Value, NovaUtil.baseUrl);
                                }

                                if (!(String.IsNullOrEmpty(showUrl) || String.IsNullOrEmpty(showTitle)))
                                {
                                    this.Settings.Categories.Add(new RssLink()
                                    {
                                        Name = showTitle,
                                        HasSubCategories = false,
                                        Url = showUrl,
                                        Thumb = showThumbUrl
                                    });
                                    dynamicCategoriesCount++;
                                }
                            }

                            baseWebData = baseWebData.Substring(showStartIndex + NovaUtil.showStart.Length);
                        }
                        else
                        {
                            break;
                        }
                    }

                    if (!String.IsNullOrEmpty(pageUrl))
                    {
                        this.Settings.Categories.Add(new NextPageCategory() { Url = pageUrl });
                    }
                }
            }

            this.Settings.DynamicCategoriesDiscovered = true;
            return dynamicCategoriesCount;
        }
Exemplo n.º 40
0
 public override int DiscoverNextPageCategories(NextPageCategory category)
 {
     category.ParentCategory.SubCategories.Remove(category);
     if (category.ParentCategory.Other == null)
         category.ParentCategory.Other = category.Other;
     return DiscoverSubCategories(category.ParentCategory, category.Url);
 }
Exemplo n.º 41
0
 public override int DiscoverNextPageCategories(NextPageCategory category)
 {
     if (category.ParentCategory == null)
     {
         Settings.Categories.Remove(category);
     }
     else
     {
         category.ParentCategory.SubCategories.Remove(category);
     }
     Func<List<Category>> method = category.Other as Func<List<Category>>;
     if (method != null)
     {
         List<Category> cats = method();
         if (cats != null)
         {
             if (category.ParentCategory == null)
             {
                 cats.ForEach((Category c) => Settings.Categories.Add(c));
             }
             else
             {
                 category.ParentCategory.SubCategories.AddRange(cats);
             }
             return cats.Count;
         }
     }
     return 0;
 }
Exemplo n.º 42
0
    public override int DiscoverNextPageCategories(NextPageCategory category)
    {
      int res = base.DiscoverNextPageCategories(category);

      foreach (RssLink cat in Settings.Categories)
      {
        Match m = Regex.Match(cat.Name, @"S\d+E\d+");
        Match m1 = Regex.Match(cat.Name, @"\d\d\d\d\.\d+\.\d+");
        if (m.Success)
          cat.Name = Regex.Replace(cat.Name, @"S\d+E\d+", "");
        else if (m1.Success)
          cat.Name = Regex.Replace(cat.Name, m1.Value, "").Trim();
      }
      return res;
    }
Exemplo n.º 43
0
        SubCatHolder getCats(string playlistUrl, Category parentCategory = null)
        {
            SubCatHolder holder = new SubCatHolder();
            holder.SubCategories = new List<Category>();
            holder.SearchableCategories = new Dictionary<string, string>();

            if (playlistUrl.StartsWith("http://www.navixtreme.com"))
                login();

            NaviXPlaylist pl = NaviXPlaylist.Load(playlistUrl, nxId);
            if (pl != null)
            {
                foreach (NaviXMediaItem item in pl.Items)
                {
                    RssLink cat;
                    if (!string.IsNullOrEmpty(item.URL) && System.Text.RegularExpressions.Regex.IsMatch(item.URL, @"[?&]page=\d+"))
                        cat = new NextPageCategory();
                    else
                        cat = new RssLink();

                    cat.Name = item.Name;
                    if (!string.IsNullOrEmpty(item.InfoTag))
                        cat.Name += string.Format(" ({0})", item.InfoTag);
                    cat.Description = string.IsNullOrEmpty(item.Description) ? pl.Description : item.Description;
                    cat.Url = item.URL;
                    if (!string.IsNullOrEmpty(item.Thumb))
                        cat.Thumb = item.Thumb;
                    else if (!string.IsNullOrEmpty(item.Icon))
                        cat.Thumb = item.Icon;
                    else
                        cat.Thumb = pl.Logo;
                    cat.HasSubCategories = item.Type == "playlist" || item.Type == "search";
                    cat.ParentCategory = parentCategory;
                    cat.Other = item;
                    holder.SubCategories.Add(cat);
                    if (item.Type == "search")
                        holder.SearchableCategories[cat.Name] = cat.Url;
                }
            }
            return holder;
        }
Exemplo n.º 44
0
        private List<Category> GetProgramsCategories(Category parentCategory, int page, string pageId = null, string moduleId = null, string query = null)
        {
            List<Category> cats = new List<Category>();
            bool isSearch = query != null;
            if (!isSearch && (string.IsNullOrEmpty(pageId) || string.IsNullOrEmpty(moduleId)))
            {
                string data = GetWebData(baseUrl + programUrl, cookies: Cookies);
                Regex rgx = new Regex(@"data-page-id=""(?<pageId>\d*)"".*?data-module-id=""(?<moduleId>\d*)""");
                Match m = rgx.Match(data);
                if (m.Success)
                {
                    pageId = m.Groups["pageId"].Value;
                    moduleId = m.Groups["moduleId"].Value;
                }
                if (string.IsNullOrEmpty(pageId) || string.IsNullOrEmpty(moduleId))
                {
                    throw new OnlineVideosException("Could not get the " + programCategoryName + " category");
                }
            }
            string url;
            if (!isSearch)
                url = string.Format("{0}api/v2/ajax/modules?items=50&page_id={1}&module_id={2}&page={3}", baseUrl, pageId, moduleId, page);
            else
                url = string.Format("{0}api/v2/ajax/search/?q={1}&items=50&types=show&page={2}", baseUrl, query, page);

            JObject json = GetWebData<JObject>(url, cookies: Cookies);
            foreach (JToken show in json["data"])
            {
                bool isPremium = show["content_info"]["package_label"]["value"].Value<string>() == "Premium";
                if (ShowPremium || !isPremium)
                {
                    JToken taxonomyItem = show["taxonomy_items"].FirstOrDefault(ti => ti["type"].Value<string>() == "show");
                    if (taxonomyItem != null)
                    {
                        RssLink cat = new RssLink();
                        cat.ParentCategory = parentCategory;
                        cat.Name = show["title"].Value<string>();
                        cat.Name += isPremium && !HaveCredentials ? " [Premium]" : "";
                        cat.Description = show["description"].Value<string>();
                        string imageFile = show["image_data"]["file"].Value<string>();
                        cat.Thumb = "http://a5.res.cloudinary.com/dumrsasw1/image/upload/c_fill,h_245,w_368/" + imageFile;
                        int termId = taxonomyItem["term_id"].Value<int>();
                        cat.Url = string.Format("{0}api/v2/ajax/shows/{1}/seasons/?show_id={2}&items=14&sort=sort_date_asc", baseUrl, termId, termId) + "&page={0}";
                        uint episodes = 0;
                        if (taxonomyItem["metadata"]["episodes"] != null)
                            uint.TryParse(taxonomyItem["metadata"]["episodes"].Value<string>(), out episodes);
                        cat.EstimatedVideoCount = episodes;
                        cats.Add(cat);
                    }
                }
            }
            int pages = json["total_pages"].Value<int>();

            if (page < pages - 1)
            {
                NextPageCategory next = new NextPageCategory() { ParentCategory = parentCategory };
                next.Other = (Func<List<Category>>)(() => GetProgramsCategories(parentCategory, page + 1, pageId, moduleId, query));
                cats.Add(next);
            }
            return cats;
        }
Exemplo n.º 45
0
        private List<Category> DiscoverAlbumsCategories(LastFmCategory category, int page)
        {
            List<Category> albums = new List<Category>();
            string refererUrl = category.Url;
            string q = refererUrl.Contains("?") ? "&" : "?";
            string url = refererUrl + q + "_pjax=%23content&page=" + page;
            string data = GetWebData(url, cookies: Cookies, referer: refererUrl);
            string rString;
            if (url.Contains("+albums"))
                rString = @"album-grid-album-art""\s+src=""(?<img>[^""]*).*?""album-grid-item-main-text""[^>]*>(?<name>[^<]*).*?data-station-url=""(?<url>[^""]*)";
            else
                rString = @"chartlist-play-image""[^<]*<img src=""(?<img>[^""]*).*?alt=""(?<name>[^""]*)[^<]*<button.*?data-station-url=""(?<url>[^""]*)";
            Regex regex = new Regex(rString, RegexOptions.Singleline);
            foreach (Match m in regex.Matches(data))
            {
                LastFmCategory album = new LastFmCategory()
                {
                    Name = HttpUtility.HtmlDecode(m.Groups["name"].Value),
                    Url = "http://www.last.fm" + m.Groups["url"].Value,
                    User = category.User,
                    ParentCategory = category,
                    Thumb = m.Groups["img"].Value,
                };
                album.Other = (Func<List<VideoInfo>>)(() => GetJsonVideos(album, 1));
                albums.Add(album);
            }

            regex = new Regex(@"<li class=""next"">(?<next>.*?)</", RegexOptions.Singleline);
            Match nextMatch = regex.Match(data);
            if (nextMatch.Success && !string.IsNullOrWhiteSpace(nextMatch.Groups["next"].Value))
            {
                NextPageCategory npc = new NextPageCategory()
                {
                    Name = "Next",
                    ParentCategory = category,
                    Other = (Func<List<Category>>)(() => DiscoverAlbumsCategories(category, page + 1))
                };
                albums.Add(npc);
            }
            return albums;
        }
Exemplo n.º 46
0
        public override int DiscoverNextPageCategories(NextPageCategory category)
        {
            string data = GetWebData<string>(category.Url, cookies: GetCookie(), forceUTF8: forceUTF8Encoding, allowUnsafeHeader: allowUnsafeHeaders, encoding: encodingOverride);

            if (category.ParentCategory == null)
            {
                Settings.Categories.Remove(category);
                return ParseCategories(data);
            }
            else
            {
                category.ParentCategory.SubCategories.Remove(category);
                int oldAmount = category.ParentCategory.SubCategories.Count;
                return ParseSubCategories(category.ParentCategory, data);
            }
        }
Exemplo n.º 47
0
        private List<Category> DiscoverArtistCategories(LastFmCategory category, int page)
        {
            string user = category.User;
            string refererUrl = "http://www.last.fm/user/" + user + "/library/artists?date_preset=" + category.Url;
            string url = refererUrl + "&_pjax=%23content&page=" + page;
            List<Category> cats = new List<Category>();
            string data = GetWebData(url, cookies: Cookies, referer: refererUrl);
            Regex regex = new Regex(@"img src=""(?<img>[^""]*)[^>]*?class=""avatar.*?library/music/(?<url>[^\?]*).*?>(?<name>[^<]*)</a>", RegexOptions.Singleline);
            foreach (Match m in regex.Matches(data))
            {
                RssLink artistCat = new RssLink()
                {
                    Name = HttpUtility.HtmlDecode(m.Groups["name"].Value),
                    Thumb = m.Groups["img"].Value,
                    HasSubCategories = true,
                    SubCategories = new List<Category>(),
                    SubCategoriesDiscovered = true,
                    ParentCategory = category
                };

                LastFmCategory artistRadio = new LastFmCategory()
                {
                    Name = "Play artist radio",
                    Url = "http://www.last.fm/player/station/music/" + m.Groups["url"].Value + "?ajax={0}",
                    User = user,
                    Thumb = m.Groups["img"].Value,
                    ParentCategory = artistCat,
                };
                artistRadio.Other = (Func<List<VideoInfo>>)(() => GetJsonVideos(artistRadio, 1));
                artistCat.SubCategories.Add(artistRadio);

                if (user != username)
                {
                    LastFmCategory artistUserScrobbledTracks = new LastFmCategory()
                    {
                        Name = "Scrobbles (" + username + ")",
                        Url = "http://www.last.fm/user/" + username + "/library/music/" + m.Groups["url"].Value + "/+tracks",
                        User = username,
                        Thumb = m.Groups["img"].Value,
                        ParentCategory = artistCat
                    };
                    artistUserScrobbledTracks.Other = (Func<List<VideoInfo>>)(() => GetHtmlVideos(artistUserScrobbledTracks, 1, new SerializableDictionary<string, string>() { { "date_preset", "ALL_TIME" } }));
                    artistCat.SubCategories.Add(artistUserScrobbledTracks);
                }

                LastFmCategory artistScrobbledTracks = new LastFmCategory()
                {
                    Name = "Scrobbles (" + user + ")",
                    Url = "http://www.last.fm/user/" + user + "/library/music/" + m.Groups["url"].Value + "/+tracks",
                    User = user,
                    Thumb = m.Groups["img"].Value,
                    ParentCategory = artistCat
                };
                artistScrobbledTracks.Other = (Func<List<VideoInfo>>)(() => GetHtmlVideos(artistScrobbledTracks, 1, new SerializableDictionary<string, string>() { { "date_preset", "ALL_TIME" } }));
                artistCat.SubCategories.Add(artistScrobbledTracks);

                LastFmCategory artistAlbums = new LastFmCategory()
                {
                    Name = "Albums",
                    Url = "http://www.last.fm/music/" + m.Groups["url"].Value + "/+albums",
                    User = user,
                    Thumb = m.Groups["img"].Value,
                    HasSubCategories = true,
                    ParentCategory = artistCat,
                    SubCategories = new List<Category>()
                };
                artistAlbums.Other = (Func<List<Category>>)(() => DiscoverAlbumsCategories(artistAlbums, 1));
                artistCat.SubCategories.Add(artistAlbums);

                LastFmCategory artistTracks = new LastFmCategory()
                {
                    Name = "Tracks",
                    Url = "http://www.last.fm/music/" + m.Groups["url"].Value + "/+tracks",
                    User = user,
                    Thumb = m.Groups["img"].Value,
                    ParentCategory = artistCat
                };
                artistTracks.Other = (Func<List<VideoInfo>>)(() => GetHtmlVideos(artistTracks, 1, null));
                artistCat.SubCategories.Add(artistTracks);

                cats.Add(artistCat);
            }
            regex = new Regex(@"<li class=""next"">(?<next>.*?)</li", RegexOptions.Singleline);
            Match nextMatch = regex.Match(data);
            if (nextMatch.Success && !string.IsNullOrWhiteSpace(nextMatch.Groups["next"].Value))
            {
                NextPageCategory npc = new NextPageCategory()
                {
                    Name = "Next",
                    ParentCategory = category,
                    Other = (Func<List<Category>>)(() => DiscoverArtistCategories(category, page + 1))
                };
                cats.Add(npc);
            }
            return cats;
        }
Exemplo n.º 48
0
        public override int DiscoverNextPageCategories(NextPageCategory category)
        {
            string data = getSubcatWebData(category.Url);

            category.ParentCategory.SubCategories.Remove(category);
            int oldAmount = category.ParentCategory.SubCategories.Count;
            return ParseSubCategories(category.ParentCategory, data);
        }
Exemplo n.º 49
0
 public override int DiscoverNextPageCategories(NextPageCategory category)
 {
     category.ParentCategory.SubCategories.Remove(category);
     return ParseSubCategories(category.ParentCategory, ((TVNNextPageCategory)category).PageNr);
 }
Exemplo n.º 50
0
 public override int DiscoverNextPageCategories(NextPageCategory category)
 {
     // remove the NextPageCategory from the list as we are resolving it now
     category.ParentCategory.SubCategories.Remove(category);
     // query Youtube to get the feed results
     var feed = service.Query(new YouTubeQuery(category.Url));
     foreach (var entry in feed.Entries)
     {
         category.ParentCategory.SubCategories.Add(new RssLink()
         {
             Name = entry is SubscriptionEntry ? ((SubscriptionEntry)entry).UserName : entry.Title.Text,
             Url = entry is SubscriptionEntry ? YouTubeQuery.CreateUserUri(((SubscriptionEntry)entry).UserName) : entry.Content.Src.Content,
             ParentCategory = category.ParentCategory,
             EstimatedVideoCount = (entry is PlaylistsEntry) ? (uint?)(entry as PlaylistsEntry).CountHint : null
         });
     }
     // if there are more results add a new NextPageCategory
     if (feed.NextChunk != null)
     {
         category.ParentCategory.SubCategories.Add(new NextPageCategory() { ParentCategory = category.ParentCategory, Url = feed.NextChunk });
     }
     // return the number of categories we discovered
     return feed.Entries.Count;
 }
Exemplo n.º 51
0
 /// <summary>
 /// Override this method in your derived Util when you need paging in a list of <see cref="Category"/>s.
 /// It will be called when the last item in that list is a <see cref="NextPageCategory"/>.
 /// </summary>
 /// <param name="category">The category item that you used to store info about how to get the next page categories.</param>
 /// <returns>The number of new categories discovered.</returns>
 public virtual int DiscoverNextPageCategories(NextPageCategory category)
 {
     return 0;
 }
Exemplo n.º 52
0
 public override int DiscoverNextPageCategories(NextPageCategory category)
 {
     return this.DiscoverSubCategories(category);
 }
Exemplo n.º 53
0
        private int AddSubcats(HtmlNode node, RssLink parentCat)
        {
            var subs = node.SelectNodes(".//article");
            foreach (var sub in subs)
            {
                RssLink subcat = new RssLink() { ParentCategory = parentCat };
                subcat.Name = HttpUtility.HtmlDecode(sub.SelectSingleNode(".//a[@title]").Attributes["title"].Value.Trim());
                subcat.Url = FormatDecodeAbsolutifyUrl(parentCat.Url, sub.SelectSingleNode(".//a[@href]").Attributes["href"].Value, null, UrlDecoding.None);
                subcat.Thumb = getThumb(sub.SelectSingleNode(".//picture/img"));

                parentCat.SubCategories.Add(subcat);
            }

            var np = node.SelectSingleNode(".//a[@href and text()='More shows']");
            nextPageAvailable = false;
            if (np != null)
            {
                string url = CreateUrl(parentCat.Url, np.Attributes["href"].Value);
                var npCat = new NextPageCategory() { Url = url, ParentCategory = parentCat };
                parentCat.SubCategories.Add(npCat);
            }

            parentCat.SubCategoriesDiscovered = true;
            return parentCat.SubCategories.Count;
        }
Exemplo n.º 54
0
 public override int DiscoverNextPageCategories(NextPageCategory category)
 {
     category.ParentCategory.SubCategories.Remove(category);
     var method = category.Other as Func<List<Category>>;
     if (method != null)
     {
         List<Category> cats = method.Invoke();
         category.ParentCategory.SubCategories.AddRange(cats);
         return cats.Count;
     }
     return 0;
 }
Exemplo n.º 55
0
        private List<Category> GetShows(int page, Category parentCategory = null, string tag = "")
        {
            List<Category> shows = new List<Category>();
            string url = string.Concat(string.Concat(string.Format(showsUrl, page, tag), (showPremium ? "" : "&is_free=true")));
            JArray items = JArray.Parse(GetWebData<string>(url));
            foreach (JToken item in items)
            {
                RssLink show = new RssLink();

                show.Name = (item["name"] == null) ? "": item["name"].Value<string>();
                show.Url = (item["nid"] == null) ? "" : item["nid"].Value<string>();
                show.Description = (item["description"] == null) ? "" : item["description"].Value<string>();
                show.Thumb = (item["program_image"] == null) ? "" : item["program_image"].Value<string>();
                show.ParentCategory = parentCategory;
                show.SubCategories = new List<Category>();
                show.HasSubCategories = true;
                show.Other = (Func<List<Category>>)(() => GetShow(show));
                shows.Add(show);
            }

            if (items.Count > 39)
            {
                NextPageCategory next = new NextPageCategory();
                next.ParentCategory = parentCategory;
                next.Other = (Func<List<Category>>)(() => GetShows(page + 1, parentCategory, tag));
                shows.Add(next);
            }
            return shows;
        }
Exemplo n.º 56
0
        private List<Category> GetListCategories(Category parentCategory, string listType, uint startIndex)
        {
            List<Category> cats = new List<Category>();

            string data = MyGetWebData(ShaktiApi + "/" + BuildId + "/pathEvaluator?withSize=true&materialize=true&model=harris&fallbackEsn=SLW32",
                postData: @"{""paths"":[[""lolomo"",""summary""],[""lolomo"",""" + listType + @""",{""from"":" + startIndex + @",""to"":" + (startIndex + noOfItems) + @"},[""summary"",""title"",""synopsis"",""queue"",""userRating"",""runtime"",""releaseYear""]],[""lolomo"",""" + listType + @""",{""from"":" + startIndex + @",""to"":" + (startIndex + noOfItems) + @"},""boxarts"",""_342x192"",""jpg""],[""lolomo"",""" + listType + @""",[""context"",""id"",""length"",""name"",""trackIds"",""requestId""]]],""authURL"":""" + latestAuthUrl + @"""}",
                contentType: "application/json");
            JObject json = (JObject)JsonConvert.DeserializeObject(data);
            if (json["value"] != null && json["value"]["videos"] != null)
            {

                foreach (JToken token in json["value"]["videos"].Where(t => t.Values().Count() > 1 && t.First()["title"] != null))
                {
                    JToken item = token.First();
                    JToken summary = item["summary"];
                    JToken userRating = item["userRating"];
                    NetflixCategory cat = new NetflixCategory() { ParentCategory = parentCategory, Name = item["title"].Value<string>(), HasSubCategories = true, InQueue = item["queue"]["inQueue"].Value<bool>(), IsShow = summary["type"].Value<string>() == "show" };
                    cat.Description = item["synopsis"].Value<string>() + "\r\n" + item["releaseYear"].Value<string>();
                    if (!string.IsNullOrWhiteSpace(userRating["userRating"].ToString()))
                        cat.Description += "\r\n" + Translate("User rating") + ": " + userRating["userRating"].ToString();
                    else if (!string.IsNullOrWhiteSpace(userRating["predicted"].ToString()))
                        cat.Description += "\r\n"+ string.Format (Translate("Predicted rating for {0}"), ProfileName) +": " + userRating["predicted"].ToString();
                    if (!string.IsNullOrWhiteSpace(userRating["average"].ToString()))
                        cat.Description += "\r\n" + Translate("Avg. rating") + ": " + userRating["average"].ToString();
                    cat.Runtime = cat.IsShow ? 0 : item["runtime"].Value<int>();
                    cat.Thumb = item["boxarts"]["_342x192"]["jpg"]["url"].Value<string>();
                    cat.Url = summary["id"].Value<UInt32>().ToString();
                    cat.Other = (Func<List<Category>>)(() => GetTitleCategories(cat));
                    cats.Add(cat);
                }

                //Paging
                int length = json["value"]["lists"].First(t => t.Values().Count() > 1).First()["length"].Value<int>();
                if (length > noOfItems + startIndex)
                {
                    NextPageCategory next = new NextPageCategory() { ParentCategory = parentCategory };
                    next.Other = (Func<List<Category>>)(() => GetListCategories(parentCategory, listType, noOfItems + startIndex + 1));
                    cats.Add(next);
                }
            }
            //Do not remember My List, need to be able to load new items
            parentCategory.SubCategoriesDiscovered = false;
            return cats;
        }
Exemplo n.º 57
0
        private List<Category> GetSubCategories(Category parentCategory, string categoryType, uint startIndex, bool getSubGenres = false)
        {
            List<Category> cats = new List<Category>();
            string id = (parentCategory as RssLink).Url;
            string data;
            JObject json;
            if (getSubGenres)
            {
                Category subgenreCat = new Category() {Name = Translate("Subgenres"), SubCategories = new List<Category>(), ParentCategory = parentCategory, HasSubCategories = true, SubCategoriesDiscovered = true};
                data = MyGetWebData(ShaktiApi + "/" + BuildId + "/pathEvaluator?withSize=true&materialize=true&model=harris&fallbackEsn=SLW32",
                    postData: @"{""paths"":[[""genres""," + id + @",""subgenres"",{""from"":0,""to"":20},""summary""]],""authURL"":""" + latestAuthUrl + @"""}",
                    contentType: "application/json");
                json = (JObject)JsonConvert.DeserializeObject(data);
                foreach (JToken token in json["value"]["genres"].Where(t => t.Values().Count() > 1 && t.First()["summary"] != null))
                {
                    JToken summary = token.First()["summary"];
                    RssLink subCat = new RssLink() { Name = summary["menuName"].Value<string>(), Url = summary["id"].Value<UInt32>().ToString(), HasSubCategories = true, ParentCategory = subgenreCat};
                    subCat.Other = (Func<List<Category>>)(() => GetSubCategories(subCat, categoryType, 0));
                    subgenreCat.SubCategories.Add(subCat);
                }
                if (subgenreCat.SubCategories.Count > 0)
                {
                    cats.Add(subgenreCat);
                }
            }

            data = MyGetWebData(ShaktiApi + "/" + BuildId + "/pathEvaluator?withSize=true&materialize=true&model=harris&fallbackEsn=SLW32",
                postData: @"{""paths"":[[""" + categoryType + @"""," + id + @",{""from"":" + startIndex + @",""to"":" + (startIndex + noOfItems) + @"},[""summary"",""title"",""synopsis"",""queue"",""userRating"",""runtime"",""releaseYear""]],[""" + categoryType + @"""," + id + @",{""from"":" + startIndex + @",""to"":" + (startIndex + noOfItems) + @"},""boxarts"",""_342x192"",""jpg""]],""authURL"":""" + latestAuthUrl + @"""}",
                contentType: "application/json");
            json = (JObject)JsonConvert.DeserializeObject(data);
            if (json["value"] != null && json["value"]["videos"] != null)
            {
                foreach (JToken token in json["value"]["videos"].Where(t => t.Values().Count() > 1 && t.First()["title"] != null))
                {
                    JToken item = token.First();
                    JToken summary = item["summary"];
                    JToken userRating = item["userRating"];
                    NetflixCategory cat = new NetflixCategory() { ParentCategory = parentCategory, Name = item["title"].Value<string>(), HasSubCategories = true, InQueue = item["queue"]["inQueue"].Value<bool>(), IsShow = summary["type"].Value<string>() == "show" };
                    cat.Description = item["synopsis"].Value<string>() + "\r\n " + item["releaseYear"].Value<string>();
                    if (!string.IsNullOrWhiteSpace(userRating["userRating"].ToString()))
                        cat.Description += "\r\n" + Translate("User rating") + ": " + userRating["userRating"].ToString();
                    else if (!string.IsNullOrWhiteSpace(userRating["predicted"].ToString()))
                        cat.Description += "\r\n" + string.Format(Translate("Predicted rating for {0}"), ProfileName) + ": " + userRating["predicted"].ToString();
                    if (!string.IsNullOrWhiteSpace(userRating["average"].ToString()))
                        cat.Description += "\r\n" + Translate("Avg. rating") + ": " + userRating["average"].ToString();
                    cat.Runtime = cat.IsShow ? 0 : item["runtime"].Value<int>();
                    cat.Thumb = item["boxarts"]["_342x192"]["jpg"]["url"].Value<string>();
                    cat.Url = summary["id"].Value<UInt32>().ToString();
                    cat.Other = (Func<List<Category>>)(() => GetTitleCategories(cat));
                    cats.Add(cat);
                }
                if (cats.Count() > noOfItems)
                {
                    NextPageCategory next = new NextPageCategory() { ParentCategory = parentCategory };
                    next.Other = (Func<List<Category>>)(() => GetSubCategories(parentCategory, categoryType, noOfItems + startIndex + 1)); 
                    cats.Add(next);
                }
            }
            parentCategory.SubCategoriesDiscovered = true;
            return cats;
        }
Exemplo n.º 58
0
 public override int DiscoverNextPageCategories(NextPageCategory category)
 {
     return(this.DiscoverSubCategories(category));
 }
Exemplo n.º 59
0
        public override int DiscoverNextPageCategories(NextPageCategory category)
        {
            int dynamicCategoriesCount = 0;
            String baseWebData = GetWebData(category.Url, forceUTF8: true);

            HtmlAgilityPack.HtmlDocument document = new HtmlAgilityPack.HtmlDocument();
            document.LoadHtml(baseWebData);

            HtmlAgilityPack.HtmlNodeCollection shows = document.DocumentNode.SelectNodes(".//div[@class='movie-border']");

            foreach (var show in shows)
            {
                this.Settings.Categories.Add(
                    new RssLink()
                    {
                        Name = show.SelectSingleNode(".//a/.//h5").InnerText,
                        Url = Utils.FormatAbsoluteUrl(show.SelectSingleNode(".//a").Attributes["href"].Value, PrimaUtil.baseUrl),
                        HasSubCategories = true
                    });

                dynamicCategoriesCount++;
            }

            HtmlAgilityPack.HtmlNode nextPageNode = document.DocumentNode.SelectSingleNode(".//script[contains(text(), 'infinity-scroll')]/text()");

            if (nextPageNode != null)
            {
                String content = document.DocumentNode.SelectSingleNode(".//script/text()").InnerText.Trim();
                String[] parts = content.Split(new String[] { "'" }, StringSplitOptions.RemoveEmptyEntries);

                foreach (var part in parts)
                {
                    Uri result;

                    if (Uri.TryCreate(part, UriKind.Absolute, out result))
                    {
                        this.Settings.Categories.Add(new NextPageCategory() { Url = part });
                        dynamicCategoriesCount++;

                        break;
                    }
                }
            }

            this.Settings.DynamicCategoriesDiscovered = true;
            return dynamicCategoriesCount;
        }
        /// <summary>
        /// Get the next page of categories
        /// </summary>
        /// <param name="category"></param>
        /// <returns></returns>
        public override int DiscoverNextPageCategories(NextPageCategory nextPagecategory)
        {
            string nextPage = string.Empty;

            nextPagecategory.ParentCategory.SubCategories.Remove(nextPagecategory);

            BuildCategories(nextPagecategory, null);
            
           /* if (results != null)
                nextPagecategory.ParentCategory.SubCategories.AddRange(results);
            */
            return nextPagecategory.ParentCategory.SubCategories.Count;
        }