Beispiel #1
0
        public IEnumerable <string> GetSearchDirectories()
        {
            string cacheDir = GetCacheDirectory();

            if (!Directory.Exists(cacheDir))
            {
                Directory.CreateDirectory(cacheDir);
            }

            List <string> dirs = new List <string>()
            {
                Configuration.Streaming.TVLogoDirectory,
                Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "Team MediaPortal", "MediaPortal", "thumbs", "tv", "logos"),
                Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "Team MediaPortal", "MediaPortal", "thumbs", "tv", "logo"),
                Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "Team MediaPortal", "MediaPortal", "thumbs", "Radio"),
                cacheDir
            };

            if (Mediaportal.GetLocation(MediaportalDirectory.Skin) != null)
            {
                dirs.Add(Path.Combine(Mediaportal.GetLocation(MediaportalDirectory.Skin), "aMPed", "Media", "Logos", "Channels"));
            }

            return(dirs
                   .Where(dir => Directory.Exists(dir))
                   .Distinct());
        }
Beispiel #2
0
        public MyFilms(IPluginData data)
        {
            try
            {
                // load database path
                if (!Mediaportal.HasValidConfigFile())
                {
                    Supported = false;
                    return;
                }

                string configPath = Path.Combine(Mediaportal.GetLocation(MediaportalDirectory.Config), "MyFilms.xml");
                if (!File.Exists(configPath))
                {
                    Supported = false;
                    return;
                }

                // load config file
                XElement configFile        = XElement.Load(configPath);
                string   currentConfigNode = configFile
                                             .Elements("section")
                                             .First(x => x.Attribute("name").Value == "MyFilms")
                                             .Elements("entry")
                                             .First(x => x.Attribute("name").Value == "Current_Config")
                                             .Value;
                if (currentConfigNode != "pelis")
                {
                    Log.Info("MyFilms: currently selected config is {0}, only pelis (Ant Movie Catalog) is supported at the moment", currentConfigNode);
                    Supported = false;
                    return;
                }

                var pelis = configFile
                            .Elements("section")
                            .First(x => x.Attribute("name").Value == "pelis");

                DatabasePath = pelis
                               .Elements("entry")
                               .First(x => x.Attribute("name").Value == "AntCatalog")
                               .Value;
                if (!File.Exists(DatabasePath))
                {
                    Log.Info("MyFilms: cannot find database {0}", DatabasePath);
                    Supported = false;
                    return;
                }

                PicturePath = pelis
                              .Elements("entry")
                              .First(x => x.Attribute("name").Value == "AntPicture")
                              .Value;
                Supported = true;
            }
            catch (Exception ex)
            {
                Log.Warn("MyFilms: failed to load database path", ex);
                Supported = false;
                return;
            }

            // initialize some regular expressions
            stripActorName = new Regex(@"^([^(]*)(\(.*\))*", RegexOptions.Compiled);
            imdbId         = new Regex(@"^.*imdb.[a-z]+/title/(tt[0-9]+)/*$", RegexOptions.Compiled);
        }
Beispiel #3
0
        public MyFilms(IPluginData data)
        {
            Supported = false;

            try
            {
                // load MyFilms.xml path
                if (!Mediaportal.HasValidConfigFile())
                {
                    return;
                }

                string configPath = Path.Combine(Mediaportal.GetLocation(MediaportalDirectory.Config), "MyFilms.xml");
                if (!File.Exists(configPath))
                {
                    return;
                }

                // load current config section
                XElement configFile;
                using (var handle = File.Open(configPath, FileMode.Open, FileAccess.Read, FileShare.Read))
                    configFile = XElement.Load(handle);
                var entries = configFile.Elements("section").First(x => x.Attribute("name").Value == "MyFilms").Elements("entry");
                if (!entries.Any(x => x.Attribute("name").Value == "Default_Config") && !entries.Any(x => x.Attribute("name").Value == "Current_Config"))
                {
                    Log.Info("MyFilms: couldn't find Current_Config or Default_Config value in MyFilms.xml");
                    return;
                }
                var configSectionName = entries.Any(x => x.Attribute("name").Value == "Current_Config") ?
                                        entries.First(x => x.Attribute("name").Value == "Current_Config").Value :
                                        entries.First(x => x.Attribute("name").Value == "Default_Config").Value;

                // look for database path
                var thisSection = configFile.Elements("section").First(x => x.Attribute("name").Value == configSectionName);
                if (!thisSection.Elements("entry").Any(x => x.Attribute("name").Value == "AntCatalog"))
                {
                    Log.Info("MyFilms: couldn't find AntCatalog entry in current section ({0})", configSectionName);
                    return;
                }

                // load database
                DatabasePath = thisSection.Elements("entry").FirstOrDefault(x => x.Attribute("name").Value == "AntCatalog").Value;
                if (!File.Exists(DatabasePath))
                {
                    Log.Info("MyFilms: cannot find database {0}", DatabasePath);
                    return;
                }

                PicturePath = thisSection.Elements("entry").Any(x => x.Attribute("name").Value == "AntPicture") ?
                              thisSection.Elements("entry").FirstOrDefault(x => x.Attribute("name").Value == "AntPicture").Value : String.Empty;
                sourcePrefix = thisSection.Elements("entry").Any(x => x.Attribute("name").Value == "PathStorage") ?
                               thisSection.Elements("entry").FirstOrDefault(x => x.Attribute("name").Value == "PathStorage").Value : String.Empty;
                Supported = true;
            }
            catch (Exception ex)
            {
                Log.Warn("MyFilms: failed to load database path", ex);
                return;
            }

            // initialize some regular expressions
            stripActorName = new Regex(@"^([^(]*)(\(.*\))*", RegexOptions.Compiled);
            imdbId         = new Regex(@"^.*imdb.[a-z]+/title/(tt[0-9]+)/*$", RegexOptions.Compiled);
        }