static SeriesMetadataExtractor()
        {
            MediaCategory  seriesCategory;
            IMediaAccessor mediaAccessor = ServiceRegistration.Get <IMediaAccessor>();

            if (!mediaAccessor.MediaCategories.TryGetValue(MEDIA_CATEGORY_NAME_SERIES, out seriesCategory))
            {
                seriesCategory = mediaAccessor.RegisterMediaCategory(MEDIA_CATEGORY_NAME_SERIES, new List <MediaCategory> {
                    DefaultMediaCategories.Video
                });
            }
            MEDIA_CATEGORIES.Add(seriesCategory);
            OnlineMatcherService.RegisterDefaultSeriesMatchers(MEDIA_CATEGORY_NAME_SERIES);
            OnlineMatcherService.RegisterDefaultSeriesSubtitleMatchers(MEDIA_CATEGORY_NAME_SERIES);

            // All non-default media item aspects must be registered
            IMediaItemAspectTypeRegistration miatr = ServiceRegistration.Get <IMediaItemAspectTypeRegistration>();

            miatr.RegisterLocallyKnownMediaItemAspectTypeAsync(TempSeriesAspect.Metadata);

            // Register reimport support
            miatr.RegisterLocallySupportedReimportMediaItemAspectTypeAsync(SeriesAspect.Metadata);
            miatr.RegisterLocallySupportedReimportMediaItemAspectTypeAsync(EpisodeAspect.Metadata);
            miatr.RegisterLocallySupportedReimportMediaItemAspectTypeAsync(VideoAspect.Metadata);
        }
Esempio n. 2
0
        static MovieMetadataExtractor()
        {
            MediaCategory  movieCategory;
            IMediaAccessor mediaAccessor = ServiceRegistration.Get <IMediaAccessor>();

            if (!mediaAccessor.MediaCategories.TryGetValue(MEDIA_CATEGORY_NAME_MOVIE, out movieCategory))
            {
                movieCategory = mediaAccessor.RegisterMediaCategory(MEDIA_CATEGORY_NAME_MOVIE, new List <MediaCategory> {
                    DefaultMediaCategories.Video
                });
            }
            MEDIA_CATEGORIES.Add(movieCategory);
            OnlineMatcherService.RegisterDefaultMovieMatchers(MEDIA_CATEGORY_NAME_MOVIE);
            OnlineMatcherService.RegisterDefaultMovieSubtitleMatchers(MEDIA_CATEGORY_NAME_MOVIE);

            // Register reimport support
            IMediaItemAspectTypeRegistration miatr = ServiceRegistration.Get <IMediaItemAspectTypeRegistration>();

            miatr.RegisterLocallySupportedReimportMediaItemAspectTypeAsync(MovieAspect.Metadata);
            miatr.RegisterLocallySupportedReimportMediaItemAspectTypeAsync(VideoAspect.Metadata);
        }
        public void Activated(PluginRuntime pluginRuntime)
        {
            var meta = pluginRuntime.Metadata;

            Logger.Info(string.Format("{0} v{1} [{2}] by {3}", meta.Name, meta.PluginVersion, meta.Description, meta.Author));

            Logger.Debug("SubtitleDownloaderProviderPlugin: Registering movie subtitle matchers");
            var providerNames  = SubtitleDownloader.SubtitleDownloaderSetup.GetSupportedProviderNames();
            var movieProviders = new BaseSubtitleDownloaderMatcher[]
            {
                new MovieSubtitlesMatcher(),
                new OpenSubtitlesMatcher(),
                new PodnapisiMatcher(),
                new SousTitresMatcher(),
                new SublightMatcher(),
                new SubsceneMatcher(),
                new TitloviMatcher(),
                new TitulkyMatcher(),
            };

            OnlineMatcherService.RegisterSubtitleMatchers(movieProviders.Where(p => providerNames.Contains(p.SubtitleDownloaderProviderId)).ToArray(), DEFAULT_MOVIE_CATEGORY);

            Logger.Debug("SubtitleDownloaderProviderPlugin: Registering series subtitle matchers");
            var seriesProviders = new BaseSubtitleDownloaderMatcher[]
            {
                new OpenSubtitlesMatcher(),
                new PodnapisiMatcher(),
                new SousTitresMatcher(),
                new SublightMatcher(),
                new SubsceneMatcher(),
                new TitloviMatcher(),
                new TitulkyMatcher(),
                new TvSubtitlesMatcher(),
            };

            OnlineMatcherService.RegisterSubtitleMatchers(seriesProviders.Where(p => providerNames.Contains(p.SubtitleDownloaderProviderId)).ToArray(), DEFAULT_SERIES_CATEGORY);
        }
        private static void LoadScripts()
        {
            try
            {
                _metadataExtractorCustomCategories = new ConcurrentBag <string>();

                //Load latest version of scripts
                Assembly assembly = Assembly.GetExecutingAssembly();
                Dictionary <string, List <ScriptableScraperMovieMatcher> > matchers = new Dictionary <string, List <ScriptableScraperMovieMatcher> >();
                List <string> categories = new List <string>();
                Dictionary <int, ScriptableScript> scripts = new Dictionary <int, ScriptableScript>();
                foreach (var file in Directory.EnumerateFiles(Path.Combine(Path.GetDirectoryName(assembly.Location), "MovieScraperScripts\\"), "*.xml"))
                {
                    var script = new ScriptableScript();
                    if (script.Load(file))
                    {
                        if (string.IsNullOrEmpty(script.Category))
                        {
                            script.Category = MEDIA_CATEGORY_NAME_MOVIE;
                        }

                        if (!scripts.ContainsKey(script.ScriptID))
                        {
                            scripts.Add(script.ScriptID, script);
                        }
                        else if (Version.TryParse(scripts[script.ScriptID].Version, out var curVer) && Version.TryParse(script.Version, out var newVer) && newVer > curVer)
                        {
                            scripts[script.ScriptID] = script;
                        }
                    }
                }

                //Categorize scripts
                foreach (var script in scripts.Values)
                {
                    if (!matchers.ContainsKey(script.Category))
                    {
                        matchers.Add(script.Category, new List <ScriptableScraperMovieMatcher>());
                    }
                    matchers[script.Category].Add(new ScriptableScraperMovieMatcher(script));
                }

                //Register movie matchers
                foreach (var matcher in matchers)
                {
                    if (!matcher.Key.Equals(MEDIA_CATEGORY_NAME_MOVIE, StringComparison.OrdinalIgnoreCase))
                    {
                        if (!categories.Contains(matcher.Key))
                        {
                            //Store custom MDE movie category
                            categories.Add(matcher.Key);
                            _metadataExtractorCustomCategories.Add(matcher.Key);
                        }
                    }

                    OnlineMatcherService.RegisterMovieMatchers(matcher.Value.ToArray(), matcher.Key);
                }
            }
            catch (Exception ex)
            {
                ServiceRegistration.Get <ILogger>().Error("ScriptableMetadataExtractor: Error initializing scripts", ex);
            }
        }