2016-03-27 21:11:27 +00:00
|
|
|
|
using MediaBrowser.Controller.Configuration;
|
2014-07-09 00:46:11 +00:00
|
|
|
|
using MediaBrowser.Controller.Entities;
|
|
|
|
|
using MediaBrowser.Controller.Entities.TV;
|
|
|
|
|
using MediaBrowser.Controller.Library;
|
2014-07-12 02:31:08 +00:00
|
|
|
|
using MediaBrowser.Model.Logging;
|
2014-07-09 00:46:11 +00:00
|
|
|
|
using MediaBrowser.XbmcMetadata.Configuration;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Globalization;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Xml;
|
2017-05-26 06:48:54 +00:00
|
|
|
|
|
2016-10-25 19:02:04 +00:00
|
|
|
|
using MediaBrowser.Controller.IO;
|
|
|
|
|
using MediaBrowser.Model.IO;
|
2016-10-26 02:53:47 +00:00
|
|
|
|
using MediaBrowser.Model.Xml;
|
2014-07-09 00:46:11 +00:00
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.XbmcMetadata.Savers
|
|
|
|
|
{
|
|
|
|
|
public class EpisodeNfoSaver : BaseNfoSaver
|
|
|
|
|
{
|
2018-09-12 17:26:21 +00:00
|
|
|
|
protected override string GetLocalSavePath(BaseItem item)
|
2014-07-09 00:46:11 +00:00
|
|
|
|
{
|
|
|
|
|
return Path.ChangeExtension(item.Path, ".nfo");
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-12 17:26:21 +00:00
|
|
|
|
protected override string GetRootElementName(BaseItem item)
|
2014-07-09 00:46:11 +00:00
|
|
|
|
{
|
|
|
|
|
return "episodedetails";
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-12 17:26:21 +00:00
|
|
|
|
public override bool IsEnabledFor(BaseItem item, ItemUpdateType updateType)
|
2014-07-09 00:46:11 +00:00
|
|
|
|
{
|
|
|
|
|
if (!item.SupportsLocalMetadata)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-04 05:55:34 +00:00
|
|
|
|
return item is Episode && updateType >= MinimumUpdateType;
|
2014-07-09 00:46:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-09-12 17:26:21 +00:00
|
|
|
|
protected override void WriteCustomElements(BaseItem item, XmlWriter writer)
|
2014-07-09 00:46:11 +00:00
|
|
|
|
{
|
|
|
|
|
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 18:08:55 +00:00
|
|
|
|
writer.WriteElementString("aired", episode.PremiereDate.Value.ToLocalTime().ToString(formatString));
|
2014-07-09 00:46:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-10-01 03:34:43 +00:00
|
|
|
|
if (!episode.ParentIndexNumber.HasValue || episode.ParentIndexNumber.Value == 0)
|
2014-07-09 00:46:11 +00:00
|
|
|
|
{
|
2016-10-01 03:34:43 +00: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-09 00:46:11 +00:00
|
|
|
|
|
2016-08-28 16:46:28 +00: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 20:07:35 +00:00
|
|
|
|
}
|
2014-07-09 00:46:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-09-12 17:26:21 +00:00
|
|
|
|
private readonly CultureInfo UsCulture = new CultureInfo("en-US");
|
2014-07-09 00:46:11 +00:00
|
|
|
|
|
2018-09-12 17:26:21 +00:00
|
|
|
|
protected override List<string> GetTagsUsed(BaseItem item)
|
2014-07-09 00:46:11 +00:00
|
|
|
|
{
|
2017-01-27 23:28:21 +00:00
|
|
|
|
var list = base.GetTagsUsed(item);
|
|
|
|
|
list.AddRange(new string[]
|
2014-07-09 00:46:11 +00:00
|
|
|
|
{
|
2017-01-27 23:28:21 +00:00
|
|
|
|
"aired",
|
|
|
|
|
"season",
|
|
|
|
|
"episode",
|
|
|
|
|
"episodenumberend",
|
|
|
|
|
"airsafter_season",
|
|
|
|
|
"airsbefore_episode",
|
|
|
|
|
"airsbefore_season",
|
|
|
|
|
"displayseason",
|
|
|
|
|
"displayepisode"
|
|
|
|
|
});
|
2014-07-09 00:46:11 +00:00
|
|
|
|
return list;
|
|
|
|
|
}
|
2016-10-26 02:53:47 +00:00
|
|
|
|
|
|
|
|
|
public EpisodeNfoSaver(IFileSystem fileSystem, IServerConfigurationManager configurationManager, ILibraryManager libraryManager, IUserManager userManager, IUserDataManager userDataManager, ILogger logger, IXmlReaderSettingsFactory xmlReaderSettingsFactory) : base(fileSystem, configurationManager, libraryManager, userManager, userDataManager, logger, xmlReaderSettingsFactory)
|
|
|
|
|
{
|
|
|
|
|
}
|
2014-07-09 00:46:11 +00:00
|
|
|
|
}
|
2016-10-01 03:34:43 +00:00
|
|
|
|
}
|