public void AddFolder(VirtualFolder folder)
 {
     this.Items.Add(folder);
       folder.ParentId = this.Id;
       if (folder.Filter == null || folder.Filter.Length == 0)
     folder.Filter = this.Filter;
       if (folder.Identifier != null)
     this.lookup[folder.Identifier] = folder.Id;
 }
        ////
        public void Category(string name, string path)
        {
            VirtualFolder folder = new VirtualFolder(provider.CreateGuid(), name);
              AddFolderWithLookup(this.parent, folder);

              string subPath = this.path + "/" + path;
              FolderStructure f = new FolderStructure(folder, this.provider, subPath);
              f.Feed("Most popular " + name,        "popular");
              f.Feed(name + " highlights",          "highlights");
              f.Feed("All " + name + " programmes", "list");
        }
        public void Channel(string name, string path)
        {
            VirtualFolder folder = new VirtualFolder(provider.CreateGuid(), name);
              folder.Thumbnail = "http://www.bbc.co.uk/iplayer/img/station_logos/" + path + ".png";
              AddFolderWithLookup(this.parent, folder);

              string subPath = this.path + "/" + path;
              FolderStructure f = new FolderStructure(folder, this.provider, subPath);
              f.Feed("Most popular on " + name,     "popular");
              f.Feed(name + " highlights",          "highlights");
              f.Feed("All " + name + " programmes", "list");
        }
        public void Folder(string name, string path, FolderDelegate subfolderDelegate)
        {
            string subPath;

              VirtualFolder child = new VirtualFolder(provider.CreateGuid(), name);
              AddFolderWithLookup(this.parent, child);

              if (path == null) {
            subPath = this.path;
              } else {
            subPath = this.path + "/" + path;
              }

              subfolderDelegate(new FolderStructure(child, this.provider, subPath));
        }
 ////
 private void AddFolderWithLookup(VirtualFolder parent, VirtualFolder child)
 {
     parent.AddFolder(child);
       provider.CacheFolder(child);
 }
 public void Feed(string name, string path)
 {
     VirtualFolder child = new VirtualFolder(provider.CreateGuid(), name, this.path + "/" + path, true);
       AddFolderWithLookup(this.parent, child);
 }
 public static void Folder(VirtualFolder parent, BBCiPlayerProvider provider, string path, FolderDelegate subfolderDelegate)
 {
     FolderStructure f = new FolderStructure(parent, provider, path);
       subfolderDelegate(f);
 }
 ////
 public FolderStructure(VirtualFolder parent, BBCiPlayerProvider provider, string path)
 {
     this.parent       = parent;
       this.provider     = provider;
       this.path         = path;
 }
 public void CacheFolder(VirtualFolder folder)
 {
     this.folderLookup[folder.Id] = folder;
 }
        private void LoadDynamicFolder(VirtualFolder vf)
        {
            this.Log("LoadDynamicFolder: "+vf.SourceUrl);

              vf.Reset(); // Remove existing items

              try {
            foreach (ProgrammeItem prog in progDB.ProgrammesFromFeed(vf.SourceUrl)) {
              try {
            string guid = vf.FindGuid(prog.Vpid);
            if (guid == null) guid = CreateGuid();

            VideoResource info =
              new VideoResource(guid, vf.Id, prog.Title, prog.Vpid, prog.Description,
                                prog.Thumbnail, prog.Date, prog.Vpid, null,
                                prog.Duration * 1000 /* PlayOn wants ms */, 0, null, null);

            this.titleLookup[info.Id] = info;
            vf.AddMedia(info);
              } catch (Exception ex) {
            vf.AddMedia(InfoResource(vf, "Error retrieving programme details. Please restart PlayOn."));
            this.Log("Error: " + ex);
              }
            }
              } catch (Exception ex) {
            vf.AddMedia(InfoResource(vf, "Error retrieving feed. Please restart PlayOn."));
            this.Log("Error: " + ex);
              }
        }
 private VideoResource InfoResource(VirtualFolder parent, string title)
 {
     return new VideoResource(CreateGuid(), parent.Id, title, "", null,
                        null, DateTime.MinValue, CreateGuid(), null,
                        0, 0, null, null);
 }
        ////
        private void AddFolders()
        {
            this.rootFolder = new VirtualFolder(this.ID, this.Name);

              FolderStructure.Folder(rootFolder, this, feedRoot, delegate(FolderStructure root){
            root.Feed("Most Popular TV", "popular/tv/list");
            root.Feed("TV Highlights",   "highlights/tv");
            root.Folder("TV Channels", delegate(FolderStructure channels){
              channels.Channel("BBC One",          "bbc_one");
              channels.Channel("BBC Two",          "bbc_two");
              channels.Channel("BBC Three",        "bbc_three");
              channels.Channel("BBC Four",         "bbc_four");
              channels.Channel("CBBC",             "cbbc");
              channels.Channel("CBeebies",         "cbeebies");
              channels.Channel("BBC News Channel", "bbc_news24");
              channels.Channel("BBC Parliament",   "bbc_parliament");
              channels.Channel("BBC Alba",         "bbc_alba");
            });
            root.Folder("TV Categories", "categories", delegate(FolderStructure categories){
              categories.Category("Children's",        "childrens/tv");
              categories.Category("Comedy",            "comedy/tv");
              categories.Folder("Drama", "drama", delegate(FolderStructure drama){
            drama.Feed("Most popular Drama",      "popular");
            drama.Feed("Drama highlights",        "highlights");
            drama.Feed("All Drama programmes",    "list");
            drama.Feed("Action & Adventure",      "action_and_adventure/tv/list");
            drama.Feed("Biographical",            "biographical/tv/list");
            drama.Feed("Classic & Period",        "classic_and_period/tv/list");
            drama.Feed("Crime",                   "crime/tv/list");
            drama.Feed("Historical",              "historical/tv/list");
            drama.Feed("Horror & Supernatual",    "horror_and_supernatural/tv/list");
            drama.Feed("Medical",                 "medical/tv/list");
            drama.Feed("Musical",                 "musical/tv/list");
            drama.Feed("Relationships & Romance", "relationship_and_romance/tv/list");
            drama.Feed("SciFi & Fantasy",         "scifi_and_fantasy/tv/list");
            drama.Feed("Soaps",                   "soaps/tv/list");
            drama.Feed("Thriller",                "thriller/tv/list");
              });
              categories.Category("Entertainment",     "entertainment/tv");
              categories.Folder("Factual", "factual", delegate(FolderStructure factual){
            factual.Feed("Most popular Factual",       "tv/popular");
            factual.Feed("Factual highlights",         "tv/highlights");
            factual.Feed("All Factual programmes",     "tv/list");
            factual.Feed("Antiques",                   "antiques/tv/list");
            factual.Feed("Arts, Culture & the Media",  "arts_culture_and_the_media/tv/list");
            factual.Feed("Beauty & Style",             "beauty_and_style/tv/list");
            factual.Feed("Cars & Motors",              "cars_and_motors/tv/list");
            factual.Feed("Cinema",                     "cinema/tv/list");
            factual.Feed("Consumer",                   "consumer/tv/list");
            factual.Feed("Crime & Justice",            "crime_and_justice/tv/list");
            factual.Feed("Disability",                 "disability/tv/list");
            factual.Feed("Families & Relationships",   "families_and_relationships/tv/list");
            factual.Feed("Food & Drink",               "food_and_drink/tv/list");
            factual.Feed("Health & Wellbeing",         "health_and_wellbeing/tv/list");
            factual.Feed("History",                    "history/tv/list");
            factual.Feed("Homes & Gardens",            "homes_and_gardens/tv/list");
            factual.Feed("Life Stories",               "life_stories/tv/list");
            factual.Feed("Money",                      "money/tv/list");
            factual.Feed("Pets & Animals",             "pets_and_animals/tv/list");
            factual.Feed("Politics",                   "politics/tv/list");
            factual.Feed("Science & Nature",           "science_and_nature/tv/list");
            factual.Feed("Travel",                     "travel/tv/list");
              });
              categories.Category("Films",             "films/tv");
              categories.Folder("Learning", "learning", delegate(FolderStructure learning){
            learning.Feed("Most popular Learning",   "popular");
            learning.Feed("Learning highlights",     "highlights");
            learning.Feed("All Learning programmes", "list");
            learning.Feed("Adult",                   "adult/tv/list");
            learning.Feed("Pre-School",              "pre_school/tv/list");
              });
              categories.Category("Music",             "Music/tv");
              categories.Category("Religion & Ethics", "religion_and_ethics/tv");
              categories.Folder("Sport", "sport", delegate(FolderStructure sport){
            sport.Feed("Most popular Sport",   "tv/popular");
            sport.Feed("Sport highlights",     "tv/highlights");
            sport.Feed("All Sport programmes", "tv/list");
            sport.Feed("Boxing",               "boxing/tv/list");
            sport.Feed("Cricket",              "cricket/tv/list");
            sport.Feed("Equestrian",           "equestrian/tv/list");
            sport.Feed("Football",             "football/tv/list");
            sport.Feed("Gaelic Games",         "gaelic_games/tv/list");
            sport.Feed("Golf",                 "golf/tv/list");
            sport.Feed("Motorsport",           "motorsport/tv/list");
            sport.Feed("Rugby League",         "rugby_league/tv/list");
            sport.Feed("Rugby Union",          "regby_union/tv/list");
            sport.Feed("Tennis",               "tennis/tv/list");
              });
              categories.Category("Northern Ireland",  "northern_ireland/tv");
              categories.Category("Scotland",          "scotland/tv");
              categories.Category("Wales",             "wales/tv");
            });
            root.Feed("Films", "films/tv/list");
              });
        }