public override int DiscoverSubCategories(Category parentCategory)
        {
            parentCategory.SubCategories = new List<Category>();

            string id = ((RssLink)parentCategory).Url;

            if (id == NrkBrowserConstants.MENU_ITEM_ID_ALPHABETICAL_LIST)
            {
                foreach(Program prg in nrkParser.GetAllPrograms())
                {
                    parentCategory.SubCategories.Add(new RssLink() { Url = prg.ID, Name = prg.Title, Description = prg.Description, Thumb = prg.Bilde, Other = prg, HasSubCategories = true, ParentCategory = parentCategory });
                }
            }
            else if (id == NrkBrowserConstants.MENU_ITEM_ID_CATEGORIES)
            {
                foreach (Vattenmelon.Nrk.Domain.Category cat in nrkParser.GetCategories())
                {
                    parentCategory.SubCategories.Add(new RssLink() { Url = cat.ID, Name = cat.Title, Other = cat, HasSubCategories = true, ParentCategory = parentCategory });
                }
            }
            else if (id == NrkBrowserConstants.MENU_ITEM_ID_MOST_WATCHED)
            {
                parentCategory.SubCategories.Add(new RssLink() { Url = NrkBrowserConstants.MENU_ITEM_ID_MEST_SETTE_UKE, Name = NrkTranslatableStrings.MENU_ITEM_TITLE_MEST_SETTE_UKE, Description = NrkTranslatableStrings.MENU_ITEM_DESCRIPTION_MEST_SETTE_UKE, ParentCategory = parentCategory });
                parentCategory.SubCategories.Add(new RssLink() { Url = NrkBrowserConstants.MENU_ITEM_ID_MEST_SETTE_MAANED, Name = NrkTranslatableStrings.MENU_ITEM_TITLE_MEST_SETTE_MAANED, Description = NrkTranslatableStrings.MENU_ITEM_DESCRIPTION_MEST_SETTE_MAANED, ParentCategory = parentCategory });
                parentCategory.SubCategories.Add(new RssLink() { Url = NrkBrowserConstants.MENU_ITEM_ID_MEST_SETTE_TOTALT, Name = NrkTranslatableStrings.MENU_ITEM_TITLE_MEST_SETTE_TOTALT, Description = NrkTranslatableStrings.MENU_ITEM_DESCRIPTION_MEST_SETTE_TOTALT, ParentCategory = parentCategory });
            }
            else if (id == NrkBrowserConstants.MENU_ITEM_ID_NRKBETA)
            {
                parentCategory.SubCategories.Add(new RssLink() { Url = NrkBrowserConstants.MENU_ITEM_ID_NRKBETA_SISTE_KLIPP, Name = NrkTranslatableStrings.MENU_ITEM_TITLE_NRKBETA_LATEST_CLIPS, ParentCategory = parentCategory });
                parentCategory.SubCategories.Add(new RssLink() { Url = NrkBrowserConstants.MENU_ITEM_ID_NRKBETA_TVSERIER, Name = NrkTranslatableStrings.MENU_ITEM_TITLE_NRKBETA_TV_SERIES, ParentCategory = parentCategory });
                parentCategory.SubCategories.Add(new RssLink() { Url = NrkBrowserConstants.MENU_ITEM_ID_NRKBETA_DIVERSE, Name = NrkTranslatableStrings.MENU_ITEM_TITLE_NRKBETA_OTHER, ParentCategory = parentCategory });
                parentCategory.SubCategories.Add(new RssLink() { Url = NrkBrowserConstants.MENU_ITEM_ID_NRKBETA_PRESENTASJONER, Name = NrkTranslatableStrings.MENU_ITEM_TITLE_NRKBETA_PRESENTATIONS, ParentCategory = parentCategory });
                parentCategory.SubCategories.Add(new RssLink() { Url = NrkBrowserConstants.MENU_ITEM_ID_NRKBETA_KONFERANSER_OG_MESSER, Name = NrkTranslatableStrings.MENU_ITEM_TITLE_NRKBETA_CONFERENCES, ParentCategory = parentCategory });
                parentCategory.SubCategories.Add(new RssLink() { Url = NrkBrowserConstants.MENU_ITEM_ID_NRKBETA_FRA_TV, Name = NrkTranslatableStrings.MENU_ITEM_TITLE_NRKBETA_FROM_TV, ParentCategory = parentCategory });
                parentCategory.SubCategories.Add(new RssLink() { Url = NrkBrowserConstants.MENU_ITEM_ID_NRKBETA_HD_KLIPP, Name = NrkTranslatableStrings.MENU_ITEM_TITLE_NRKBETA_HD_CLIPS, ParentCategory = parentCategory });
            }
            else if (id == NrkBrowserConstants.MENU_ITEM_ID_PODCASTS_VIDEO)
            {
                foreach (PodKast pk in nrkParser.GetVideoPodkaster())
                {
                    parentCategory.SubCategories.Add(new RssLink() { Url = pk.ID, Name = pk.Title, Description = pk.Description, Thumb = pk.Bilde, Other = pk, ParentCategory = parentCategory });
                }
            }
            else if (parentCategory.Other is Vattenmelon.Nrk.Domain.Category)
            {
                foreach (Program prg in nrkParser.GetPrograms((Vattenmelon.Nrk.Domain.Category)parentCategory.Other))
                {
                    parentCategory.SubCategories.Add(new RssLink() { Url = prg.ID, Name = prg.Title, Description = prg.Description, Thumb = prg.Bilde, Other = prg, HasSubCategories = true, ParentCategory = parentCategory });
                }
            }
            else if (parentCategory.Other is Program)
            {
                foreach (Folder f in nrkParser.GetFolders((Program)parentCategory.Other))
                {
                    parentCategory.SubCategories.Add(new RssLink() { Url = f.ID, Name = f.Title, Other = f, ParentCategory = parentCategory });
                }
                if (parentCategory.SubCategories.Count == 0)
                {
                    // if no folder found, create a Category for "All"
                    parentCategory.SubCategories.Add(new RssLink() { Name = Translation.Instance.All, Other = parentCategory.Other, ParentCategory = parentCategory });
                }
            }

            parentCategory.SubCategoriesDiscovered = true;

            return parentCategory.SubCategories.Count;
        }
        public override List<VideoInfo> GetVideos(Category category)
        {
            IList<Item> items = null;
            string id = ((RssLink)category).Url;

            if (id == NrkBrowserConstants.MENU_ITEM_ID_LIVE)
            {
                items = nrkParser.GetDirektePage();
            }
            else if (id == NrkBrowserConstants.MENU_ITEM_ID_LIVE_ALTERNATE)
            {
                items = new List<Item>();
                items.Add(new Stream(NrkParserConstants.STREAM_PREFIX + "03" + liveStreamUrlSuffix, NrkBrowserConstants.MENU_ITEM_LIVE_ALTERNATE_NRK1));
                items.Add(new Stream(NrkParserConstants.STREAM_PREFIX + "04" + liveStreamUrlSuffix, NrkBrowserConstants.MENU_ITEM_LIVE_ALTERNATE_NRK2));
                items.Add(new Stream(NrkParserConstants.STREAM_PREFIX + "05" + liveStreamUrlSuffix, NrkBrowserConstants.MENU_ITEM_LIVE_ALTERNATE_3));
                items.Add(new Stream(NrkParserConstants.STREAM_PREFIX + "08" + liveStreamUrlSuffix, NrkBrowserConstants.MENU_ITEM_LIVE_ALTERNATE_4));
            }
            else if (id == NrkBrowserConstants.MENU_ITEM_ID_CHOOSE_STREAM_MANUALLY)
            {
                items = new List<Item>();
                for (int i = 0; i < 10; i++)
                {
                    items.Add(new Stream(NrkParserConstants.STREAM_PREFIX + i.ToString("D2") + liveStreamUrlSuffix, "Strøm " + i));
                }
            }
            else if (id == NrkBrowserConstants.MENU_ITEM_ID_LATEST_CLIPS)
            {
                items = nrkParser.GetSistePaaForsiden();
            }
            else if (id == NrkBrowserConstants.MENU_ITEM_ID_RECOMMENDED_PROGRAMS)
            {
                items = nrkParser.getAnbefalte();
            }
            else if (id == NrkBrowserConstants.MENU_ITEM_ID_MEST_SETTE_UKE)
            {
                items = nrkParser.GetMestSette(7);
                foreach (Item i in items) i.Description = String.Format(NrkTranslatableStrings.DESCRIPTION_CLIP_SHOWN_TIMES, i.Description);
            }
            else if (id == NrkBrowserConstants.MENU_ITEM_ID_MEST_SETTE_MAANED)
            {
                items = nrkParser.GetMestSette(31);
                foreach (Item i in items) i.Description = String.Format(NrkTranslatableStrings.DESCRIPTION_CLIP_SHOWN_TIMES, i.Description);
            }
            else if (id == NrkBrowserConstants.MENU_ITEM_ID_MEST_SETTE_TOTALT)
            {
                items = nrkParser.GetMestSette(3650);
                foreach (Item i in items) i.Description = String.Format(NrkTranslatableStrings.DESCRIPTION_CLIP_SHOWN_TIMES, i.Description);
            }
            else if (id == NrkBrowserConstants.MENU_ITEM_ID_NRKBETA_SISTE_KLIPP)
            {
                items = new NrkBetaXmlParser().FindLatestClips().getClips();
            }
            else if (id == NrkBrowserConstants.MENU_ITEM_ID_NRKBETA_TVSERIER || id == NrkBrowserConstants.MENU_ITEM_ID_NRKBETA_FRA_TV)
            {
                NrkBetaXmlParser nrkBetaParser = new NrkBetaXmlParser(NrkParserConstants.NRK_BETA_FEEDS_KATEGORI_URL, NrkParserConstants.NRK_BETA_SECTION_FRA_TV);
                items = nrkBetaParser.getClips();
            }
            else if (id == NrkBrowserConstants.MENU_ITEM_ID_NRKBETA_DIVERSE)
            {
                NrkBetaXmlParser nrkBetaParser = new NrkBetaXmlParser(NrkParserConstants.NRK_BETA_FEEDS_KATEGORI_URL, NrkParserConstants.NRK_BETA_SECTION_DIVERSE);
                items = nrkBetaParser.getClips();
            }
            else if (id == NrkBrowserConstants.MENU_ITEM_ID_NRKBETA_KONFERANSER_OG_MESSER)
            {
                NrkBetaXmlParser nrkBetaParser = new NrkBetaXmlParser(NrkParserConstants.NRK_BETA_FEEDS_KATEGORI_URL, NrkParserConstants.NRK_BETA_SECTION_KONFERANSER_OG_MESSER);
                items = nrkBetaParser.getClips();
            }
            else if (id == NrkBrowserConstants.MENU_ITEM_ID_NRKBETA_PRESENTASJONER)
            {
                NrkBetaXmlParser nrkBetaParser = new NrkBetaXmlParser(NrkParserConstants.NRK_BETA_FEEDS_KATEGORI_URL, NrkParserConstants.NRK_BETA_SECTION_PRESENTASJONER);
                items = nrkBetaParser.getClips();
            }
            else if (id == NrkBrowserConstants.MENU_ITEM_ID_NRKBETA_HD_KLIPP)
            {
                items = new NrkBetaXmlParser().FindHDClips().getClips();
            }
            else if (category.Other is Program)
            {
                items = nrkParser.GetClips((Program)category.Other);
            }
            else if (category.Other is Folder)
            {
                items = nrkParser.GetClips((Folder)category.Other);
            }
            else if (category.Other is PodKast)
            {
                PodkastXmlParser pxp = new PodkastXmlParser(id);
                items = pxp.getClips();
            }

            return VideosFromItems(items);
        }
예제 #3
0
        public IList<Item> GetPrograms(Category category)
        {
            string data = FetchUrl(CATEGORY_URL + category.ID);
            Regex queryBilder =
                new Regex("<li><div><a href=\"/nett-tv/prosjekt/.*?\" title=\".*?\"><img src=\"(?<imgsrc>[^\"]*)\".*?/></a><h3><a href=\"/nett-tv/prosjekt/(?<id>[^\"]*)\" title=\".*?\">(?<title>[^<]*)</a></h3><div class=\"summary\"><p>(?<desc>[^<]*)</p></div></div></li>");
            MatchCollection matches = queryBilder.Matches(data);
            List<string> bilder = new List<string>();
            List<Item> programs = new List<Item>();
            foreach (Match x in matches)
            {
                programs.Add(new Program(x.Groups["id"].Value, x.Groups["title"].Value, x.Groups["desc"].Value, x.Groups["imgsrc"].Value));
            }

            return programs;
        }