2014-06-30 03:04:50 +00:00
|
|
|
|
using MediaBrowser.Common.IO;
|
|
|
|
|
using MediaBrowser.Controller.Configuration;
|
|
|
|
|
using MediaBrowser.Controller.Entities;
|
|
|
|
|
using MediaBrowser.Controller.Entities.Movies;
|
|
|
|
|
using MediaBrowser.Controller.Entities.TV;
|
|
|
|
|
using MediaBrowser.Controller.Library;
|
|
|
|
|
using MediaBrowser.Model.Entities;
|
2014-07-12 02:31:08 +00:00
|
|
|
|
using MediaBrowser.Model.Logging;
|
2014-06-30 03:04:50 +00:00
|
|
|
|
using System.Collections.Generic;
|
2014-07-09 00:46:11 +00:00
|
|
|
|
using System.Globalization;
|
2014-06-30 03:04:50 +00:00
|
|
|
|
using System.IO;
|
2014-07-09 00:46:11 +00:00
|
|
|
|
using System.Xml;
|
2014-06-30 03:04:50 +00:00
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.XbmcMetadata.Savers
|
|
|
|
|
{
|
2014-07-09 00:46:11 +00:00
|
|
|
|
public class MovieNfoSaver : BaseNfoSaver
|
2014-06-30 03:04:50 +00:00
|
|
|
|
{
|
2014-07-12 02:31:08 +00:00
|
|
|
|
public MovieNfoSaver(IFileSystem fileSystem, IServerConfigurationManager configurationManager, ILibraryManager libraryManager, IUserManager userManager, IUserDataManager userDataManager, ILogger logger) : base(fileSystem, configurationManager, libraryManager, userManager, userDataManager, logger)
|
2014-06-30 03:04:50 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-09 00:46:11 +00:00
|
|
|
|
public override string GetSavePath(IHasMetadata item)
|
2014-06-30 03:04:50 +00:00
|
|
|
|
{
|
2014-07-26 17:30:15 +00:00
|
|
|
|
return GetMovieSavePath(item, FileSystem);
|
2014-06-30 03:04:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-07-26 17:30:15 +00:00
|
|
|
|
public static string GetMovieSavePath(IHasMetadata item, IFileSystem fileSystem)
|
2014-06-30 03:04:50 +00:00
|
|
|
|
{
|
|
|
|
|
var video = (Video)item;
|
|
|
|
|
|
|
|
|
|
if (video.VideoType == VideoType.Dvd || video.VideoType == VideoType.BluRay || video.VideoType == VideoType.HdDvd)
|
|
|
|
|
{
|
|
|
|
|
var path = item.ContainingFolderPath;
|
|
|
|
|
|
2014-07-26 17:30:15 +00:00
|
|
|
|
return Path.Combine(path, fileSystem.GetFileNameWithoutExtension(path) + ".nfo");
|
2014-06-30 03:04:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Path.ChangeExtension(item.Path, ".nfo");
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-09 00:46:11 +00:00
|
|
|
|
protected override string GetRootElementName(IHasMetadata item)
|
2014-06-30 03:04:50 +00:00
|
|
|
|
{
|
2014-07-09 00:46:11 +00:00
|
|
|
|
return item is MusicVideo ? "musicvideo" : "movie";
|
|
|
|
|
}
|
2014-06-30 03:04:50 +00:00
|
|
|
|
|
2014-07-09 00:46:11 +00:00
|
|
|
|
public override bool IsEnabledFor(IHasMetadata item, ItemUpdateType updateType)
|
|
|
|
|
{
|
|
|
|
|
if (!item.SupportsLocalMetadata)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2014-06-30 03:04:50 +00:00
|
|
|
|
|
2014-07-09 00:46:11 +00:00
|
|
|
|
var video = item as Video;
|
2014-06-30 03:04:50 +00:00
|
|
|
|
|
2014-07-09 00:46:11 +00:00
|
|
|
|
// Check parent for null to avoid running this against things like video backdrops
|
|
|
|
|
if (video != null && !(item is Episode) && !video.IsOwnedItem)
|
|
|
|
|
{
|
2014-09-13 14:10:30 +00:00
|
|
|
|
return updateType >= ItemUpdateType.ImageUpdate;
|
2014-07-09 00:46:11 +00:00
|
|
|
|
}
|
2014-06-30 03:04:50 +00:00
|
|
|
|
|
2014-07-09 00:46:11 +00:00
|
|
|
|
return false;
|
|
|
|
|
}
|
2014-06-30 03:04:50 +00:00
|
|
|
|
|
2014-07-09 00:46:11 +00:00
|
|
|
|
protected override void WriteCustomElements(IHasMetadata item, XmlWriter writer)
|
|
|
|
|
{
|
2014-06-30 03:04:50 +00:00
|
|
|
|
var imdb = item.GetProviderId(MetadataProviders.Imdb);
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(imdb))
|
|
|
|
|
{
|
2014-07-09 00:46:11 +00:00
|
|
|
|
writer.WriteElementString("id", imdb);
|
2014-06-30 03:04:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var musicVideo = item as MusicVideo;
|
|
|
|
|
|
|
|
|
|
if (musicVideo != null)
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(musicVideo.Artist))
|
|
|
|
|
{
|
2014-07-09 00:46:11 +00:00
|
|
|
|
writer.WriteElementString("artist", musicVideo.Artist);
|
2014-06-30 03:04:50 +00:00
|
|
|
|
}
|
|
|
|
|
if (!string.IsNullOrEmpty(musicVideo.Album))
|
|
|
|
|
{
|
2014-07-09 00:46:11 +00:00
|
|
|
|
writer.WriteElementString("album", musicVideo.Album);
|
2014-06-30 03:04:50 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var movie = item as Movie;
|
|
|
|
|
|
|
|
|
|
if (movie != null)
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(movie.TmdbCollectionName))
|
|
|
|
|
{
|
2014-07-09 00:46:11 +00:00
|
|
|
|
writer.WriteElementString("set", movie.TmdbCollectionName);
|
2014-06-30 03:04:50 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2014-07-09 00:46:11 +00:00
|
|
|
|
}
|
2014-06-30 03:04:50 +00:00
|
|
|
|
|
2014-07-09 00:46:11 +00:00
|
|
|
|
private static readonly CultureInfo UsCulture = new CultureInfo("en-US");
|
2014-06-30 03:04:50 +00:00
|
|
|
|
|
2014-07-09 00:46:11 +00:00
|
|
|
|
protected override List<string> GetTagsUsed()
|
|
|
|
|
{
|
|
|
|
|
var list = new List<string>
|
|
|
|
|
{
|
2014-06-30 03:04:50 +00:00
|
|
|
|
"album",
|
|
|
|
|
"artist",
|
|
|
|
|
"set",
|
|
|
|
|
"id"
|
2014-07-09 00:46:11 +00:00
|
|
|
|
};
|
2014-06-30 03:04:50 +00:00
|
|
|
|
|
2014-07-09 00:46:11 +00:00
|
|
|
|
return list;
|
2014-06-30 03:04:50 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|