move xml providers to plugin
This commit is contained in:
parent
5b6356e779
commit
a39d7e888b
|
@ -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<LocalImageInfo>();
|
||||
return GetFilesFromParentFolder(nameWithoutExtension, parentPathFiles);
|
||||
}
|
||||
|
||||
private List<LocalImageInfo> GetFilesFromParentFolder(string filenameWithoutExtension, IEnumerable<FileSystemMetadata> parentPathFiles)
|
||||
|
|
|
@ -44,24 +44,15 @@
|
|||
<Compile Include="Images\LocalImageProvider.cs" />
|
||||
<Compile Include="Parsers\BaseItemXmlParser.cs" />
|
||||
<Compile Include="Parsers\BoxSetXmlParser.cs" />
|
||||
<Compile Include="Parsers\EpisodeXmlParser.cs" />
|
||||
<Compile Include="Parsers\GameSystemXmlParser.cs" />
|
||||
<Compile Include="Parsers\GameXmlParser.cs" />
|
||||
<Compile Include="Parsers\MovieXmlParser.cs" />
|
||||
<Compile Include="Parsers\MusicVideoXmlParser.cs" />
|
||||
<Compile Include="Parsers\PlaylistXmlParser.cs" />
|
||||
<Compile Include="Parsers\SeriesXmlParser.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Providers\BoxSetXmlProvider.cs" />
|
||||
<Compile Include="Providers\EpisodeXmlProvider.cs" />
|
||||
<Compile Include="Providers\FolderXmlProvider.cs" />
|
||||
<Compile Include="Providers\GameSystemXmlProvider.cs" />
|
||||
<Compile Include="Providers\GameXmlProvider.cs" />
|
||||
<Compile Include="Providers\MovieXmlProvider.cs" />
|
||||
<Compile Include="Providers\MusicVideoXmlProvider.cs" />
|
||||
<Compile Include="Providers\PlaylistXmlProvider.cs" />
|
||||
<Compile Include="Providers\SeriesXmlProvider.cs" />
|
||||
<Compile Include="Providers\VideoXmlProvider.cs" />
|
||||
<Compile Include="Savers\BaseXmlSaver.cs" />
|
||||
<Compile Include="Savers\BoxSetXmlSaver.cs" />
|
||||
<Compile Include="Savers\FolderXmlSaver.cs" />
|
||||
|
|
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Class EpisodeXmlParser
|
||||
/// </summary>
|
||||
public class EpisodeXmlParser : BaseItemXmlParser<Episode>
|
||||
{
|
||||
private List<LocalImageInfo> _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<Episode> item,
|
||||
List<LocalImageInfo> images,
|
||||
string metadataFile,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
_imagesFound = images;
|
||||
_xmlPath = metadataFile;
|
||||
|
||||
Fetch(item, metadataFile, cancellationToken);
|
||||
}
|
||||
|
||||
private static readonly CultureInfo UsCulture = new CultureInfo("en-US");
|
||||
|
||||
/// <summary>
|
||||
/// Fetches the data from XML node.
|
||||
/// </summary>
|
||||
/// <param name="reader">The reader.</param>
|
||||
/// <param name="result">The result.</param>
|
||||
protected override void FetchDataFromXmlNode(XmlReader reader, MetadataResult<Episode> 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Class EpisodeXmlParser
|
||||
/// </summary>
|
||||
public class BaseVideoXmlParser<T> : BaseItemXmlParser<T>
|
||||
where T : Video
|
||||
{
|
||||
/// <summary>
|
||||
/// Fetches the data from XML node.
|
||||
/// </summary>
|
||||
/// <param name="reader">The reader.</param>
|
||||
/// <param name="result">The result.</param>
|
||||
protected override void FetchDataFromXmlNode(XmlReader reader, MetadataResult<T> 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<Movie>
|
||||
{
|
||||
public MovieXmlParser(ILogger logger, IProviderManager providerManager, IXmlReaderSettingsFactory xmlReaderSettingsFactory, IFileSystem fileSystem) : base(logger, providerManager, xmlReaderSettingsFactory, fileSystem)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public class VideoXmlParser : BaseVideoXmlParser<Video>
|
||||
{
|
||||
public VideoXmlParser(ILogger logger, IProviderManager providerManager, IXmlReaderSettingsFactory xmlReaderSettingsFactory, IFileSystem fileSystem) : base(logger, providerManager, xmlReaderSettingsFactory, fileSystem)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,51 +0,0 @@
|
|||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using System;
|
||||
using System.Xml;
|
||||
using MediaBrowser.Model.IO;
|
||||
using MediaBrowser.Model.Xml;
|
||||
|
||||
namespace MediaBrowser.LocalMetadata.Parsers
|
||||
{
|
||||
public class MusicVideoXmlParser : BaseVideoXmlParser<MusicVideo>
|
||||
{
|
||||
/// <summary>
|
||||
/// Fetches the data from XML node.
|
||||
/// </summary>
|
||||
/// <param name="reader">The reader.</param>
|
||||
/// <param name="result">The result.</param>
|
||||
protected override void FetchDataFromXmlNode(XmlReader reader, MetadataResult<MusicVideo> result)
|
||||
{
|
||||
var item = result.Item;
|
||||
|
||||
switch (reader.Name)
|
||||
{
|
||||
case "Artist":
|
||||
{
|
||||
var val = reader.ReadElementContentAsString();
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(val))
|
||||
{
|
||||
var artists = val.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
item.Artists.AddRange(artists);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case "Album":
|
||||
item.Album = reader.ReadElementContentAsString();
|
||||
break;
|
||||
|
||||
default:
|
||||
base.FetchDataFromXmlNode(reader, result);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public MusicVideoXmlParser(ILogger logger, IProviderManager providerManager, IXmlReaderSettingsFactory xmlReaderSettingsFactory, IFileSystem fileSystem) : base(logger, providerManager, xmlReaderSettingsFactory, fileSystem)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,102 +0,0 @@
|
|||
using System;
|
||||
using System.Xml;
|
||||
using MediaBrowser.Controller.Entities.TV;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.IO;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using MediaBrowser.Model.Xml;
|
||||
|
||||
namespace MediaBrowser.LocalMetadata.Parsers
|
||||
{
|
||||
/// <summary>
|
||||
/// Class SeriesXmlParser
|
||||
/// </summary>
|
||||
public class SeriesXmlParser : BaseItemXmlParser<Series>
|
||||
{
|
||||
/// <summary>
|
||||
/// Fetches the data from XML node.
|
||||
/// </summary>
|
||||
/// <param name="reader">The reader.</param>
|
||||
/// <param name="result">The result.</param>
|
||||
protected override void FetchDataFromXmlNode(XmlReader reader, MetadataResult<Series> result)
|
||||
{
|
||||
var item = result.Item;
|
||||
|
||||
switch (reader.Name)
|
||||
{
|
||||
case "Series":
|
||||
//MB generated metadata is within a "Series" 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 "id":
|
||||
string id = reader.ReadElementContentAsString();
|
||||
if (!string.IsNullOrWhiteSpace(id))
|
||||
{
|
||||
item.SetProviderId(MetadataProviders.Tvdb, id);
|
||||
}
|
||||
break;
|
||||
|
||||
case "Airs_DayOfWeek":
|
||||
{
|
||||
item.AirDays = TVUtils.GetAirDays(reader.ReadElementContentAsString());
|
||||
break;
|
||||
}
|
||||
|
||||
case "Airs_Time":
|
||||
{
|
||||
var val = reader.ReadElementContentAsString();
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(val))
|
||||
{
|
||||
item.AirTime = val;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case "Status":
|
||||
{
|
||||
var status = reader.ReadElementContentAsString();
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(status))
|
||||
{
|
||||
SeriesStatus seriesStatus;
|
||||
if (Enum.TryParse(status, true, out seriesStatus))
|
||||
{
|
||||
item.Status = seriesStatus;
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.Info("Unrecognized series status: " + status);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
base.FetchDataFromXmlNode(reader, result);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public SeriesXmlParser(ILogger logger, IProviderManager providerManager, IXmlReaderSettingsFactory xmlReaderSettingsFactory, IFileSystem fileSystem) : base(logger, providerManager, xmlReaderSettingsFactory, fileSystem)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
using MediaBrowser.Controller.Entities.TV;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.LocalMetadata.Parsers;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
|
||||
using MediaBrowser.Controller.IO;
|
||||
using MediaBrowser.Model.IO;
|
||||
using MediaBrowser.Model.Xml;
|
||||
|
||||
namespace MediaBrowser.LocalMetadata.Providers
|
||||
{
|
||||
public class EpisodeXmlProvider : BaseXmlProvider<Episode>
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IProviderManager _providerManager;
|
||||
private readonly IXmlReaderSettingsFactory _xmlSettings;
|
||||
|
||||
public EpisodeXmlProvider(IFileSystem fileSystem, ILogger logger, IProviderManager providerManager, IXmlReaderSettingsFactory xmlSettings)
|
||||
: base(fileSystem)
|
||||
{
|
||||
_logger = logger;
|
||||
_providerManager = providerManager;
|
||||
_xmlSettings = xmlSettings;
|
||||
}
|
||||
|
||||
protected override void Fetch(MetadataResult<Episode> result, string path, CancellationToken cancellationToken)
|
||||
{
|
||||
var images = new List<LocalImageInfo>();
|
||||
var chapters = new List<ChapterInfo>();
|
||||
|
||||
new EpisodeXmlParser(_logger, FileSystem, _providerManager, _xmlSettings).Fetch(result, images, path, cancellationToken);
|
||||
|
||||
result.Images = images;
|
||||
}
|
||||
|
||||
protected override FileSystemMetadata GetXmlFile(ItemInfo info, IDirectoryService directoryService)
|
||||
{
|
||||
var metadataPath = FileSystem.GetDirectoryName(info.Path);
|
||||
metadataPath = Path.Combine(metadataPath, "metadata");
|
||||
|
||||
var metadataFile = Path.Combine(metadataPath, Path.ChangeExtension(Path.GetFileName(info.Path), ".xml"));
|
||||
|
||||
return directoryService.GetFile(metadataFile);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,62 +0,0 @@
|
|||
using MediaBrowser.Controller.Entities.Movies;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.LocalMetadata.Parsers;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
|
||||
using MediaBrowser.Controller.IO;
|
||||
using MediaBrowser.Model.IO;
|
||||
using MediaBrowser.Model.Xml;
|
||||
|
||||
namespace MediaBrowser.LocalMetadata.Providers
|
||||
{
|
||||
public class MovieXmlProvider : BaseXmlProvider<Movie>
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IProviderManager _providerManager;
|
||||
protected IXmlReaderSettingsFactory XmlReaderSettingsFactory { get; private set; }
|
||||
|
||||
public MovieXmlProvider(IFileSystem fileSystem, ILogger logger, IProviderManager providerManager, IXmlReaderSettingsFactory xmlReaderSettingsFactory)
|
||||
: base(fileSystem)
|
||||
{
|
||||
_logger = logger;
|
||||
_providerManager = providerManager;
|
||||
XmlReaderSettingsFactory = xmlReaderSettingsFactory;
|
||||
}
|
||||
|
||||
protected override void Fetch(MetadataResult<Movie> result, string path, CancellationToken cancellationToken)
|
||||
{
|
||||
new MovieXmlParser(_logger, _providerManager, XmlReaderSettingsFactory, FileSystem).Fetch(result, path, cancellationToken);
|
||||
}
|
||||
|
||||
protected override FileSystemMetadata GetXmlFile(ItemInfo info, IDirectoryService directoryService)
|
||||
{
|
||||
return GetXmlFileInfo(info, FileSystem);
|
||||
}
|
||||
|
||||
public static FileSystemMetadata GetXmlFileInfo(ItemInfo info, IFileSystem fileSystem)
|
||||
{
|
||||
var fileInfo = fileSystem.GetFileSystemInfo(info.Path);
|
||||
|
||||
var directoryInfo = fileInfo.IsDirectory ? fileInfo : fileSystem.GetDirectoryInfo(fileSystem.GetDirectoryName(info.Path));
|
||||
|
||||
var directoryPath = directoryInfo.FullName;
|
||||
|
||||
var specificFile = Path.Combine(directoryPath, fileSystem.GetFileNameWithoutExtension(info.Path) + ".xml");
|
||||
|
||||
var file = fileSystem.GetFileInfo(specificFile);
|
||||
|
||||
// In a mixed folder, only {moviename}.xml is supported
|
||||
if (info.IsInMixedFolder)
|
||||
{
|
||||
return file;
|
||||
}
|
||||
|
||||
// If in it's own folder, prefer movie.xml, but allow the specific file as well
|
||||
var movieFile = fileSystem.GetFileInfo(Path.Combine(directoryPath, "movie.xml"));
|
||||
|
||||
return movieFile.Exists ? movieFile : file;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
using System.Threading;
|
||||
|
||||
using MediaBrowser.Model.IO;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.IO;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.LocalMetadata.Parsers;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using MediaBrowser.Model.Xml;
|
||||
|
||||
namespace MediaBrowser.LocalMetadata.Providers
|
||||
{
|
||||
class MusicVideoXmlProvider : BaseXmlProvider<MusicVideo>
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IProviderManager _providerManager;
|
||||
protected IXmlReaderSettingsFactory XmlReaderSettingsFactory { get; private set; }
|
||||
|
||||
public MusicVideoXmlProvider(IFileSystem fileSystem, ILogger logger, IProviderManager providerManager, IXmlReaderSettingsFactory xmlReaderSettingsFactory)
|
||||
: base(fileSystem)
|
||||
{
|
||||
_logger = logger;
|
||||
_providerManager = providerManager;
|
||||
XmlReaderSettingsFactory = xmlReaderSettingsFactory;
|
||||
}
|
||||
|
||||
protected override void Fetch(MetadataResult<MusicVideo> result, string path, CancellationToken cancellationToken)
|
||||
{
|
||||
new MusicVideoXmlParser(_logger, _providerManager, XmlReaderSettingsFactory, FileSystem).Fetch(result, path, cancellationToken);
|
||||
}
|
||||
|
||||
protected override FileSystemMetadata GetXmlFile(ItemInfo info, IDirectoryService directoryService)
|
||||
{
|
||||
return MovieXmlProvider.GetXmlFileInfo(info, FileSystem);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
using System.IO;
|
||||
using System.Threading;
|
||||
|
||||
using MediaBrowser.Model.IO;
|
||||
using MediaBrowser.Controller.Entities.TV;
|
||||
using MediaBrowser.Controller.IO;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.LocalMetadata.Parsers;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using MediaBrowser.Model.Xml;
|
||||
|
||||
namespace MediaBrowser.LocalMetadata.Providers
|
||||
{
|
||||
/// <summary>
|
||||
/// Class SeriesProviderFromXml
|
||||
/// </summary>
|
||||
public class SeriesXmlProvider : BaseXmlProvider<Series>, IHasOrder
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IProviderManager _providerManager;
|
||||
protected IXmlReaderSettingsFactory XmlReaderSettingsFactory { get; private set; }
|
||||
|
||||
public SeriesXmlProvider(IFileSystem fileSystem, ILogger logger, IProviderManager providerManager, IXmlReaderSettingsFactory xmlReaderSettingsFactory)
|
||||
: base(fileSystem)
|
||||
{
|
||||
_logger = logger;
|
||||
_providerManager = providerManager;
|
||||
XmlReaderSettingsFactory = xmlReaderSettingsFactory;
|
||||
}
|
||||
|
||||
protected override void Fetch(MetadataResult<Series> result, string path, CancellationToken cancellationToken)
|
||||
{
|
||||
new SeriesXmlParser(_logger, _providerManager, XmlReaderSettingsFactory, FileSystem).Fetch(result, path, cancellationToken);
|
||||
}
|
||||
|
||||
protected override FileSystemMetadata GetXmlFile(ItemInfo info, IDirectoryService directoryService)
|
||||
{
|
||||
return directoryService.GetFile(Path.Combine(info.Path, "series.xml"));
|
||||
}
|
||||
|
||||
public override int Order
|
||||
{
|
||||
get
|
||||
{
|
||||
// After Xbmc
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.LocalMetadata.Parsers;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using System.Threading;
|
||||
|
||||
using MediaBrowser.Controller.IO;
|
||||
using MediaBrowser.Model.IO;
|
||||
using MediaBrowser.Model.Xml;
|
||||
|
||||
namespace MediaBrowser.LocalMetadata.Providers
|
||||
{
|
||||
class VideoXmlProvider : BaseXmlProvider<Video>
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IProviderManager _providerManager;
|
||||
protected IXmlReaderSettingsFactory XmlReaderSettingsFactory { get; private set; }
|
||||
|
||||
public VideoXmlProvider(IFileSystem fileSystem, ILogger logger, IProviderManager providerManager, IXmlReaderSettingsFactory xmlReaderSettingsFactory)
|
||||
: base(fileSystem)
|
||||
{
|
||||
_logger = logger;
|
||||
_providerManager = providerManager;
|
||||
XmlReaderSettingsFactory = xmlReaderSettingsFactory;
|
||||
}
|
||||
|
||||
protected override void Fetch(MetadataResult<Video> result, string path, CancellationToken cancellationToken)
|
||||
{
|
||||
new VideoXmlParser(_logger, _providerManager, XmlReaderSettingsFactory, FileSystem).Fetch(result, path, cancellationToken);
|
||||
}
|
||||
|
||||
protected override FileSystemMetadata GetXmlFile(ItemInfo info, IDirectoryService directoryService)
|
||||
{
|
||||
return MovieXmlProvider.GetXmlFileInfo(info, FileSystem);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user