2014-02-04 20:19:29 +00:00
|
|
|
|
using MediaBrowser.Common.IO;
|
|
|
|
|
using MediaBrowser.Controller.Entities.Movies;
|
|
|
|
|
using MediaBrowser.Controller.Providers;
|
|
|
|
|
using MediaBrowser.Model.Logging;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.Providers.Movies
|
|
|
|
|
{
|
2014-02-06 04:39:16 +00:00
|
|
|
|
public class MovieXmlProvider : BaseXmlProvider<Movie>
|
2014-02-04 20:19:29 +00:00
|
|
|
|
{
|
|
|
|
|
private readonly ILogger _logger;
|
|
|
|
|
|
|
|
|
|
public MovieXmlProvider(IFileSystem fileSystem, ILogger logger)
|
|
|
|
|
: base(fileSystem)
|
|
|
|
|
{
|
|
|
|
|
_logger = logger;
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-09 04:52:52 +00:00
|
|
|
|
protected override void Fetch(LocalMetadataResult<Movie> result, string path, CancellationToken cancellationToken)
|
2014-02-04 20:19:29 +00:00
|
|
|
|
{
|
2014-02-09 04:52:52 +00:00
|
|
|
|
new MovieXmlParser(_logger).Fetch(result.Item, path, cancellationToken);
|
2014-02-04 20:19:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-03-12 19:56:12 +00:00
|
|
|
|
protected override FileSystemInfo GetXmlFile(ItemInfo info, IDirectoryService directoryService)
|
2014-02-04 20:19:29 +00:00
|
|
|
|
{
|
2014-02-06 04:39:16 +00:00
|
|
|
|
return GetXmlFileInfo(info, FileSystem);
|
2014-02-04 20:19:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-02-06 04:39:16 +00:00
|
|
|
|
public static FileInfo GetXmlFileInfo(ItemInfo info, IFileSystem fileSystem)
|
2014-02-04 20:19:29 +00:00
|
|
|
|
{
|
2014-02-06 04:39:16 +00:00
|
|
|
|
var fileInfo = fileSystem.GetFileSystemInfo(info.Path);
|
2014-02-04 20:19:29 +00:00
|
|
|
|
|
|
|
|
|
var directoryInfo = fileInfo as DirectoryInfo;
|
|
|
|
|
|
|
|
|
|
if (directoryInfo == null)
|
|
|
|
|
{
|
2014-02-06 04:39:16 +00:00
|
|
|
|
directoryInfo = new DirectoryInfo(Path.GetDirectoryName(info.Path));
|
2014-02-04 20:19:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var directoryPath = directoryInfo.FullName;
|
|
|
|
|
|
2014-02-06 04:39:16 +00:00
|
|
|
|
var specificFile = Path.Combine(directoryPath, Path.GetFileNameWithoutExtension(info.Path) + ".xml");
|
2014-02-04 20:19:29 +00:00
|
|
|
|
|
|
|
|
|
var file = new FileInfo(specificFile);
|
|
|
|
|
|
2014-02-06 04:39:16 +00:00
|
|
|
|
return info.IsInMixedFolder || file.Exists ? file : new FileInfo(Path.Combine(directoryPath, "movie.xml"));
|
2014-02-04 20:19:29 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|