/// <summary>
        /// Instantiates a new <see cref="NfoMovieMetadataExtractor"/> object
        /// </summary>
        public StubAudioMetadataExtractor()
        {
            _metadata = new MetadataExtractorMetadata(
                metadataExtractorId: METADATAEXTRACTOR_ID,
                name: "Stub audio metadata extractor",
                metadataExtractorPriority: MetadataExtractorPriority.Stub,
                processesNonFiles: true,
                shareCategories: MEDIA_CATEGORIES,
                extractedAspectTypes: new MediaItemAspectMetadata[]
            {
                MediaAspect.Metadata,
                AudioAspect.Metadata,
                StubAspect.Metadata
            });

            _settings = ServiceRegistration.Get <ISettingsManager>().Load <StubAudioMetadataExtractorSettings>();

            if (_settings.EnableDebugLogging)
            {
                _debugLogger = FileLogger.CreateFileLogger(ServiceRegistration.Get <IPathManager>().GetPath(@"<LOG>\StubAudioMetadataExtractorDebug.log"), LogLevel.Debug, false, true);
                LogSettings();
            }
            else
            {
                _debugLogger = new NoLogger();
            }
        }
Exemple #2
0
        /// <summary>
        /// Instantiates a new <see cref="NfoSeriesMetadataExtractor"/> object
        /// </summary>
        public StubSeriesMetadataExtractor()
        {
            // The metadataExtractorPriority is intentionally set wrong to "Extended" although, depending on the
            // content of the nfo-file, it may download thumbs from the internet (and should therefore be
            // "External"). This is a temporary workaround for performance purposes. It ensures that this
            // MetadataExtractor is applied before the VideoThumbnailer (which is intentionally set to "External"
            // although it only uses local files). Creating thumbs with the VideoThumbnailer takes much longer
            // than downloading them from the internet.
            // ToDo: Correct this once we have a better priority system
            _metadata = new MetadataExtractorMetadata(
                metadataExtractorId: METADATAEXTRACTOR_ID,
                name: "Stub series metadata extractor",
                metadataExtractorPriority: MetadataExtractorPriority.Stub,
                processesNonFiles: true,
                shareCategories: MEDIA_CATEGORIES,
                extractedAspectTypes: new MediaItemAspectMetadata[]
            {
                MediaAspect.Metadata,
                EpisodeAspect.Metadata,
                StubAspect.Metadata
            });

            _settings = ServiceRegistration.Get <ISettingsManager>().Load <StubSeriesMetadataExtractorSettings>();

            if (_settings.EnableDebugLogging)
            {
                _debugLogger = FileLogger.CreateFileLogger(ServiceRegistration.Get <IPathManager>().GetPath(@"<LOG>\StubSeriesMetadataExtractorDebug.log"), LogLevel.Debug, false, true);
                LogSettings();
            }
            else
            {
                _debugLogger = new NoLogger();
            }
        }
        public IEnumerable <IDictionary <Guid, IList <MediaItemAspect> > > ExtractStubItems(IResourceAccessor mediaItemAccessor, IEnumerable <Guid> metadataExtractorIds)
        {
            List <IDictionary <Guid, IList <MediaItemAspect> > > stubAspects = new List <IDictionary <Guid, IList <MediaItemAspect> > >();
            ICollection <IMetadataExtractor> extractors = new List <IMetadataExtractor>();

            foreach (Guid extractorId in metadataExtractorIds)
            {
                IMetadataExtractor extractor;
                if (LocalMetadataExtractors.TryGetValue(extractorId, out extractor))
                {
                    extractors.Add(extractor);
                }
            }

            // Execute all metadata extractors in order of their priority
            foreach (IMetadataExtractor extractor in extractors.OrderBy(m => m.Metadata.Priority))
            {
                try
                {
                    List <IDictionary <Guid, IList <MediaItemAspect> > > result = new List <IDictionary <Guid, IList <MediaItemAspect> > >();
                    if (extractor.TryExtractStubItems(mediaItemAccessor, result))
                    {
                        stubAspects.AddRange(result);
                    }
                }
                catch (Exception e)
                {
                    MetadataExtractorMetadata mem = extractor.Metadata;
                    ServiceRegistration.Get <ILogger>().Error("MediaAccessor: Error extracting stub items from metadata extractor '{0}' (Id: '{1}')",
                                                              e, mem.Name, mem.MetadataExtractorId);
                    throw;
                }
            }
            return(stubAspects.Count > 0 ? stubAspects : null);
        }
        public BaseScriptableMovieMetadataExtractor(string id)
        {
            try
            {
                bool loaded = _metadataExtractorCustomCategories.TryTake(out _category);

                List <MediaCategory> mediaCategories = new List <MediaCategory>();
                if (loaded)
                {
                    MediaCategory  mediaCategory;
                    IMediaAccessor mediaAccessor = ServiceRegistration.Get <IMediaAccessor>();
                    if (!mediaAccessor.MediaCategories.TryGetValue(_category, out mediaCategory))
                    {
                        mediaCategory = mediaAccessor.RegisterMediaCategory(_category, new List <MediaCategory> {
                            DefaultMediaCategories.Video
                        });
                    }
                    mediaCategories.Add(mediaCategory);
                }

                _metadata = new MetadataExtractorMetadata(new Guid(id), $"Scriptable movie metadata extractor ({(loaded ? _category : "Disabled")})", MetadataExtractorPriority.External, true,
                                                          mediaCategories, new MediaItemAspectMetadata[] { MediaAspect.Metadata, MovieAspect.Metadata });
            }
            catch (Exception ex)
            {
                ServiceRegistration.Get <ILogger>().Error("ScriptableMetadataExtractor: Error initializing metadata extractor", ex);
            }
        }
        public IDictionary <Guid, MediaItemAspect> ExtractMetadata(IResourceAccessor mediaItemAccessor,
                                                                   IEnumerable <IMetadataExtractor> metadataExtractors, bool forceQuickMode)
        {
            IDictionary <Guid, MediaItemAspect> result = new Dictionary <Guid, MediaItemAspect>();
            bool success = false;

            // Execute all metadata extractors in order of their priority
            foreach (IMetadataExtractor extractor in metadataExtractors.OrderBy(m => m.Metadata.Priority))
            {
                try
                {
                    if (extractor.TryExtractMetadata(mediaItemAccessor, result, forceQuickMode))
                    {
                        success = true;
                    }
                }
                catch (Exception e)
                {
                    MetadataExtractorMetadata mem = extractor.Metadata;
                    ServiceRegistration.Get <ILogger>().Error("MediaAccessor: Error extracting metadata from metadata extractor '{0}' (Id: '{1}')",
                                                              e, mem.Name, mem.MetadataExtractorId);
                    throw;
                }
            }
            return(success ? result : null);
        }
Exemple #6
0
 public VideoThumbnailer()
 {
     _metadata = new MetadataExtractorMetadata(METADATAEXTRACTOR_ID, "Video thumbnail extractor", MetadataExtractorPriority.Extended, true,
                                               MEDIA_CATEGORIES, new[]
     {
         ThumbnailLargeAspect.Metadata
     });
 }
Exemple #7
0
        /// <summary>
        /// Instantiates a new <see cref="NfoMovieMetadataExtractor"/> object
        /// </summary>
        public NfoMovieMetadataExtractor()
        {
            // The metadataExtractorPriority is intentionally set wrong to "Extended" although, depending on the
            // content of the nfo-file, it may download thumbs from the internet (and should therefore be
            // "External"). This is a temporary workaround for performance purposes. It ensures that this
            // MetadataExtractor is applied before the VideoThumbnailer (which is intentionally set to "External"
            // although it only uses local files). Creating thumbs with the VideoThumbnailer takes much longer
            // than downloading them from the internet.
            // ToDo: Correct this once we have a better priority system
            _metadata = new MetadataExtractorMetadata(
                metadataExtractorId: METADATAEXTRACTOR_ID,
                name: "Nfo movie metadata extractor",
                metadataExtractorPriority: MetadataExtractorPriority.Extended,
                processesNonFiles: true,
                shareCategories: MEDIA_CATEGORIES,
                extractedAspectTypes: new[]
            {
                MediaAspect.Metadata,
                VideoAspect.Metadata,
                MovieAspect.Metadata,
                ThumbnailLargeAspect.Metadata
            });

            _settings = ServiceRegistration.Get <ISettingsManager>().Load <NfoMovieMetadataExtractorSettings>();

            // The following save operation makes sure that in any case an xml-file is written for the NfoMovieMetadataExtractorSettings
            // ToDo: Remove this once the SettingsManager does this automatically
            ServiceRegistration.Get <ISettingsManager>().Save(_settings);

            if (_settings.EnableDebugLogging)
            {
                _debugLogger = FileLogger.CreateFileLogger(ServiceRegistration.Get <IPathManager>().GetPath(@"<LOG>\NfoMovieMetadataExtractorDebug.log"), LogLevel.Debug, false, true);
                LogSettings();
            }
            else
            {
                _debugLogger = new NoLogger();
            }

            var handler = new HttpClientHandler();

            if (handler.SupportsAutomaticDecompression)
            {
                // This enables the automatic decompression of the content. It does not automatically send an "Accept-Encoding" header!
                // We therefore have to add the Accept-Encoding header(s) manually below.
                // Additionally, due to the automatic decompression, HttpResponseMessage.Content.Headers DOES NOT contain
                // a "Content-Encoding" header anymore when we try to access it. It is automatically removed when decompressing.
                handler.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
            }
            else
            {
                _debugLogger.Warn("HttpClient does not support compression");
            }
            _httpClient = new HttpClient(handler);
            _httpClient.DefaultRequestHeaders.AcceptEncoding.Add(new System.Net.Http.Headers.StringWithQualityHeaderValue("gzip"));
            _httpClient.DefaultRequestHeaders.AcceptEncoding.Add(new System.Net.Http.Headers.StringWithQualityHeaderValue("deflate"));
        }
Exemple #8
0
 public MovieMetadataExtractor()
 {
     _metadata = new MetadataExtractorMetadata(METADATAEXTRACTOR_ID, "Movies metadata extractor", MetadataExtractorPriority.External, true,
                                               MEDIA_CATEGORIES, new[]
     {
         MediaAspect.Metadata,
         MovieAspect.Metadata
     });
 }
 public BluRayMetadataExtractor()
 {
     _metadata = new MetadataExtractorMetadata(METADATAEXTRACTOR_ID, "BluRay metadata extractor", true,
       SHARE_CATEGORIES, new[]
       {
         MediaAspect.Metadata,
         VideoAspect.Metadata
       });
 }
Exemple #10
0
 public ImageMetadataExtractor()
 {
     _metadata = new MetadataExtractorMetadata(METADATAEXTRACTOR_ID, "Image metadata extractor", MetadataExtractorPriority.Core, true,
                                               MEDIA_CATEGORIES, new[]
     {
         MediaAspect.Metadata,
         ImageAspect.Metadata
     });
 }
Exemple #11
0
 public AudioMetadataExtractor()
 {
     _metadata = new MetadataExtractorMetadata(METADATAEXTRACTOR_ID, "Audio metadata extractor", MetadataExtractorPriority.Core, false,
                                               MEDIA_CATEGORIES, new[]
     {
         MediaAspect.Metadata,
         AudioAspect.Metadata
     });
 }
 public BluRayMetadataExtractor()
 {
     _metadata = new MetadataExtractorMetadata(METADATAEXTRACTOR_ID, "BluRay metadata extractor", MetadataExtractorPriority.Core, false,
                                               MEDIA_CATEGORIES, new[]
     {
         MediaAspect.Metadata,
         VideoAspect.Metadata
     });
 }
Exemple #13
0
 public Tve3RecordingMetadataExtractor()
 {
     _metadata = new MetadataExtractorMetadata(METADATAEXTRACTOR_ID, "TVEngine3 recordings metadata extractor", MetadataExtractorPriority.Extended, false,
                                               MEDIA_CATEGORIES, new MediaItemAspectMetadata[]
     {
         MediaAspect.Metadata,
         VideoAspect.Metadata,
         RecordingAspect.Metadata,
     });
 }
 public ArgusRecordingSeriesMetadataExtractor()
 {
     _metadata = new MetadataExtractorMetadata(METADATAEXTRACTOR_ID, "Argus recordings series metadata extractor", MetadataExtractorPriority.Extended, false,
                                               SERIES_MEDIA_CATEGORIES, new[]
     {
         MediaAspect.Metadata,
         VideoAspect.Metadata,
         EpisodeAspect.Metadata,
     });
 }
Exemple #15
0
 public RadioRecordingMetadataExtractor()
 {
     _metadata = new MetadataExtractorMetadata(METADATAEXTRACTOR_ID, "Radio recording metadata extractor", MetadataExtractorPriority.Core, false,
                                               MEDIA_CATEGORIES, new MediaItemAspectMetadata[]
     {
         MediaAspect.Metadata,
         ProviderResourceAspect.Metadata,
         AudioAspect.Metadata,
     });
 }
 public VideoMetadataExtractor()
 {
     _metadata = new MetadataExtractorMetadata(METADATAEXTRACTOR_ID, "Video metadata extractor", MetadataExtractorPriority.Core, true,
                                               MEDIA_CATEGORIES, new[]
     {
         MediaAspect.Metadata,
         VideoAspect.Metadata,
         SeriesAspect.Metadata
     });
 }
Exemple #17
0
 public BluRayMetadataExtractor()
 {
     _metadata = new MetadataExtractorMetadata(METADATAEXTRACTOR_ID, "BluRay metadata extractor", MetadataExtractorPriority.Core, false,
                                               MEDIA_CATEGORIES, new MediaItemAspectMetadata[]
     {
         MediaAspect.Metadata,
         VideoStreamAspect.Metadata,
         ThumbnailLargeAspect.Metadata
     });
 }
 public WTVRecordingMetadataExtractor()
 {
     _metadata = new MetadataExtractorMetadata(METADATAEXTRACTOR_ID, "WTV recordings metadata extractor", MetadataExtractorPriority.Extended, false,
                                               MEDIA_CATEGORIES, new[]
     {
         MediaAspect.Metadata,
         VideoAspect.Metadata,
         RecordingAspect.Metadata,
     });
 }
 public OCVVideoThumbnailer()
 {
     // Creating thumbs with this MetadataExtractor takes much longer than downloading them from the internet.
     // This MetadataExtractor only creates thumbs if the ThumbnailLargeAspect has not been filled before.
     // ToDo: Correct this once we have a better priority system
     _metadata = new MetadataExtractorMetadata(METADATAEXTRACTOR_ID, "OpenCV video thumbnail extractor", MetadataExtractorPriority.FallBack, true,
                                               MEDIA_CATEGORIES, new[]
     {
         ThumbnailLargeAspect.Metadata
     });
 }
        public SubtitleMetadataExtractor()
        {
            _metadata = new MetadataExtractorMetadata(METADATAEXTRACTOR_ID, "Subtitle metadata extractor", MetadataExtractorPriority.FallBack, true,
                                                      MEDIA_CATEGORIES, new MediaItemAspectMetadata[]
            {
                SubtitleAspect.Metadata,
            });

            _settingWatcher = new SettingsChangeWatcher <SubtitleMetadataExtractorSettings>();
            _settingWatcher.SettingsChanged += SettingsChanged;
        }
Exemple #21
0
 public MovieMetadataExtractor()
 {
     _metadata = new MetadataExtractorMetadata(METADATAEXTRACTOR_ID, "Movies metadata extractor", MetadataExtractorPriority.External, true,
                                               MEDIA_CATEGORIES, new[]
     {
         MediaAspect.Metadata,
         VideoAspect.Metadata,
         MovieAspect.Metadata
     });
     _onlyFanArt = ServiceRegistration.Get <ISettingsManager>().Load <MovieMetadataExtractorSettings>().OnlyFanArt;
 }
Exemple #22
0
 public BassAudioMetadataExtractor()
 {
     _metadata = new MetadataExtractorMetadata(METADATAEXTRACTOR_ID, "Bass Audio metadata extractor", MetadataExtractorPriority.Core, false,
                                               MEDIA_CATEGORIES, new[]
     {
         MediaAspect.Metadata,
         AudioAspect.Metadata,
         ThumbnailLargeAspect.Metadata
     });
     _lib = BassLibraryManager.Get();
 }
Exemple #23
0
        public GameMetadataExtractor()
        {
            _metadata = new MetadataExtractorMetadata(METADATAEXTRACTOR_ID, "Games metadata extractor", MetadataExtractorPriority.External, true,
                                                      MEDIA_CATEGORIES, new[]
            {
                MediaAspect.Metadata,
                GameAspect.Metadata
            });

            _settingsWatcher.SettingsChanged += SettingsChanged;
            UpdateMediaCategories(_settingsWatcher.Settings.ConfiguredEmulators);
        }
Exemple #24
0
        public ImageMetadataExtractor()
        {
            _metadata = new MetadataExtractorMetadata(METADATAEXTRACTOR_ID, "Image metadata extractor", MetadataExtractorPriority.Core, true,
                                                      MEDIA_CATEGORIES, new[]
            {
                MediaAspect.Metadata,
                ImageAspect.Metadata,
                ThumbnailLargeAspect.Metadata
            });
            _settingWatcher = new SettingsChangeWatcher <ImageMetadataExtractorSettings>();
            _settingWatcher.SettingsChanged += SettingsChanged;

            LoadSettings();
        }
 public VideoThumbnailer()
 {
     // The metadataExtractorPriority is intentionally set wrong to "External" although
     // this MetadataExtractor does not download anything from the internet (and should therefore be
     // "Extended"). This is a temporary workaround for performance purposes. It ensures that this
     // MetadataExtractor is applied after in particular the NfoMetadataExtractors (which are
     // intentionally set to "Extended" although they may download images from the internet).
     // Creating thumbs with this MetadataExtractor takes much longer than downloading them from the internet.
     // This MetadataExtractor only creates thumbs if the ThumbnailLargeAspect has not been filled before.
     // ToDo: Correct this once we have a better priority system
     _metadata = new MetadataExtractorMetadata(METADATAEXTRACTOR_ID, "Video thumbnail extractor", MetadataExtractorPriority.External, true,
                                               MEDIA_CATEGORIES, new[]
     {
         ThumbnailLargeAspect.Metadata
     });
 }
 public bool IsStubResource(IResourceAccessor mediaItemAccessor)
 {
     foreach (IMetadataExtractor extractor in LocalMetadataExtractors.Values)
     {
         try
         {
             if (extractor.IsStubResource(mediaItemAccessor))
             {
                 return(true);
             }
         }
         catch (Exception e)
         {
             MetadataExtractorMetadata mem = extractor.Metadata;
             ServiceRegistration.Get <ILogger>().Error("MediaAccessor: Error checking for stub resource on metadata extractor '{0}' (Id: '{1}')",
                                                       e, mem.Name, mem.MetadataExtractorId);
             throw;
         }
     }
     return(false);
 }
Exemple #27
0
        public MovieMetadataExtractor()
        {
            _metadata = new MetadataExtractorMetadata(METADATAEXTRACTOR_ID, "Movies metadata extractor", MetadataExtractorPriority.External, true,
                                                      MEDIA_CATEGORIES, new MediaItemAspectMetadata[]
            {
                MediaAspect.Metadata,
                MovieAspect.Metadata
            });

            _messageQueue = new AsynchronousMessageQueue(this, new string[]
            {
                ImporterWorkerMessaging.CHANNEL,
            });
            _messageQueue.MessageReceived += OnMessageReceived;
            _messageQueue.Start();

            _settingWatcher = new SettingsChangeWatcher <MovieMetadataExtractorSettings>();
            _settingWatcher.SettingsChanged += SettingsChanged;

            LoadSettings();
        }
 /// <summary>
 /// Instantiates a new <see cref="NfoSeriesMetadataExtractor"/> object
 /// </summary>
 public NfoSeriesMetadataExtractor()
 {
     // The metadataExtractorPriority is intentionally set wrong to "Extended" although, depending on the
     // content of the nfo-file, it may download thumbs from the internet (and should therefore be
     // "External"). This is a temporary workaround for performance purposes. It ensures that this
     // MetadataExtractor is applied before the VideoThumbnailer (which is intentionally set to "External"
     // although it only uses local files). Creating thumbs with the VideoThumbnailer takes much longer
     // than downloading them from the internet.
     // ToDo: Correct this once we have a better priority system
     _metadata = new MetadataExtractorMetadata(
         metadataExtractorId: METADATAEXTRACTOR_ID,
         name: "Nfo series metadata extractor",
         metadataExtractorPriority: MetadataExtractorPriority.Extended,
         processesNonFiles: true,
         shareCategories: MEDIA_CATEGORIES,
         extractedAspectTypes: new MediaItemAspectMetadata[]
     {
         MediaAspect.Metadata,
         EpisodeAspect.Metadata,
         ThumbnailLargeAspect.Metadata
     });
 }
        public async Task <IDictionary <Guid, IList <MediaItemAspect> > > ExtractMetadataAsync(IResourceAccessor mediaItemAccessor,
                                                                                               IEnumerable <IMetadataExtractor> metadataExtractors, IDictionary <Guid, IList <MediaItemAspect> > existingAspects, bool forceQuickMode)
        {
            IDictionary <Guid, IList <MediaItemAspect> > result = existingAspects;

            if (result == null)
            {
                result = new Dictionary <Guid, IList <MediaItemAspect> >();
            }

            IFileSystemResourceAccessor fsra = mediaItemAccessor as IFileSystemResourceAccessor;

            if (fsra != null)
            {
                ServiceRegistration.Get <ILogger>().Debug("MediaAccessor: Importing file '{0}'", fsra.ResourcePathName);
            }

            bool success = false;

            // Execute all metadata extractors in order of their priority
            foreach (IMetadataExtractor extractor in metadataExtractors.OrderBy(m => m.Metadata.Priority))
            {
                try
                {
                    if (await extractor.TryExtractMetadataAsync(mediaItemAccessor, result, forceQuickMode).ConfigureAwait(false))
                    {
                        success = true;
                    }
                }
                catch (Exception e)
                {
                    MetadataExtractorMetadata mem = extractor.Metadata;
                    ServiceRegistration.Get <ILogger>().Error("MediaAccessor: Error extracting metadata from metadata extractor '{0}' (Id: '{1}')",
                                                              e, mem.Name, mem.MetadataExtractorId);
                    //throw;
                }
            }
            return(success ? result : null);
        }
        public AudioMetadataExtractor()
        {
            _metadata = new MetadataExtractorMetadata(METADATAEXTRACTOR_ID, "Audio metadata extractor", MetadataExtractorPriority.Core, false,
                                                      MEDIA_CATEGORIES, new[]
            {
                MediaAspect.Metadata,
                AudioAspect.Metadata,
                ThumbnailLargeAspect.Metadata
            });

            _messageQueue = new AsynchronousMessageQueue(this, new string[]
            {
                ImporterWorkerMessaging.CHANNEL,
            });
            _messageQueue.MessageReceived += OnMessageReceived;
            _messageQueue.Start();

            _settingWatcher = new SettingsChangeWatcher <AudioMetadataExtractorSettings>();
            _settingWatcher.SettingsChanged += SettingsChanged;

            LoadSettings();
        }
 public GoodMergeMetadataExtractor()
 {
     _metadata = new MetadataExtractorMetadata(METADATAEXTRACTOR_ID, "GoodMerge metadata extractor", MetadataExtractorPriority.Extended, true,
                                               MEDIA_CATEGORIES, new[] { GoodMergeAspect.Metadata });
 }