diff --git a/MediaBrowser.LocalMetadata/Images/EpisodeLocalImageProvider.cs b/MediaBrowser.LocalMetadata/Images/EpisodeLocalImageProvider.cs index fbb6b20f11..033c38420d 100644 --- a/MediaBrowser.LocalMetadata/Images/EpisodeLocalImageProvider.cs +++ b/MediaBrowser.LocalMetadata/Images/EpisodeLocalImageProvider.cs @@ -45,22 +45,7 @@ namespace MediaBrowser.LocalMetadata.Images var nameWithoutExtension = _fileSystem.GetFileNameWithoutExtension(item.Path); - var files = GetFilesFromParentFolder(nameWithoutExtension, parentPathFiles); - - if (files.Count > 0) - { - return files; - } - - var metadataPath = Path.Combine(parentPath, "metadata"); - - if (parentPathFiles.Any(i => string.Equals(i.FullName, metadataPath, StringComparison.OrdinalIgnoreCase))) - { - var filesInMetadataFolder = _fileSystem.GetFiles(metadataPath, BaseItem.SupportedImageExtensions, false, false); - return GetFilesFromParentFolder(nameWithoutExtension, filesInMetadataFolder); - } - - return new List(); + return GetFilesFromParentFolder(nameWithoutExtension, parentPathFiles); } private List GetFilesFromParentFolder(string filenameWithoutExtension, IEnumerable parentPathFiles) diff --git a/MediaBrowser.LocalMetadata/MediaBrowser.LocalMetadata.csproj b/MediaBrowser.LocalMetadata/MediaBrowser.LocalMetadata.csproj index f7b7fa5f26..9a7371a66f 100644 --- a/MediaBrowser.LocalMetadata/MediaBrowser.LocalMetadata.csproj +++ b/MediaBrowser.LocalMetadata/MediaBrowser.LocalMetadata.csproj @@ -44,24 +44,15 @@ - - - - - - - - - diff --git a/MediaBrowser.LocalMetadata/Parsers/EpisodeXmlParser.cs b/MediaBrowser.LocalMetadata/Parsers/EpisodeXmlParser.cs deleted file mode 100644 index 6aba137eb0..0000000000 --- a/MediaBrowser.LocalMetadata/Parsers/EpisodeXmlParser.cs +++ /dev/null @@ -1,271 +0,0 @@ -using MediaBrowser.Controller.Entities.TV; -using MediaBrowser.Controller.Providers; -using MediaBrowser.Model.Entities; -using MediaBrowser.Model.Logging; -using System; -using System.Collections.Generic; -using System.Globalization; -using System.IO; -using System.Threading; -using System.Xml; - -using MediaBrowser.Controller.IO; -using MediaBrowser.Model.IO; -using MediaBrowser.Model.Xml; - -namespace MediaBrowser.LocalMetadata.Parsers -{ - /// - /// Class EpisodeXmlParser - /// - public class EpisodeXmlParser : BaseItemXmlParser - { - private List _imagesFound; - private readonly IFileSystem _fileSystem; - - public EpisodeXmlParser(ILogger logger, IFileSystem fileSystem, IProviderManager providerManager, IXmlReaderSettingsFactory xmlSettings) - : base(logger, providerManager, xmlSettings, fileSystem) - { - _fileSystem = fileSystem; - } - - private string _xmlPath; - - public void Fetch(MetadataResult item, - List images, - string metadataFile, - CancellationToken cancellationToken) - { - _imagesFound = images; - _xmlPath = metadataFile; - - Fetch(item, metadataFile, cancellationToken); - } - - private static readonly CultureInfo UsCulture = new CultureInfo("en-US"); - - /// - /// Fetches the data from XML node. - /// - /// The reader. - /// The result. - protected override void FetchDataFromXmlNode(XmlReader reader, MetadataResult result) - { - var item = result.Item; - - switch (reader.Name) - { - case "Episode": - - //MB generated metadata is within an "Episode" node - using (var subTree = reader.ReadSubtree()) - { - subTree.MoveToContent(); - - // Loop through each element - while (subTree.Read()) - { - if (subTree.NodeType == XmlNodeType.Element) - { - FetchDataFromXmlNode(subTree, result); - } - } - - } - break; - - case "filename": - { - var filename = reader.ReadElementContentAsString(); - - if (!string.IsNullOrWhiteSpace(filename)) - { - // Strip off everything but the filename. Some metadata tools like MetaBrowser v1.0 will have an 'episodes' prefix - // even though it's actually using the metadata folder. - filename = Path.GetFileName(filename); - - var parentFolder = _fileSystem.GetDirectoryName(_xmlPath); - filename = Path.Combine(parentFolder, filename); - var file = _fileSystem.GetFileInfo(filename); - - if (file.Exists) - { - _imagesFound.Add(new LocalImageInfo - { - Type = ImageType.Primary, - FileInfo = file - }); - } - } - break; - } - case "SeasonNumber": - { - var number = reader.ReadElementContentAsString(); - - if (!string.IsNullOrWhiteSpace(number)) - { - int num; - - if (int.TryParse(number, out num)) - { - item.ParentIndexNumber = num; - } - } - break; - } - - case "EpisodeNumber": - { - var number = reader.ReadElementContentAsString(); - - if (!string.IsNullOrWhiteSpace(number)) - { - int num; - - if (int.TryParse(number, out num)) - { - item.IndexNumber = num; - } - } - break; - } - - case "EpisodeNumberEnd": - { - var number = reader.ReadElementContentAsString(); - - if (!string.IsNullOrWhiteSpace(number)) - { - int num; - - if (int.TryParse(number, out num)) - { - item.IndexNumberEnd = num; - } - } - break; - } - - case "absolute_number": - { - var val = reader.ReadElementContentAsString(); - - if (!string.IsNullOrWhiteSpace(val)) - { - int rval; - - // int.TryParse is local aware, so it can be probamatic, force us culture - if (int.TryParse(val, NumberStyles.Integer, UsCulture, out rval)) - { - item.AbsoluteEpisodeNumber = rval; - } - } - - break; - } - case "DVD_episodenumber": - { - var number = reader.ReadElementContentAsString(); - - if (!string.IsNullOrWhiteSpace(number)) - { - float num; - - if (float.TryParse(number, NumberStyles.Any, UsCulture, out num)) - { - item.DvdEpisodeNumber = num; - } - } - break; - } - - case "DVD_season": - { - var number = reader.ReadElementContentAsString(); - - if (!string.IsNullOrWhiteSpace(number)) - { - float num; - - if (float.TryParse(number, NumberStyles.Any, UsCulture, out num)) - { - item.DvdSeasonNumber = Convert.ToInt32(num); - } - } - break; - } - - case "airsbefore_episode": - { - var val = reader.ReadElementContentAsString(); - - if (!string.IsNullOrWhiteSpace(val)) - { - int rval; - - // int.TryParse is local aware, so it can be probamatic, force us culture - if (int.TryParse(val, NumberStyles.Integer, UsCulture, out rval)) - { - item.AirsBeforeEpisodeNumber = rval; - } - } - - break; - } - - case "airsafter_season": - { - var val = reader.ReadElementContentAsString(); - - if (!string.IsNullOrWhiteSpace(val)) - { - int rval; - - // int.TryParse is local aware, so it can be probamatic, force us culture - if (int.TryParse(val, NumberStyles.Integer, UsCulture, out rval)) - { - item.AirsAfterSeasonNumber = rval; - } - } - - break; - } - - case "airsbefore_season": - { - var val = reader.ReadElementContentAsString(); - - if (!string.IsNullOrWhiteSpace(val)) - { - int rval; - - // int.TryParse is local aware, so it can be probamatic, force us culture - if (int.TryParse(val, NumberStyles.Integer, UsCulture, out rval)) - { - item.AirsBeforeSeasonNumber = rval; - } - } - - break; - } - - case "EpisodeName": - { - var name = reader.ReadElementContentAsString(); - - if (!string.IsNullOrWhiteSpace(name)) - { - item.Name = name; - } - break; - } - - - default: - base.FetchDataFromXmlNode(reader, result); - break; - } - } - } -} diff --git a/MediaBrowser.LocalMetadata/Parsers/MovieXmlParser.cs b/MediaBrowser.LocalMetadata/Parsers/MovieXmlParser.cs deleted file mode 100644 index 08c895c43f..0000000000 --- a/MediaBrowser.LocalMetadata/Parsers/MovieXmlParser.cs +++ /dev/null @@ -1,65 +0,0 @@ -using MediaBrowser.Controller.Entities; -using MediaBrowser.Controller.Entities.Movies; -using MediaBrowser.Controller.Providers; -using MediaBrowser.Model.Logging; -using System.Xml; -using MediaBrowser.Model.IO; -using MediaBrowser.Model.Xml; - -namespace MediaBrowser.LocalMetadata.Parsers -{ - /// - /// Class EpisodeXmlParser - /// - public class BaseVideoXmlParser : BaseItemXmlParser - where T : Video - { - /// - /// Fetches the data from XML node. - /// - /// The reader. - /// The result. - protected override void FetchDataFromXmlNode(XmlReader reader, MetadataResult result) - { - var item = result.Item; - - switch (reader.Name) - { - case "TmdbCollectionName": - { - var val = reader.ReadElementContentAsString(); - var movie = item as Movie; - - if (!string.IsNullOrWhiteSpace(val) && movie != null) - { - movie.CollectionName = val; - } - - break; - } - - default: - base.FetchDataFromXmlNode(reader, result); - break; - } - } - - public BaseVideoXmlParser(ILogger logger, IProviderManager providerManager, IXmlReaderSettingsFactory xmlReaderSettingsFactory, IFileSystem fileSystem) : base(logger, providerManager, xmlReaderSettingsFactory, fileSystem) - { - } - } - - public class MovieXmlParser : BaseVideoXmlParser - { - public MovieXmlParser(ILogger logger, IProviderManager providerManager, IXmlReaderSettingsFactory xmlReaderSettingsFactory, IFileSystem fileSystem) : base(logger, providerManager, xmlReaderSettingsFactory, fileSystem) - { - } - } - - public class VideoXmlParser : BaseVideoXmlParser