2016-03-27 17:11:27 -04:00
|
|
|
|
using MediaBrowser.Controller.Configuration;
|
2014-07-08 20:46:11 -04:00
|
|
|
|
using MediaBrowser.Controller.Entities;
|
|
|
|
|
using MediaBrowser.Controller.Entities.TV;
|
|
|
|
|
using MediaBrowser.Controller.Library;
|
2014-07-11 22:31:08 -04:00
|
|
|
|
using MediaBrowser.Model.Logging;
|
2014-07-08 20:46:11 -04:00
|
|
|
|
using MediaBrowser.XbmcMetadata.Configuration;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Globalization;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Xml;
|
2016-10-25 15:02:04 -04:00
|
|
|
|
using MediaBrowser.Common.IO;
|
|
|
|
|
using MediaBrowser.Controller.IO;
|
|
|
|
|
using MediaBrowser.Model.IO;
|
2014-07-08 20:46:11 -04:00
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.XbmcMetadata.Savers
|
|
|
|
|
{
|
|
|
|
|
public class EpisodeNfoSaver : BaseNfoSaver
|
|
|
|
|
{
|
2014-07-11 22:31:08 -04:00
|
|
|
|
public EpisodeNfoSaver(IFileSystem fileSystem, IServerConfigurationManager configurationManager, ILibraryManager libraryManager, IUserManager userManager, IUserDataManager userDataManager, ILogger logger) : base(fileSystem, configurationManager, libraryManager, userManager, userDataManager, logger)
|
2014-07-08 20:46:11 -04:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-22 00:42:26 -04:00
|
|
|
|
protected override string GetLocalSavePath(IHasMetadata item)
|
2014-07-08 20:46:11 -04:00
|
|
|
|
{
|
|
|
|
|
return Path.ChangeExtension(item.Path, ".nfo");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override string GetRootElementName(IHasMetadata item)
|
|
|
|
|
{
|
|
|
|
|
return "episodedetails";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool IsEnabledFor(IHasMetadata item, ItemUpdateType updateType)
|
|
|
|
|
{
|
|
|
|
|
if (!item.SupportsLocalMetadata)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-04 00:55:34 -05:00
|
|
|
|
return item is Episode && updateType >= MinimumUpdateType;
|
2014-07-08 20:46:11 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void WriteCustomElements(IHasMetadata item, XmlWriter writer)
|
|
|
|
|
{
|
|
|
|
|
var episode = (Episode)item;
|
|
|
|
|
|
|
|
|
|
if (episode.IndexNumber.HasValue)
|
|
|
|
|
{
|
|
|
|
|
writer.WriteElementString("episode", episode.IndexNumber.Value.ToString(UsCulture));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (episode.IndexNumberEnd.HasValue)
|
|
|
|
|
{
|
|
|
|
|
writer.WriteElementString("episodenumberend", episode.IndexNumberEnd.Value.ToString(UsCulture));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (episode.ParentIndexNumber.HasValue)
|
|
|
|
|
{
|
|
|
|
|
writer.WriteElementString("season", episode.ParentIndexNumber.Value.ToString(UsCulture));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (episode.PremiereDate.HasValue)
|
|
|
|
|
{
|
|
|
|
|
var formatString = ConfigurationManager.GetNfoConfiguration().ReleaseDateFormat;
|
|
|
|
|
|
2016-01-27 13:08:55 -05:00
|
|
|
|
writer.WriteElementString("aired", episode.PremiereDate.Value.ToLocalTime().ToString(formatString));
|
2014-07-08 20:46:11 -04:00
|
|
|
|
}
|
|
|
|
|
|
2016-09-18 13:29:52 -04:00
|
|
|
|
if (!episode.ParentIndexNumber.HasValue || episode.ParentIndexNumber.Value == 0)
|
2014-07-08 20:46:11 -04:00
|
|
|
|
{
|
2016-09-18 13:29:52 -04:00
|
|
|
|
if (episode.AirsAfterSeasonNumber.HasValue && episode.AirsAfterSeasonNumber.Value != -1)
|
|
|
|
|
{
|
|
|
|
|
writer.WriteElementString("airsafter_season", episode.AirsAfterSeasonNumber.Value.ToString(UsCulture));
|
|
|
|
|
}
|
|
|
|
|
if (episode.AirsBeforeEpisodeNumber.HasValue && episode.AirsBeforeEpisodeNumber.Value != -1)
|
|
|
|
|
{
|
|
|
|
|
writer.WriteElementString("airsbefore_episode", episode.AirsBeforeEpisodeNumber.Value.ToString(UsCulture));
|
|
|
|
|
}
|
|
|
|
|
if (episode.AirsBeforeSeasonNumber.HasValue && episode.AirsBeforeSeasonNumber.Value != -1)
|
|
|
|
|
{
|
|
|
|
|
writer.WriteElementString("airsbefore_season", episode.AirsBeforeSeasonNumber.Value.ToString(UsCulture));
|
|
|
|
|
}
|
2014-07-08 20:46:11 -04:00
|
|
|
|
|
2016-08-28 12:46:28 -04:00
|
|
|
|
if (episode.AirsBeforeEpisodeNumber.HasValue && episode.AirsBeforeEpisodeNumber.Value != -1)
|
|
|
|
|
{
|
|
|
|
|
writer.WriteElementString("displayepisode", episode.AirsBeforeEpisodeNumber.Value.ToString(UsCulture));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var specialSeason = episode.AiredSeasonNumber;
|
|
|
|
|
if (specialSeason.HasValue && specialSeason.Value != -1)
|
|
|
|
|
{
|
|
|
|
|
writer.WriteElementString("displayseason", specialSeason.Value.ToString(UsCulture));
|
|
|
|
|
}
|
2016-06-24 16:07:35 -04:00
|
|
|
|
}
|
|
|
|
|
|
2014-07-08 20:46:11 -04:00
|
|
|
|
if (episode.DvdEpisodeNumber.HasValue)
|
|
|
|
|
{
|
|
|
|
|
writer.WriteElementString("DVD_episodenumber", episode.DvdEpisodeNumber.Value.ToString(UsCulture));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (episode.DvdSeasonNumber.HasValue)
|
|
|
|
|
{
|
|
|
|
|
writer.WriteElementString("DVD_season", episode.DvdSeasonNumber.Value.ToString(UsCulture));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (episode.AbsoluteEpisodeNumber.HasValue)
|
|
|
|
|
{
|
|
|
|
|
writer.WriteElementString("absolute_number", episode.AbsoluteEpisodeNumber.Value.ToString(UsCulture));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static readonly CultureInfo UsCulture = new CultureInfo("en-US");
|
|
|
|
|
|
|
|
|
|
protected override List<string> GetTagsUsed()
|
|
|
|
|
{
|
|
|
|
|
var list = new List<string>
|
|
|
|
|
{
|
|
|
|
|
"aired",
|
|
|
|
|
"season",
|
|
|
|
|
"episode",
|
|
|
|
|
"episodenumberend",
|
|
|
|
|
"airsafter_season",
|
|
|
|
|
"airsbefore_episode",
|
|
|
|
|
"airsbefore_season",
|
|
|
|
|
"DVD_episodenumber",
|
|
|
|
|
"DVD_season",
|
2016-08-22 14:28:24 -04:00
|
|
|
|
"absolute_number",
|
|
|
|
|
"displayseason",
|
|
|
|
|
"displayepisode"
|
2014-07-08 20:46:11 -04:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|