Fix some documentation warnings for MediaBrowser.XbmcMetadata
This commit is contained in:
parent
2638759b42
commit
0803a916aa
|
@ -6,6 +6,7 @@ namespace MediaBrowser.XbmcMetadata.Configuration
|
|||
{
|
||||
public class ConfigurationFactory : IConfigurationFactory
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public IEnumerable<ConfigurationStore> GetConfigurations()
|
||||
{
|
||||
return new[]
|
||||
|
|
|
@ -22,13 +22,6 @@ namespace MediaBrowser.XbmcMetadata.Parsers
|
|||
public class BaseNfoParser<T>
|
||||
where T : BaseItem
|
||||
{
|
||||
/// <summary>
|
||||
/// The logger
|
||||
/// </summary>
|
||||
protected ILogger Logger { get; private set; }
|
||||
protected IProviderManager ProviderManager { get; private set; }
|
||||
|
||||
private readonly CultureInfo _usCulture = new CultureInfo("en-US");
|
||||
private readonly IConfigurationManager _config;
|
||||
private Dictionary<string, string> _validProviderIds;
|
||||
|
||||
|
@ -42,6 +35,20 @@ namespace MediaBrowser.XbmcMetadata.Parsers
|
|||
ProviderManager = providerManager;
|
||||
}
|
||||
|
||||
protected CultureInfo UsCulture { get; } = new CultureInfo("en-US");
|
||||
|
||||
/// <summary>
|
||||
/// Gets the logger.
|
||||
/// </summary>
|
||||
protected ILogger Logger { get; }
|
||||
|
||||
protected IProviderManager ProviderManager { get; }
|
||||
|
||||
protected virtual bool SupportsUrlAfterClosingXmlTag => false;
|
||||
|
||||
protected virtual string MovieDbParserSearchString => "themoviedb.org/movie/";
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Fetches metadata for an item from one xml file
|
||||
/// </summary>
|
||||
|
@ -83,8 +90,6 @@ namespace MediaBrowser.XbmcMetadata.Parsers
|
|||
Fetch(item, metadataFile, GetXmlReaderSettings(), cancellationToken);
|
||||
}
|
||||
|
||||
protected virtual bool SupportsUrlAfterClosingXmlTag => false;
|
||||
|
||||
/// <summary>
|
||||
/// Fetches the specified item.
|
||||
/// </summary>
|
||||
|
@ -198,8 +203,6 @@ namespace MediaBrowser.XbmcMetadata.Parsers
|
|||
}
|
||||
}
|
||||
|
||||
protected virtual string MovieDbParserSearchString => "themoviedb.org/movie/";
|
||||
|
||||
protected void ParseProviderLinks(T item, string xml)
|
||||
{
|
||||
//Look for a match for the Regex pattern "tt" followed by 7 digits
|
||||
|
@ -219,7 +222,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers
|
|||
var tmdbId = xml.Substring(index + srch.Length).TrimEnd('/').Split('-')[0];
|
||||
if (!string.IsNullOrWhiteSpace(tmdbId) && int.TryParse(tmdbId, NumberStyles.Integer, CultureInfo.InvariantCulture, out var value))
|
||||
{
|
||||
item.SetProviderId(MetadataProviders.Tmdb, value.ToString(_usCulture));
|
||||
item.SetProviderId(MetadataProviders.Tmdb, value.ToString(UsCulture));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -234,7 +237,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers
|
|||
var tvdbId = xml.Substring(index + srch.Length).TrimEnd('/');
|
||||
if (!string.IsNullOrWhiteSpace(tvdbId) && int.TryParse(tvdbId, NumberStyles.Integer, CultureInfo.InvariantCulture, out var value))
|
||||
{
|
||||
item.SetProviderId(MetadataProviders.Tvdb, value.ToString(_usCulture));
|
||||
item.SetProviderId(MetadataProviders.Tvdb, value.ToString(UsCulture));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -291,7 +294,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers
|
|||
|
||||
if (!string.IsNullOrEmpty(text))
|
||||
{
|
||||
if (float.TryParse(text, NumberStyles.Any, _usCulture, out var value))
|
||||
if (float.TryParse(text, NumberStyles.Any, UsCulture, out var value))
|
||||
{
|
||||
item.CriticRating = value;
|
||||
}
|
||||
|
@ -417,7 +420,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers
|
|||
|
||||
if (!string.IsNullOrWhiteSpace(text))
|
||||
{
|
||||
if (int.TryParse(text.Split(' ')[0], NumberStyles.Integer, _usCulture, out var runtime))
|
||||
if (int.TryParse(text.Split(' ')[0], NumberStyles.Integer, UsCulture, out var runtime))
|
||||
{
|
||||
item.RunTimeTicks = TimeSpan.FromMinutes(runtime).Ticks;
|
||||
}
|
||||
|
@ -870,7 +873,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers
|
|||
|
||||
if (!string.IsNullOrWhiteSpace(val))
|
||||
{
|
||||
if (int.TryParse(val, NumberStyles.Integer, _usCulture, out var intVal))
|
||||
if (int.TryParse(val, NumberStyles.Integer, UsCulture, out var intVal))
|
||||
{
|
||||
sortOrder = intVal;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
@ -14,16 +13,12 @@ namespace MediaBrowser.XbmcMetadata.Parsers
|
|||
{
|
||||
public class EpisodeNfoParser : BaseNfoParser<Episode>
|
||||
{
|
||||
public void Fetch(MetadataResult<Episode> item,
|
||||
List<LocalImageInfo> images,
|
||||
string metadataFile,
|
||||
CancellationToken cancellationToken)
|
||||
public EpisodeNfoParser(ILogger logger, IConfigurationManager config, IProviderManager providerManager)
|
||||
: base(logger, config, providerManager)
|
||||
{
|
||||
Fetch(item, metadataFile, cancellationToken);
|
||||
}
|
||||
|
||||
private readonly CultureInfo UsCulture = new CultureInfo("en-US");
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Fetch(MetadataResult<Episode> item, string metadataFile, XmlReaderSettings settings, CancellationToken cancellationToken)
|
||||
{
|
||||
using (var fileStream = File.OpenRead(metadataFile))
|
||||
|
@ -73,11 +68,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fetches the data from XML node.
|
||||
/// </summary>
|
||||
/// <param name="reader">The reader.</param>
|
||||
/// <param name="itemResult">The item result.</param>
|
||||
/// <inheritdoc />
|
||||
protected override void FetchDataFromXmlNode(XmlReader reader, MetadataResult<Episode> itemResult)
|
||||
{
|
||||
var item = itemResult.Item;
|
||||
|
@ -212,10 +203,5 @@ namespace MediaBrowser.XbmcMetadata.Parsers
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public EpisodeNfoParser(ILogger logger, IConfigurationManager config, IProviderManager providerManager)
|
||||
: base(logger, config, providerManager)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,13 +13,15 @@ namespace MediaBrowser.XbmcMetadata.Parsers
|
|||
{
|
||||
public class MovieNfoParser : BaseNfoParser<Video>
|
||||
{
|
||||
public MovieNfoParser(ILogger logger, IConfigurationManager config, IProviderManager providerManager)
|
||||
: base(logger, config, providerManager)
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override bool SupportsUrlAfterClosingXmlTag => true;
|
||||
|
||||
/// <summary>
|
||||
/// Fetches the data from XML node.
|
||||
/// </summary>
|
||||
/// <param name="reader">The reader.</param>
|
||||
/// <param name="itemResult">The item result.</param>
|
||||
/// <inheritdoc />
|
||||
protected override void FetchDataFromXmlNode(XmlReader reader, MetadataResult<Video> itemResult)
|
||||
{
|
||||
var item = itemResult.Item;
|
||||
|
@ -35,14 +37,17 @@ namespace MediaBrowser.XbmcMetadata.Parsers
|
|||
{
|
||||
imdbId = reader.ReadElementContentAsString();
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(imdbId))
|
||||
{
|
||||
item.SetProviderId(MetadataProviders.Imdb, imdbId);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(tmdbId))
|
||||
{
|
||||
item.SetProviderId(MetadataProviders.Tmdb, tmdbId);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case "set":
|
||||
|
@ -83,9 +88,8 @@ namespace MediaBrowser.XbmcMetadata.Parsers
|
|||
case "artist":
|
||||
{
|
||||
var val = reader.ReadElementContentAsString();
|
||||
var movie = item as MusicVideo;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(val) && movie != null)
|
||||
if (!string.IsNullOrWhiteSpace(val) && item is MusicVideo movie)
|
||||
{
|
||||
var list = movie.Artists.ToList();
|
||||
list.Add(val);
|
||||
|
@ -98,9 +102,8 @@ namespace MediaBrowser.XbmcMetadata.Parsers
|
|||
case "album":
|
||||
{
|
||||
var val = reader.ReadElementContentAsString();
|
||||
var movie = item as MusicVideo;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(val) && movie != null)
|
||||
if (!string.IsNullOrWhiteSpace(val) && item is MusicVideo movie)
|
||||
{
|
||||
movie.Album = val;
|
||||
}
|
||||
|
@ -119,48 +122,41 @@ namespace MediaBrowser.XbmcMetadata.Parsers
|
|||
//xml = xml.Substring(xml.IndexOf('<'));
|
||||
//xml = xml.Substring(0, xml.LastIndexOf('>'));
|
||||
|
||||
using (var stringReader = new StringReader("<set>" + xml + "</set>"))
|
||||
// These are not going to be valid xml so no sense in causing the provider to fail and spamming the log with exceptions
|
||||
try
|
||||
{
|
||||
// These are not going to be valid xml so no sense in causing the provider to fail and spamming the log with exceptions
|
||||
try
|
||||
using (var stringReader = new StringReader("<set>" + xml + "</set>"))
|
||||
using (var reader = XmlReader.Create(stringReader, GetXmlReaderSettings()))
|
||||
{
|
||||
using (var reader = XmlReader.Create(stringReader, GetXmlReaderSettings()))
|
||||
{
|
||||
reader.MoveToContent();
|
||||
reader.Read();
|
||||
reader.MoveToContent();
|
||||
reader.Read();
|
||||
|
||||
// Loop through each element
|
||||
while (!reader.EOF && reader.ReadState == ReadState.Interactive)
|
||||
// Loop through each element
|
||||
while (!reader.EOF && reader.ReadState == ReadState.Interactive)
|
||||
{
|
||||
if (reader.NodeType == XmlNodeType.Element)
|
||||
{
|
||||
if (reader.NodeType == XmlNodeType.Element)
|
||||
switch (reader.Name)
|
||||
{
|
||||
switch (reader.Name)
|
||||
{
|
||||
case "name":
|
||||
movie.CollectionName = reader.ReadElementContentAsString();
|
||||
break;
|
||||
default:
|
||||
reader.Skip();
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
reader.Read();
|
||||
case "name":
|
||||
movie.CollectionName = reader.ReadElementContentAsString();
|
||||
break;
|
||||
default:
|
||||
reader.Skip();
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
reader.Read();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (XmlException)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (XmlException)
|
||||
{
|
||||
|
||||
public MovieNfoParser(ILogger logger, IConfigurationManager config, IProviderManager providerManager)
|
||||
: base(logger, config, providerManager)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,11 +9,12 @@ namespace MediaBrowser.XbmcMetadata.Parsers
|
|||
{
|
||||
public class SeasonNfoParser : BaseNfoParser<Season>
|
||||
{
|
||||
/// <summary>
|
||||
/// Fetches the data from XML node.
|
||||
/// </summary>
|
||||
/// <param name="reader">The reader.</param>
|
||||
/// <param name="itemResult">The item result.</param>
|
||||
public SeasonNfoParser(ILogger logger, IConfigurationManager config, IProviderManager providerManager)
|
||||
: base(logger, config, providerManager)
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void FetchDataFromXmlNode(XmlReader reader, MetadataResult<Season> itemResult)
|
||||
{
|
||||
var item = itemResult.Item;
|
||||
|
@ -39,10 +40,5 @@ namespace MediaBrowser.XbmcMetadata.Parsers
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public SeasonNfoParser(ILogger logger, IConfigurationManager config, IProviderManager providerManager)
|
||||
: base(logger, config, providerManager)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,15 +11,18 @@ namespace MediaBrowser.XbmcMetadata.Parsers
|
|||
{
|
||||
public class SeriesNfoParser : BaseNfoParser<Series>
|
||||
{
|
||||
public SeriesNfoParser(ILogger logger, IConfigurationManager config, IProviderManager providerManager)
|
||||
: base(logger, config, providerManager)
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override bool SupportsUrlAfterClosingXmlTag => true;
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override string MovieDbParserSearchString => "themoviedb.org/tv/";
|
||||
|
||||
/// <summary>
|
||||
/// Fetches the data from XML node.
|
||||
/// </summary>
|
||||
/// <param name="reader">The reader.</param>
|
||||
/// <param name="itemResult">The item result.</param>
|
||||
/// <inheritdoc />
|
||||
protected override void FetchDataFromXmlNode(XmlReader reader, MetadataResult<Series> itemResult)
|
||||
{
|
||||
var item = itemResult.Item;
|
||||
|
@ -91,10 +94,5 @@ namespace MediaBrowser.XbmcMetadata.Parsers
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public SeriesNfoParser(ILogger logger, IConfigurationManager config, IProviderManager providerManager)
|
||||
: base(logger, config, providerManager)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,14 +23,14 @@ namespace MediaBrowser.XbmcMetadata.Providers
|
|||
_providerManager = providerManager;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Fetch(MetadataResult<MusicAlbum> result, string path, CancellationToken cancellationToken)
|
||||
{
|
||||
new BaseNfoParser<MusicAlbum>(_logger, _config, _providerManager).Fetch(result, path, cancellationToken);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override FileSystemMetadata GetXmlFile(ItemInfo info, IDirectoryService directoryService)
|
||||
{
|
||||
return directoryService.GetFile(Path.Combine(info.Path, "album.nfo"));
|
||||
}
|
||||
=> directoryService.GetFile(Path.Combine(info.Path, "album.nfo"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,14 +23,14 @@ namespace MediaBrowser.XbmcMetadata.Providers
|
|||
_providerManager = providerManager;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Fetch(MetadataResult<MusicArtist> result, string path, CancellationToken cancellationToken)
|
||||
{
|
||||
new BaseNfoParser<MusicArtist>(_logger, _config, _providerManager).Fetch(result, path, cancellationToken);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override FileSystemMetadata GetXmlFile(ItemInfo info, IDirectoryService directoryService)
|
||||
{
|
||||
return directoryService.GetFile(Path.Combine(info.Path, "artist.nfo"));
|
||||
}
|
||||
=> directoryService.GetFile(Path.Combine(info.Path, "artist.nfo"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,9 +11,16 @@ namespace MediaBrowser.XbmcMetadata.Providers
|
|||
public abstract class BaseNfoProvider<T> : ILocalMetadataProvider<T>, IHasItemChangeMonitor
|
||||
where T : BaseItem, new()
|
||||
{
|
||||
protected IFileSystem FileSystem;
|
||||
private IFileSystem _fileSystem;
|
||||
|
||||
public Task<MetadataResult<T>> GetMetadata(ItemInfo info,
|
||||
protected BaseNfoProvider(IFileSystem fileSystem)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task<MetadataResult<T>> GetMetadata(
|
||||
ItemInfo info,
|
||||
IDirectoryService directoryService,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
|
@ -47,15 +54,13 @@ namespace MediaBrowser.XbmcMetadata.Providers
|
|||
return Task.FromResult(result);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected abstract void Fetch(MetadataResult<T> result, string path, CancellationToken cancellationToken);
|
||||
|
||||
protected BaseNfoProvider(IFileSystem fileSystem)
|
||||
{
|
||||
FileSystem = fileSystem;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected abstract FileSystemMetadata GetXmlFile(ItemInfo info, IDirectoryService directoryService);
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool HasChanged(BaseItem item, IDirectoryService directoryService)
|
||||
{
|
||||
var file = GetXmlFile(new ItemInfo(item), directoryService);
|
||||
|
@ -65,7 +70,7 @@ namespace MediaBrowser.XbmcMetadata.Providers
|
|||
return false;
|
||||
}
|
||||
|
||||
return file.Exists && FileSystem.GetLastWriteTimeUtc(file) > item.DateLastSaved;
|
||||
return file.Exists && _fileSystem.GetLastWriteTimeUtc(file) > item.DateLastSaved;
|
||||
}
|
||||
|
||||
public string Name => BaseNfoSaver.SaverName;
|
||||
|
|
|
@ -25,6 +25,7 @@ namespace MediaBrowser.XbmcMetadata.Providers
|
|||
_providerManager = providerManager;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Fetch(MetadataResult<T> result, string path, CancellationToken cancellationToken)
|
||||
{
|
||||
var tmpItem = new MetadataResult<Video>
|
||||
|
@ -42,9 +43,10 @@ namespace MediaBrowser.XbmcMetadata.Providers
|
|||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override FileSystemMetadata GetXmlFile(ItemInfo info, IDirectoryService directoryService)
|
||||
{
|
||||
return MovieNfoSaver.GetMovieSavePaths(info, FileSystem)
|
||||
return MovieNfoSaver.GetMovieSavePaths(info)
|
||||
.Select(directoryService.GetFile)
|
||||
.FirstOrDefault(i => i != null);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using MediaBrowser.Common.Configuration;
|
||||
|
@ -24,15 +23,13 @@ namespace MediaBrowser.XbmcMetadata.Providers
|
|||
_providerManager = providerManager;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Fetch(MetadataResult<Episode> result, string path, CancellationToken cancellationToken)
|
||||
{
|
||||
var images = new List<LocalImageInfo>();
|
||||
|
||||
new EpisodeNfoParser(_logger, _config, _providerManager).Fetch(result, images, path, cancellationToken);
|
||||
|
||||
result.Images = images;
|
||||
new EpisodeNfoParser(_logger, _config, _providerManager).Fetch(result, path, cancellationToken);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override FileSystemMetadata GetXmlFile(ItemInfo info, IDirectoryService directoryService)
|
||||
{
|
||||
var path = Path.ChangeExtension(info.Path, ".nfo");
|
||||
|
|
|
@ -23,11 +23,13 @@ namespace MediaBrowser.XbmcMetadata.Providers
|
|||
_providerManager = providerManager;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Fetch(MetadataResult<Season> result, string path, CancellationToken cancellationToken)
|
||||
{
|
||||
new SeasonNfoParser(_logger, _config, _providerManager).Fetch(result, path, cancellationToken);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override FileSystemMetadata GetXmlFile(ItemInfo info, IDirectoryService directoryService)
|
||||
=> directoryService.GetFile(Path.Combine(info.Path, "season.nfo"));
|
||||
}
|
||||
|
|
|
@ -23,11 +23,13 @@ namespace MediaBrowser.XbmcMetadata.Providers
|
|||
_providerManager = providerManager;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Fetch(MetadataResult<Series> result, string path, CancellationToken cancellationToken)
|
||||
{
|
||||
new SeriesNfoParser(_logger, _config, _providerManager).Fetch(result, path, cancellationToken);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override FileSystemMetadata GetXmlFile(ItemInfo info, IDirectoryService directoryService)
|
||||
=> directoryService.GetFile(Path.Combine(info.Path, "tvshow.nfo"));
|
||||
}
|
||||
|
|
|
@ -28,26 +28,15 @@ namespace MediaBrowser.XbmcMetadata.Savers
|
|||
|
||||
/// <inheritdoc />
|
||||
protected override string GetLocalSavePath(BaseItem item)
|
||||
{
|
||||
return Path.Combine(item.Path, "album.nfo");
|
||||
}
|
||||
=> Path.Combine(item.Path, "album.nfo");
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override string GetRootElementName(BaseItem item)
|
||||
{
|
||||
return "album";
|
||||
}
|
||||
=> "album";
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool IsEnabledFor(BaseItem item, ItemUpdateType updateType)
|
||||
{
|
||||
if (!item.SupportsLocalMetadata)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return item is MusicAlbum && updateType >= MinimumUpdateType;
|
||||
}
|
||||
=> !item.SupportsLocalMetadata && item is MusicAlbum && updateType >= MinimumUpdateType;
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void WriteCustomElements(BaseItem item, XmlWriter writer)
|
||||
|
|
|
@ -14,26 +14,24 @@ namespace MediaBrowser.XbmcMetadata.Savers
|
|||
{
|
||||
public class ArtistNfoSaver : BaseNfoSaver
|
||||
{
|
||||
public ArtistNfoSaver(IFileSystem fileSystem, IServerConfigurationManager configurationManager, ILibraryManager libraryManager, IUserManager userManager, IUserDataManager userDataManager, ILogger logger)
|
||||
: base(fileSystem, configurationManager, libraryManager, userManager, userDataManager, logger)
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override string GetLocalSavePath(BaseItem item)
|
||||
{
|
||||
return Path.Combine(item.Path, "artist.nfo");
|
||||
}
|
||||
=> Path.Combine(item.Path, "artist.nfo");
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override string GetRootElementName(BaseItem item)
|
||||
{
|
||||
return "artist";
|
||||
}
|
||||
=> "artist";
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool IsEnabledFor(BaseItem item, ItemUpdateType updateType)
|
||||
{
|
||||
if (!item.SupportsLocalMetadata)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return item is MusicArtist && updateType >= MinimumUpdateType;
|
||||
}
|
||||
=> !item.SupportsLocalMetadata && item is MusicArtist && updateType >= MinimumUpdateType;
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void WriteCustomElements(BaseItem item, XmlWriter writer)
|
||||
{
|
||||
var artist = (MusicArtist)item;
|
||||
|
@ -51,8 +49,6 @@ namespace MediaBrowser.XbmcMetadata.Savers
|
|||
AddAlbums(albums, writer);
|
||||
}
|
||||
|
||||
private readonly CultureInfo UsCulture = new CultureInfo("en-US");
|
||||
|
||||
private void AddAlbums(IList<BaseItem> albums, XmlWriter writer)
|
||||
{
|
||||
foreach (var album in albums)
|
||||
|
@ -66,13 +62,14 @@ namespace MediaBrowser.XbmcMetadata.Savers
|
|||
|
||||
if (album.ProductionYear.HasValue)
|
||||
{
|
||||
writer.WriteElementString("year", album.ProductionYear.Value.ToString(UsCulture));
|
||||
writer.WriteElementString("year", album.ProductionYear.Value.ToString(CultureInfo.InvariantCulture));
|
||||
}
|
||||
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override List<string> GetTagsUsed(BaseItem item)
|
||||
{
|
||||
var list = base.GetTagsUsed(item);
|
||||
|
@ -81,12 +78,8 @@ namespace MediaBrowser.XbmcMetadata.Savers
|
|||
"album",
|
||||
"disbanded"
|
||||
});
|
||||
return list;
|
||||
}
|
||||
|
||||
public ArtistNfoSaver(IFileSystem fileSystem, IServerConfigurationManager configurationManager, ILibraryManager libraryManager, IUserManager userManager, IUserDataManager userDataManager, ILogger logger)
|
||||
: base(fileSystem, configurationManager, libraryManager, userManager, userDataManager, logger)
|
||||
{
|
||||
return list;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,76 +25,81 @@ namespace MediaBrowser.XbmcMetadata.Savers
|
|||
{
|
||||
public abstract class BaseNfoSaver : IMetadataFileSaver
|
||||
{
|
||||
public static readonly string YouTubeWatchUrl = "https://www.youtube.com/watch?v=";
|
||||
public const string DateAddedFormat = "yyyy-MM-dd HH:mm:ss";
|
||||
|
||||
private static readonly CultureInfo UsCulture = new CultureInfo("en-US");
|
||||
public const string YouTubeWatchUrl = "https://www.youtube.com/watch?v=";
|
||||
|
||||
private static readonly Dictionary<string, string> CommonTags = new[] {
|
||||
private static readonly CultureInfo _usCulture = CultureInfo.ReadOnly(new CultureInfo("en-US"));
|
||||
|
||||
"plot",
|
||||
"customrating",
|
||||
"lockdata",
|
||||
"dateadded",
|
||||
"title",
|
||||
"rating",
|
||||
"year",
|
||||
"sorttitle",
|
||||
"mpaa",
|
||||
"aspectratio",
|
||||
"collectionnumber",
|
||||
"tmdbid",
|
||||
"rottentomatoesid",
|
||||
"language",
|
||||
"tvcomid",
|
||||
"tagline",
|
||||
"studio",
|
||||
"genre",
|
||||
"tag",
|
||||
"runtime",
|
||||
"actor",
|
||||
"criticrating",
|
||||
"fileinfo",
|
||||
"director",
|
||||
"writer",
|
||||
"trailer",
|
||||
"premiered",
|
||||
"releasedate",
|
||||
"outline",
|
||||
"id",
|
||||
"credits",
|
||||
"originaltitle",
|
||||
"watched",
|
||||
"playcount",
|
||||
"lastplayed",
|
||||
"art",
|
||||
"resume",
|
||||
"biography",
|
||||
"formed",
|
||||
"review",
|
||||
"style",
|
||||
"imdbid",
|
||||
"imdb_id",
|
||||
"country",
|
||||
"audiodbalbumid",
|
||||
"audiodbartistid",
|
||||
"enddate",
|
||||
"lockedfields",
|
||||
"zap2itid",
|
||||
"tvrageid",
|
||||
private static readonly HashSet<string> _commonTags = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
|
||||
{
|
||||
"plot",
|
||||
"customrating",
|
||||
"lockdata",
|
||||
"dateadded",
|
||||
"title",
|
||||
"rating",
|
||||
"year",
|
||||
"sorttitle",
|
||||
"mpaa",
|
||||
"aspectratio",
|
||||
"collectionnumber",
|
||||
"tmdbid",
|
||||
"rottentomatoesid",
|
||||
"language",
|
||||
"tvcomid",
|
||||
"tagline",
|
||||
"studio",
|
||||
"genre",
|
||||
"tag",
|
||||
"runtime",
|
||||
"actor",
|
||||
"criticrating",
|
||||
"fileinfo",
|
||||
"director",
|
||||
"writer",
|
||||
"trailer",
|
||||
"premiered",
|
||||
"releasedate",
|
||||
"outline",
|
||||
"id",
|
||||
"credits",
|
||||
"originaltitle",
|
||||
"watched",
|
||||
"playcount",
|
||||
"lastplayed",
|
||||
"art",
|
||||
"resume",
|
||||
"biography",
|
||||
"formed",
|
||||
"review",
|
||||
"style",
|
||||
"imdbid",
|
||||
"imdb_id",
|
||||
"country",
|
||||
"audiodbalbumid",
|
||||
"audiodbartistid",
|
||||
"enddate",
|
||||
"lockedfields",
|
||||
"zap2itid",
|
||||
"tvrageid",
|
||||
|
||||
"musicbrainzartistid",
|
||||
"musicbrainzalbumartistid",
|
||||
"musicbrainzalbumid",
|
||||
"musicbrainzreleasegroupid",
|
||||
"tvdbid",
|
||||
"collectionitem",
|
||||
"musicbrainzartistid",
|
||||
"musicbrainzalbumartistid",
|
||||
"musicbrainzalbumid",
|
||||
"musicbrainzreleasegroupid",
|
||||
"tvdbid",
|
||||
"collectionitem",
|
||||
|
||||
"isuserfavorite",
|
||||
"userrating",
|
||||
"isuserfavorite",
|
||||
"userrating",
|
||||
|
||||
"countrycode"
|
||||
"countrycode"
|
||||
};
|
||||
|
||||
// filters control characters but allows only properly-formed surrogate sequences
|
||||
private const string _invalidXMLCharsRegex = @"(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x9F\uFEFF\uFFFE\uFFFF]";
|
||||
|
||||
}.ToDictionary(i => i, StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
protected BaseNfoSaver(
|
||||
IFileSystem fileSystem,
|
||||
|
@ -112,12 +117,17 @@ namespace MediaBrowser.XbmcMetadata.Savers
|
|||
FileSystem = fileSystem;
|
||||
}
|
||||
|
||||
protected IFileSystem FileSystem { get; private set; }
|
||||
protected IServerConfigurationManager ConfigurationManager { get; private set; }
|
||||
protected ILibraryManager LibraryManager { get; private set; }
|
||||
protected IUserManager UserManager { get; private set; }
|
||||
protected IUserDataManager UserDataManager { get; private set; }
|
||||
protected ILogger Logger { get; private set; }
|
||||
protected IFileSystem FileSystem { get; }
|
||||
|
||||
protected IServerConfigurationManager ConfigurationManager { get; }
|
||||
|
||||
protected ILibraryManager LibraryManager { get; }
|
||||
|
||||
protected IUserManager UserManager { get; }
|
||||
|
||||
protected IUserDataManager UserDataManager { get; }
|
||||
|
||||
protected ILogger Logger { get; }
|
||||
|
||||
protected ItemUpdateType MinimumUpdateType
|
||||
{
|
||||
|
@ -136,23 +146,22 @@ namespace MediaBrowser.XbmcMetadata.Savers
|
|||
|
||||
public static string SaverName => "Nfo";
|
||||
|
||||
/// <inheritdoc />
|
||||
public string GetSavePath(BaseItem item)
|
||||
{
|
||||
return GetLocalSavePath(item);
|
||||
}
|
||||
=> GetLocalSavePath(item);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the save path.
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <returns>System.String.</returns>
|
||||
/// <returns><see cref="string" />.</returns>
|
||||
protected abstract string GetLocalSavePath(BaseItem item);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the root element.
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <returns>System.String.</returns>
|
||||
/// <returns><see cref="string" />.</returns>
|
||||
protected abstract string GetRootElementName(BaseItem item);
|
||||
|
||||
/// <summary>
|
||||
|
@ -169,11 +178,12 @@ namespace MediaBrowser.XbmcMetadata.Savers
|
|||
foreach (var providerKey in item.ProviderIds.Keys)
|
||||
{
|
||||
var providerIdTagName = GetTagForProviderKey(providerKey);
|
||||
if (!CommonTags.ContainsKey(providerIdTagName))
|
||||
if (!_commonTags.Contains(providerIdTagName))
|
||||
{
|
||||
list.Add(providerIdTagName);
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
|
@ -199,7 +209,7 @@ namespace MediaBrowser.XbmcMetadata.Savers
|
|||
// On Windows, savint the file will fail if the file is hidden or readonly
|
||||
FileSystem.SetAttributes(path, false, false);
|
||||
|
||||
using (var filestream = FileSystem.GetFileStream(path, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read))
|
||||
using (var filestream = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.Read))
|
||||
{
|
||||
stream.CopyTo(filestream);
|
||||
}
|
||||
|
@ -248,9 +258,7 @@ namespace MediaBrowser.XbmcMetadata.Savers
|
|||
|
||||
WriteCustomElements(item, writer);
|
||||
|
||||
var hasMediaSources = baseItem as IHasMediaSources;
|
||||
|
||||
if (hasMediaSources != null)
|
||||
if (baseItem is IHasMediaSources hasMediaSources)
|
||||
{
|
||||
AddMediaInfo(hasMediaSources, writer);
|
||||
}
|
||||
|
@ -313,17 +321,17 @@ namespace MediaBrowser.XbmcMetadata.Savers
|
|||
|
||||
if (stream.BitRate.HasValue)
|
||||
{
|
||||
writer.WriteElementString("bitrate", stream.BitRate.Value.ToString(UsCulture));
|
||||
writer.WriteElementString("bitrate", stream.BitRate.Value.ToString(_usCulture));
|
||||
}
|
||||
|
||||
if (stream.Width.HasValue)
|
||||
{
|
||||
writer.WriteElementString("width", stream.Width.Value.ToString(UsCulture));
|
||||
writer.WriteElementString("width", stream.Width.Value.ToString(_usCulture));
|
||||
}
|
||||
|
||||
if (stream.Height.HasValue)
|
||||
{
|
||||
writer.WriteElementString("height", stream.Height.Value.ToString(UsCulture));
|
||||
writer.WriteElementString("height", stream.Height.Value.ToString(_usCulture));
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(stream.AspectRatio))
|
||||
|
@ -336,14 +344,14 @@ namespace MediaBrowser.XbmcMetadata.Savers
|
|||
|
||||
if (framerate.HasValue)
|
||||
{
|
||||
writer.WriteElementString("framerate", framerate.Value.ToString(UsCulture));
|
||||
writer.WriteElementString("framerate", framerate.Value.ToString(_usCulture));
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(stream.Language))
|
||||
{
|
||||
// http://web.archive.org/web/20181230211547/https://emby.media/community/index.php?/topic/49071-nfo-not-generated-on-actualize-or-rescan-or-identify
|
||||
// Web Archive version of link since it's not really explained in the thread.
|
||||
writer.WriteElementString("language", RemoveInvalidXMLChars(stream.Language));
|
||||
writer.WriteElementString("language", Regex.Replace(stream.Language, _invalidXMLCharsRegex, string.Empty));
|
||||
}
|
||||
|
||||
var scanType = stream.IsInterlaced ? "interlaced" : "progressive";
|
||||
|
@ -354,12 +362,12 @@ namespace MediaBrowser.XbmcMetadata.Savers
|
|||
|
||||
if (stream.Channels.HasValue)
|
||||
{
|
||||
writer.WriteElementString("channels", stream.Channels.Value.ToString(UsCulture));
|
||||
writer.WriteElementString("channels", stream.Channels.Value.ToString(_usCulture));
|
||||
}
|
||||
|
||||
if (stream.SampleRate.HasValue)
|
||||
{
|
||||
writer.WriteElementString("samplingrate", stream.SampleRate.Value.ToString(UsCulture));
|
||||
writer.WriteElementString("samplingrate", stream.SampleRate.Value.ToString(_usCulture));
|
||||
}
|
||||
|
||||
writer.WriteElementString("default", stream.IsDefault.ToString());
|
||||
|
@ -372,13 +380,11 @@ namespace MediaBrowser.XbmcMetadata.Savers
|
|||
{
|
||||
var timespan = TimeSpan.FromTicks(runtimeTicks.Value);
|
||||
|
||||
writer.WriteElementString("duration", Math.Floor(timespan.TotalMinutes).ToString(UsCulture));
|
||||
writer.WriteElementString("durationinseconds", Math.Floor(timespan.TotalSeconds).ToString(UsCulture));
|
||||
writer.WriteElementString("duration", Math.Floor(timespan.TotalMinutes).ToString(_usCulture));
|
||||
writer.WriteElementString("durationinseconds", Math.Floor(timespan.TotalSeconds).ToString(_usCulture));
|
||||
}
|
||||
|
||||
var video = item as Video;
|
||||
|
||||
if (video != null)
|
||||
if (item is Video video)
|
||||
{
|
||||
//AddChapters(video, builder, itemRepository);
|
||||
|
||||
|
@ -413,21 +419,6 @@ namespace MediaBrowser.XbmcMetadata.Savers
|
|||
writer.WriteEndElement();
|
||||
}
|
||||
|
||||
// filters control characters but allows only properly-formed surrogate sequences
|
||||
private static Regex _invalidXMLChars = new Regex(
|
||||
@"(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x9F\uFEFF\uFFFE\uFFFF]");
|
||||
|
||||
/// <summary>
|
||||
/// removes any unusual unicode characters that can't be encoded into XML
|
||||
/// </summary>
|
||||
public static string RemoveInvalidXMLChars(string text)
|
||||
{
|
||||
if (string.IsNullOrEmpty(text)) return string.Empty;
|
||||
return _invalidXMLChars.Replace(text, string.Empty);
|
||||
}
|
||||
|
||||
public const string DateAddedFormat = "yyyy-MM-dd HH:mm:ss";
|
||||
|
||||
/// <summary>
|
||||
/// Adds the common nodes.
|
||||
/// </summary>
|
||||
|
@ -524,12 +515,12 @@ namespace MediaBrowser.XbmcMetadata.Savers
|
|||
|
||||
if (item.CommunityRating.HasValue)
|
||||
{
|
||||
writer.WriteElementString("rating", item.CommunityRating.Value.ToString(UsCulture));
|
||||
writer.WriteElementString("rating", item.CommunityRating.Value.ToString(_usCulture));
|
||||
}
|
||||
|
||||
if (item.ProductionYear.HasValue)
|
||||
{
|
||||
writer.WriteElementString("year", item.ProductionYear.Value.ToString(UsCulture));
|
||||
writer.WriteElementString("year", item.ProductionYear.Value.ToString(_usCulture));
|
||||
}
|
||||
|
||||
var forcedSortName = item.ForcedSortName;
|
||||
|
@ -628,12 +619,10 @@ namespace MediaBrowser.XbmcMetadata.Savers
|
|||
|
||||
if (item.CriticRating.HasValue)
|
||||
{
|
||||
writer.WriteElementString("criticrating", item.CriticRating.Value.ToString(UsCulture));
|
||||
writer.WriteElementString("criticrating", item.CriticRating.Value.ToString(_usCulture));
|
||||
}
|
||||
|
||||
var hasDisplayOrder = item as IHasDisplayOrder;
|
||||
|
||||
if (hasDisplayOrder != null)
|
||||
if (item is IHasDisplayOrder hasDisplayOrder)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(hasDisplayOrder.DisplayOrder))
|
||||
{
|
||||
|
@ -648,7 +637,7 @@ namespace MediaBrowser.XbmcMetadata.Savers
|
|||
{
|
||||
var timespan = TimeSpan.FromTicks(runTimeTicks.Value);
|
||||
|
||||
writer.WriteElementString("runtime", Convert.ToInt64(timespan.TotalMinutes).ToString(UsCulture));
|
||||
writer.WriteElementString("runtime", Convert.ToInt64(timespan.TotalMinutes).ToString(_usCulture));
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(item.Tagline))
|
||||
|
@ -783,8 +772,7 @@ namespace MediaBrowser.XbmcMetadata.Savers
|
|||
|
||||
AddActors(people, writer, libraryManager, fileSystem, config, options.SaveImagePathsInNfo);
|
||||
|
||||
var folder = item as BoxSet;
|
||||
if (folder != null)
|
||||
if (item is BoxSet folder)
|
||||
{
|
||||
AddCollectionItems(folder, writer);
|
||||
}
|
||||
|
@ -875,7 +863,7 @@ namespace MediaBrowser.XbmcMetadata.Savers
|
|||
|
||||
if (!item.IsFolder)
|
||||
{
|
||||
writer.WriteElementString("playcount", userdata.PlayCount.ToString(UsCulture));
|
||||
writer.WriteElementString("playcount", userdata.PlayCount.ToString(_usCulture));
|
||||
writer.WriteElementString("watched", userdata.Played.ToString(CultureInfo.InvariantCulture).ToLowerInvariant());
|
||||
|
||||
if (userdata.LastPlayedDate.HasValue)
|
||||
|
@ -887,8 +875,8 @@ namespace MediaBrowser.XbmcMetadata.Savers
|
|||
|
||||
var runTimeTicks = item.RunTimeTicks ?? 0;
|
||||
|
||||
writer.WriteElementString("position", TimeSpan.FromTicks(userdata.PlaybackPositionTicks).TotalSeconds.ToString(UsCulture));
|
||||
writer.WriteElementString("total", TimeSpan.FromTicks(runTimeTicks).TotalSeconds.ToString(UsCulture));
|
||||
writer.WriteElementString("position", TimeSpan.FromTicks(userdata.PlaybackPositionTicks).TotalSeconds.ToString(_usCulture));
|
||||
writer.WriteElementString("total", TimeSpan.FromTicks(runTimeTicks).TotalSeconds.ToString(_usCulture));
|
||||
}
|
||||
|
||||
writer.WriteEndElement();
|
||||
|
@ -922,24 +910,17 @@ namespace MediaBrowser.XbmcMetadata.Savers
|
|||
|
||||
if (person.SortOrder.HasValue)
|
||||
{
|
||||
writer.WriteElementString("sortorder", person.SortOrder.Value.ToString(UsCulture));
|
||||
writer.WriteElementString("sortorder", person.SortOrder.Value.ToString(_usCulture));
|
||||
}
|
||||
|
||||
if (saveImagePath)
|
||||
{
|
||||
try
|
||||
{
|
||||
var personEntity = libraryManager.GetPerson(person.Name);
|
||||
var image = personEntity.GetImageInfo(ImageType.Primary, 0);
|
||||
var personEntity = libraryManager.GetPerson(person.Name);
|
||||
var image = personEntity.GetImageInfo(ImageType.Primary, 0);
|
||||
|
||||
if (image != null)
|
||||
{
|
||||
writer.WriteElementString("thumb", GetImagePathToSave(image, libraryManager, config));
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
if (image != null)
|
||||
{
|
||||
// Already logged in core
|
||||
writer.WriteElementString("thumb", GetImagePathToSave(image, libraryManager, config));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -995,7 +976,7 @@ namespace MediaBrowser.XbmcMetadata.Savers
|
|||
{
|
||||
var name = reader.Name;
|
||||
|
||||
if (!CommonTags.ContainsKey(name) && !xmlTagsUsed.Contains(name, StringComparer.OrdinalIgnoreCase))
|
||||
if (!_commonTags.Contains(name) && !xmlTagsUsed.Contains(name, StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
writer.WriteNode(reader, false);
|
||||
}
|
||||
|
@ -1013,8 +994,6 @@ namespace MediaBrowser.XbmcMetadata.Savers
|
|||
}
|
||||
|
||||
private string GetTagForProviderKey(string providerKey)
|
||||
{
|
||||
return providerKey.ToLowerInvariant() + "id";
|
||||
}
|
||||
=> providerKey.ToLowerInvariant() + "id";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,43 +14,43 @@ namespace MediaBrowser.XbmcMetadata.Savers
|
|||
{
|
||||
public class EpisodeNfoSaver : BaseNfoSaver
|
||||
{
|
||||
public EpisodeNfoSaver(IFileSystem fileSystem, IServerConfigurationManager configurationManager, ILibraryManager libraryManager, IUserManager userManager, IUserDataManager userDataManager, ILogger logger)
|
||||
: base(fileSystem, configurationManager, libraryManager, userManager, userDataManager, logger)
|
||||
{
|
||||
}
|
||||
|
||||
private readonly CultureInfo _usCulture = new CultureInfo("en-US");
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override string GetLocalSavePath(BaseItem item)
|
||||
{
|
||||
return Path.ChangeExtension(item.Path, ".nfo");
|
||||
}
|
||||
=> Path.ChangeExtension(item.Path, ".nfo");
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override string GetRootElementName(BaseItem item)
|
||||
{
|
||||
return "episodedetails";
|
||||
}
|
||||
=> "episodedetails";
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool IsEnabledFor(BaseItem item, ItemUpdateType updateType)
|
||||
{
|
||||
if (!item.SupportsLocalMetadata)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return item is Episode && updateType >= MinimumUpdateType;
|
||||
}
|
||||
=> !item.SupportsLocalMetadata && item is Episode && updateType >= MinimumUpdateType;
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void WriteCustomElements(BaseItem item, XmlWriter writer)
|
||||
{
|
||||
var episode = (Episode)item;
|
||||
|
||||
if (episode.IndexNumber.HasValue)
|
||||
{
|
||||
writer.WriteElementString("episode", episode.IndexNumber.Value.ToString(UsCulture));
|
||||
writer.WriteElementString("episode", episode.IndexNumber.Value.ToString(_usCulture));
|
||||
}
|
||||
|
||||
if (episode.IndexNumberEnd.HasValue)
|
||||
{
|
||||
writer.WriteElementString("episodenumberend", episode.IndexNumberEnd.Value.ToString(UsCulture));
|
||||
writer.WriteElementString("episodenumberend", episode.IndexNumberEnd.Value.ToString(_usCulture));
|
||||
}
|
||||
|
||||
if (episode.ParentIndexNumber.HasValue)
|
||||
{
|
||||
writer.WriteElementString("season", episode.ParentIndexNumber.Value.ToString(UsCulture));
|
||||
writer.WriteElementString("season", episode.ParentIndexNumber.Value.ToString(_usCulture));
|
||||
}
|
||||
|
||||
if (episode.PremiereDate.HasValue)
|
||||
|
@ -64,32 +64,33 @@ namespace MediaBrowser.XbmcMetadata.Savers
|
|||
{
|
||||
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));
|
||||
writer.WriteElementString("airsafter_season", episode.AirsAfterSeasonNumber.Value.ToString(_usCulture));
|
||||
}
|
||||
|
||||
if (episode.AirsBeforeEpisodeNumber.HasValue && episode.AirsBeforeEpisodeNumber.Value != -1)
|
||||
{
|
||||
writer.WriteElementString("displayepisode", episode.AirsBeforeEpisodeNumber.Value.ToString(UsCulture));
|
||||
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));
|
||||
}
|
||||
|
||||
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));
|
||||
writer.WriteElementString("displayseason", specialSeason.Value.ToString(_usCulture));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private readonly CultureInfo UsCulture = new CultureInfo("en-US");
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override List<string> GetTagsUsed(BaseItem item)
|
||||
{
|
||||
var list = base.GetTagsUsed(item);
|
||||
|
@ -105,12 +106,8 @@ namespace MediaBrowser.XbmcMetadata.Savers
|
|||
"displayseason",
|
||||
"displayepisode"
|
||||
});
|
||||
return list;
|
||||
}
|
||||
|
||||
public EpisodeNfoSaver(IFileSystem fileSystem, IServerConfigurationManager configurationManager, ILibraryManager libraryManager, IUserManager userManager, IUserDataManager userDataManager, ILogger logger)
|
||||
: base(fileSystem, configurationManager, libraryManager, userManager, userDataManager, logger)
|
||||
{
|
||||
return list;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Xml;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
|
@ -15,28 +16,29 @@ namespace MediaBrowser.XbmcMetadata.Savers
|
|||
{
|
||||
public class MovieNfoSaver : BaseNfoSaver
|
||||
{
|
||||
protected override string GetLocalSavePath(BaseItem item)
|
||||
public MovieNfoSaver(IFileSystem fileSystem, IServerConfigurationManager configurationManager, ILibraryManager libraryManager, IUserManager userManager, IUserDataManager userDataManager, ILogger logger)
|
||||
: base(fileSystem, configurationManager, libraryManager, userManager, userDataManager, logger)
|
||||
{
|
||||
var paths = GetMovieSavePaths(new ItemInfo(item), FileSystem);
|
||||
return paths.Count == 0 ? null : paths[0];
|
||||
}
|
||||
|
||||
public static List<string> GetMovieSavePaths(ItemInfo item, IFileSystem fileSystem)
|
||||
{
|
||||
var list = new List<string>();
|
||||
/// <inheritdoc />
|
||||
protected override string GetLocalSavePath(BaseItem item)
|
||||
=> GetMovieSavePaths(new ItemInfo(item)).FirstOrDefault();
|
||||
|
||||
public static IEnumerable<string> GetMovieSavePaths(ItemInfo item)
|
||||
{
|
||||
if (item.VideoType == VideoType.Dvd && !item.IsPlaceHolder)
|
||||
{
|
||||
var path = item.ContainingFolderPath;
|
||||
|
||||
list.Add(Path.Combine(path, "VIDEO_TS", "VIDEO_TS.nfo"));
|
||||
yield return Path.Combine(path, "VIDEO_TS", "VIDEO_TS.nfo");
|
||||
}
|
||||
|
||||
if (!item.IsPlaceHolder && (item.VideoType == VideoType.Dvd || item.VideoType == VideoType.BluRay))
|
||||
{
|
||||
var path = item.ContainingFolderPath;
|
||||
|
||||
list.Add(Path.Combine(path, Path.GetFileName(path) + ".nfo"));
|
||||
yield return Path.Combine(path, Path.GetFileName(path) + ".nfo");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -47,22 +49,20 @@ namespace MediaBrowser.XbmcMetadata.Savers
|
|||
// list.Add(Path.Combine(item.ContainingFolderPath, "movie.nfo"));
|
||||
//}
|
||||
|
||||
list.Add(Path.ChangeExtension(item.Path, ".nfo"));
|
||||
yield return Path.ChangeExtension(item.Path, ".nfo");
|
||||
|
||||
if (!item.IsInMixedFolder)
|
||||
{
|
||||
list.Add(Path.Combine(item.ContainingFolderPath, "movie.nfo"));
|
||||
yield return Path.Combine(item.ContainingFolderPath, "movie.nfo");
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override string GetRootElementName(BaseItem item)
|
||||
{
|
||||
return item is MusicVideo ? "musicvideo" : "movie";
|
||||
}
|
||||
=> item is MusicVideo ? "musicvideo" : "movie";
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool IsEnabledFor(BaseItem item, ItemUpdateType updateType)
|
||||
{
|
||||
if (!item.SupportsLocalMetadata)
|
||||
|
@ -70,10 +70,8 @@ namespace MediaBrowser.XbmcMetadata.Savers
|
|||
return false;
|
||||
}
|
||||
|
||||
var video = item as Video;
|
||||
|
||||
// Check parent for null to avoid running this against things like video backdrops
|
||||
if (video != null && !(item is Episode) && !video.ExtraType.HasValue)
|
||||
if (item is Video video && !(item is Episode) && !video.ExtraType.HasValue)
|
||||
{
|
||||
return updateType >= MinimumUpdateType;
|
||||
}
|
||||
|
@ -81,6 +79,7 @@ namespace MediaBrowser.XbmcMetadata.Savers
|
|||
return false;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void WriteCustomElements(BaseItem item, XmlWriter writer)
|
||||
{
|
||||
var imdb = item.GetProviderId(MetadataProviders.Imdb);
|
||||
|
@ -90,9 +89,7 @@ namespace MediaBrowser.XbmcMetadata.Savers
|
|||
writer.WriteElementString("id", imdb);
|
||||
}
|
||||
|
||||
var musicVideo = item as MusicVideo;
|
||||
|
||||
if (musicVideo != null)
|
||||
if (item is MusicVideo musicVideo)
|
||||
{
|
||||
foreach (var artist in musicVideo.Artists)
|
||||
{
|
||||
|
@ -104,9 +101,7 @@ namespace MediaBrowser.XbmcMetadata.Savers
|
|||
}
|
||||
}
|
||||
|
||||
var movie = item as Movie;
|
||||
|
||||
if (movie != null)
|
||||
if (item is Movie movie)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(movie.CollectionName))
|
||||
{
|
||||
|
@ -115,6 +110,7 @@ namespace MediaBrowser.XbmcMetadata.Savers
|
|||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override List<string> GetTagsUsed(BaseItem item)
|
||||
{
|
||||
var list = base.GetTagsUsed(item);
|
||||
|
@ -125,12 +121,8 @@ namespace MediaBrowser.XbmcMetadata.Savers
|
|||
"set",
|
||||
"id"
|
||||
});
|
||||
return list;
|
||||
}
|
||||
|
||||
public MovieNfoSaver(IFileSystem fileSystem, IServerConfigurationManager configurationManager, ILibraryManager libraryManager, IUserManager userManager, IUserDataManager userDataManager, ILogger logger)
|
||||
: base(fileSystem, configurationManager, libraryManager, userManager, userDataManager, logger)
|
||||
{
|
||||
return list;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,16 +13,26 @@ namespace MediaBrowser.XbmcMetadata.Savers
|
|||
{
|
||||
public class SeasonNfoSaver : BaseNfoSaver
|
||||
{
|
||||
public SeasonNfoSaver(
|
||||
IFileSystem fileSystem,
|
||||
IServerConfigurationManager configurationManager,
|
||||
ILibraryManager libraryManager,
|
||||
IUserManager userManager,
|
||||
IUserDataManager userDataManager,
|
||||
ILogger logger)
|
||||
: base(fileSystem, configurationManager, libraryManager, userManager, userDataManager, logger)
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override string GetLocalSavePath(BaseItem item)
|
||||
{
|
||||
return Path.Combine(item.Path, "season.nfo");
|
||||
}
|
||||
=> Path.Combine(item.Path, "season.nfo");
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override string GetRootElementName(BaseItem item)
|
||||
{
|
||||
return "season";
|
||||
}
|
||||
=> "season";
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool IsEnabledFor(BaseItem item, ItemUpdateType updateType)
|
||||
{
|
||||
if (!item.SupportsLocalMetadata)
|
||||
|
@ -38,6 +48,7 @@ namespace MediaBrowser.XbmcMetadata.Savers
|
|||
return updateType >= MinimumUpdateType || (updateType >= ItemUpdateType.MetadataImport && File.Exists(GetSavePath(item)));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void WriteCustomElements(BaseItem item, XmlWriter writer)
|
||||
{
|
||||
var season = (Season)item;
|
||||
|
@ -48,6 +59,7 @@ namespace MediaBrowser.XbmcMetadata.Savers
|
|||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override List<string> GetTagsUsed(BaseItem item)
|
||||
{
|
||||
var list = base.GetTagsUsed(item);
|
||||
|
@ -58,16 +70,5 @@ namespace MediaBrowser.XbmcMetadata.Savers
|
|||
|
||||
return list;
|
||||
}
|
||||
|
||||
public SeasonNfoSaver(
|
||||
IFileSystem fileSystem,
|
||||
IServerConfigurationManager configurationManager,
|
||||
ILibraryManager libraryManager,
|
||||
IUserManager userManager,
|
||||
IUserDataManager userDataManager,
|
||||
ILogger logger)
|
||||
: base(fileSystem, configurationManager, libraryManager, userManager, userDataManager, logger)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Xml;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
|
@ -13,26 +14,30 @@ namespace MediaBrowser.XbmcMetadata.Savers
|
|||
{
|
||||
public class SeriesNfoSaver : BaseNfoSaver
|
||||
{
|
||||
public SeriesNfoSaver(
|
||||
IFileSystem fileSystem,
|
||||
IServerConfigurationManager configurationManager,
|
||||
ILibraryManager libraryManager,
|
||||
IUserManager userManager,
|
||||
IUserDataManager userDataManager,
|
||||
ILogger logger)
|
||||
: base(fileSystem, configurationManager, libraryManager, userManager, userDataManager, logger)
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override string GetLocalSavePath(BaseItem item)
|
||||
{
|
||||
return Path.Combine(item.Path, "tvshow.nfo");
|
||||
}
|
||||
=> Path.Combine(item.Path, "tvshow.nfo");
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override string GetRootElementName(BaseItem item)
|
||||
{
|
||||
return "tvshow";
|
||||
}
|
||||
=> "tvshow";
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool IsEnabledFor(BaseItem item, ItemUpdateType updateType)
|
||||
{
|
||||
if (!item.SupportsLocalMetadata)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return item is Series && updateType >= MinimumUpdateType;
|
||||
}
|
||||
=> item.SupportsLocalMetadata && item is Series && updateType >= MinimumUpdateType;
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void WriteCustomElements(BaseItem item, XmlWriter writer)
|
||||
{
|
||||
var series = (Series)item;
|
||||
|
@ -52,7 +57,12 @@ namespace MediaBrowser.XbmcMetadata.Savers
|
|||
|
||||
writer.WriteStartElement("url");
|
||||
writer.WriteAttributeString("cache", string.Format("{0}.xml", tvdb));
|
||||
writer.WriteString(string.Format("http://www.thetvdb.com/api/1D62F2F90030C444/series/{0}/all/{1}.zip", tvdb, language));
|
||||
writer.WriteString(
|
||||
string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"http://www.thetvdb.com/api/1D62F2F90030C444/series/{0}/all/{1}.zip",
|
||||
tvdb,
|
||||
language));
|
||||
writer.WriteEndElement();
|
||||
|
||||
writer.WriteEndElement();
|
||||
|
@ -67,6 +77,7 @@ namespace MediaBrowser.XbmcMetadata.Savers
|
|||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override List<string> GetTagsUsed(BaseItem item)
|
||||
{
|
||||
var list = base.GetTagsUsed(item);
|
||||
|
@ -79,12 +90,8 @@ namespace MediaBrowser.XbmcMetadata.Savers
|
|||
"status",
|
||||
"displayorder"
|
||||
});
|
||||
return list;
|
||||
}
|
||||
|
||||
public SeriesNfoSaver(IFileSystem fileSystem, IServerConfigurationManager configurationManager, ILibraryManager libraryManager, IUserManager userManager, IUserDataManager userDataManager, ILogger logger)
|
||||
: base(fileSystem, configurationManager, libraryManager, userManager, userDataManager, logger)
|
||||
{
|
||||
return list;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user