Merge pull request #1643 from Bond-009/docs3
Fix some documentation warnings for MediaBrowser.XbmcMetadata
This commit is contained in:
commit
e19474d22f
|
@ -6,6 +6,7 @@ namespace MediaBrowser.XbmcMetadata.Configuration
|
|||
{
|
||||
public class ConfigurationFactory : IConfigurationFactory
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public IEnumerable<ConfigurationStore> GetConfigurations()
|
||||
{
|
||||
return new[]
|
||||
|
|
|
@ -15,4 +15,8 @@
|
|||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<LangVersion>latest</LangVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -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,19 @@ 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 +89,6 @@ namespace MediaBrowser.XbmcMetadata.Parsers
|
|||
Fetch(item, metadataFile, GetXmlReaderSettings(), cancellationToken);
|
||||
}
|
||||
|
||||
protected virtual bool SupportsUrlAfterClosingXmlTag => false;
|
||||
|
||||
/// <summary>
|
||||
/// Fetches the specified item.
|
||||
/// </summary>
|
||||
|
@ -198,8 +202,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 +221,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 +236,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 +293,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 +419,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 +872,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,11 +122,10 @@ 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
|
||||
{
|
||||
using (var stringReader = new StringReader("<set>" + xml + "</set>"))
|
||||
using (var reader = XmlReader.Create(stringReader, GetXmlReaderSettings()))
|
||||
{
|
||||
reader.MoveToContent();
|
||||
|
@ -157,10 +159,4 @@ namespace MediaBrowser.XbmcMetadata.Parsers
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,12 +25,12 @@ 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");
|
||||
|
||||
private static readonly Dictionary<string, string> CommonTags = new[] {
|
||||
public const string YouTubeWatchUrl = "https://www.youtube.com/watch?v=";
|
||||
|
||||
private static readonly HashSet<string> _commonTags = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
|
||||
{
|
||||
"plot",
|
||||
"customrating",
|
||||
"lockdata",
|
||||
|
@ -93,8 +93,10 @@ namespace MediaBrowser.XbmcMetadata.Savers
|
|||
"userrating",
|
||||
|
||||
"countrycode"
|
||||
};
|
||||
|
||||
}.ToDictionary(i => i, StringComparer.OrdinalIgnoreCase);
|
||||
// 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]";
|
||||
|
||||
protected BaseNfoSaver(
|
||||
IFileSystem fileSystem,
|
||||
|
@ -112,12 +114,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
|
||||
{
|
||||
|
@ -132,35 +139,30 @@ namespace MediaBrowser.XbmcMetadata.Savers
|
|||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Name => SaverName;
|
||||
|
||||
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>
|
||||
/// Determines whether [is enabled for] [the specified item].
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="updateType">Type of the update.</param>
|
||||
/// <returns><c>true</c> if [is enabled for] [the specified item]; otherwise, <c>false</c>.</returns>
|
||||
/// <inheritdoc />
|
||||
public abstract bool IsEnabledFor(BaseItem item, ItemUpdateType updateType);
|
||||
|
||||
protected virtual List<string> GetTagsUsed(BaseItem item)
|
||||
|
@ -169,14 +171,16 @@ 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;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Save(BaseItem item, CancellationToken cancellationToken)
|
||||
{
|
||||
var path = GetSavePath(item);
|
||||
|
@ -196,10 +200,11 @@ namespace MediaBrowser.XbmcMetadata.Savers
|
|||
private void SaveToFile(Stream stream, string path)
|
||||
{
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(path));
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
@ -216,9 +221,9 @@ namespace MediaBrowser.XbmcMetadata.Savers
|
|||
{
|
||||
FileSystem.SetHidden(path, hidden);
|
||||
}
|
||||
catch (Exception ex)
|
||||
catch (IOException ex)
|
||||
{
|
||||
Logger.LogError(ex, "Error setting hidden attribute on {path}", path);
|
||||
Logger.LogError(ex, "Error setting hidden attribute on {Path}", path);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -248,9 +253,7 @@ namespace MediaBrowser.XbmcMetadata.Savers
|
|||
|
||||
WriteCustomElements(item, writer);
|
||||
|
||||
var hasMediaSources = baseItem as IHasMediaSources;
|
||||
|
||||
if (hasMediaSources != null)
|
||||
if (baseItem is IHasMediaSources hasMediaSources)
|
||||
{
|
||||
AddMediaInfo(hasMediaSources, writer);
|
||||
}
|
||||
|
@ -259,7 +262,7 @@ namespace MediaBrowser.XbmcMetadata.Savers
|
|||
|
||||
try
|
||||
{
|
||||
AddCustomTags(xmlPath, tagsUsed, writer, Logger, FileSystem);
|
||||
AddCustomTags(xmlPath, tagsUsed, writer, Logger);
|
||||
}
|
||||
catch (FileNotFoundException)
|
||||
{
|
||||
|
@ -313,17 +316,17 @@ namespace MediaBrowser.XbmcMetadata.Savers
|
|||
|
||||
if (stream.BitRate.HasValue)
|
||||
{
|
||||
writer.WriteElementString("bitrate", stream.BitRate.Value.ToString(UsCulture));
|
||||
writer.WriteElementString("bitrate", stream.BitRate.Value.ToString(CultureInfo.InvariantCulture));
|
||||
}
|
||||
|
||||
if (stream.Width.HasValue)
|
||||
{
|
||||
writer.WriteElementString("width", stream.Width.Value.ToString(UsCulture));
|
||||
writer.WriteElementString("width", stream.Width.Value.ToString(CultureInfo.InvariantCulture));
|
||||
}
|
||||
|
||||
if (stream.Height.HasValue)
|
||||
{
|
||||
writer.WriteElementString("height", stream.Height.Value.ToString(UsCulture));
|
||||
writer.WriteElementString("height", stream.Height.Value.ToString(CultureInfo.InvariantCulture));
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(stream.AspectRatio))
|
||||
|
@ -336,14 +339,14 @@ namespace MediaBrowser.XbmcMetadata.Savers
|
|||
|
||||
if (framerate.HasValue)
|
||||
{
|
||||
writer.WriteElementString("framerate", framerate.Value.ToString(UsCulture));
|
||||
writer.WriteElementString("framerate", framerate.Value.ToString(CultureInfo.InvariantCulture));
|
||||
}
|
||||
|
||||
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 +357,12 @@ namespace MediaBrowser.XbmcMetadata.Savers
|
|||
|
||||
if (stream.Channels.HasValue)
|
||||
{
|
||||
writer.WriteElementString("channels", stream.Channels.Value.ToString(UsCulture));
|
||||
writer.WriteElementString("channels", stream.Channels.Value.ToString(CultureInfo.InvariantCulture));
|
||||
}
|
||||
|
||||
if (stream.SampleRate.HasValue)
|
||||
{
|
||||
writer.WriteElementString("samplingrate", stream.SampleRate.Value.ToString(UsCulture));
|
||||
writer.WriteElementString("samplingrate", stream.SampleRate.Value.ToString(CultureInfo.InvariantCulture));
|
||||
}
|
||||
|
||||
writer.WriteElementString("default", stream.IsDefault.ToString());
|
||||
|
@ -372,13 +375,15 @@ 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(CultureInfo.InvariantCulture));
|
||||
writer.WriteElementString(
|
||||
"durationinseconds",
|
||||
Math.Floor(timespan.TotalSeconds).ToString(CultureInfo.InvariantCulture));
|
||||
}
|
||||
|
||||
var video = item as Video;
|
||||
|
||||
if (video != null)
|
||||
if (item is Video video)
|
||||
{
|
||||
//AddChapters(video, builder, itemRepository);
|
||||
|
||||
|
@ -413,26 +418,18 @@ 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>
|
||||
/// <returns>Task.</returns>
|
||||
private void AddCommonNodes(BaseItem item, XmlWriter writer, ILibraryManager libraryManager, IUserManager userManager, IUserDataManager userDataRepo, IFileSystem fileSystem, IServerConfigurationManager config)
|
||||
private void AddCommonNodes(
|
||||
BaseItem item,
|
||||
XmlWriter writer,
|
||||
ILibraryManager libraryManager,
|
||||
IUserManager userManager,
|
||||
IUserDataManager userDataRepo,
|
||||
IFileSystem fileSystem,
|
||||
IServerConfigurationManager config)
|
||||
{
|
||||
var writtenProviderIds = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
|
@ -524,12 +521,12 @@ namespace MediaBrowser.XbmcMetadata.Savers
|
|||
|
||||
if (item.CommunityRating.HasValue)
|
||||
{
|
||||
writer.WriteElementString("rating", item.CommunityRating.Value.ToString(UsCulture));
|
||||
writer.WriteElementString("rating", item.CommunityRating.Value.ToString(CultureInfo.InvariantCulture));
|
||||
}
|
||||
|
||||
if (item.ProductionYear.HasValue)
|
||||
{
|
||||
writer.WriteElementString("year", item.ProductionYear.Value.ToString(UsCulture));
|
||||
writer.WriteElementString("year", item.ProductionYear.Value.ToString(CultureInfo.InvariantCulture));
|
||||
}
|
||||
|
||||
var forcedSortName = item.ForcedSortName;
|
||||
|
@ -543,14 +540,11 @@ namespace MediaBrowser.XbmcMetadata.Savers
|
|||
writer.WriteElementString("mpaa", item.OfficialRating);
|
||||
}
|
||||
|
||||
var hasAspectRatio = item as IHasAspectRatio;
|
||||
if (hasAspectRatio != null)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(hasAspectRatio.AspectRatio))
|
||||
if (item is IHasAspectRatio hasAspectRatio
|
||||
&& !string.IsNullOrEmpty(hasAspectRatio.AspectRatio))
|
||||
{
|
||||
writer.WriteElementString("aspectratio", hasAspectRatio.AspectRatio);
|
||||
}
|
||||
}
|
||||
|
||||
var tmdbCollection = item.GetProviderId(MetadataProviders.TmdbCollection);
|
||||
|
||||
|
@ -571,6 +565,7 @@ namespace MediaBrowser.XbmcMetadata.Savers
|
|||
{
|
||||
writer.WriteElementString("imdbid", imdb);
|
||||
}
|
||||
|
||||
writtenProviderIds.Add(MetadataProviders.Imdb.ToString());
|
||||
}
|
||||
|
||||
|
@ -607,12 +602,18 @@ namespace MediaBrowser.XbmcMetadata.Savers
|
|||
|
||||
if (item is MusicArtist)
|
||||
{
|
||||
writer.WriteElementString("formed", item.PremiereDate.Value.ToLocalTime().ToString(formatString));
|
||||
writer.WriteElementString(
|
||||
"formed",
|
||||
item.PremiereDate.Value.ToLocalTime().ToString(formatString));
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.WriteElementString("premiered", item.PremiereDate.Value.ToLocalTime().ToString(formatString));
|
||||
writer.WriteElementString("releasedate", item.PremiereDate.Value.ToLocalTime().ToString(formatString));
|
||||
writer.WriteElementString(
|
||||
"premiered",
|
||||
item.PremiereDate.Value.ToLocalTime().ToString(formatString));
|
||||
writer.WriteElementString(
|
||||
"releasedate",
|
||||
item.PremiereDate.Value.ToLocalTime().ToString(formatString));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -622,18 +623,20 @@ namespace MediaBrowser.XbmcMetadata.Savers
|
|||
{
|
||||
var formatString = options.ReleaseDateFormat;
|
||||
|
||||
writer.WriteElementString("enddate", item.EndDate.Value.ToLocalTime().ToString(formatString));
|
||||
writer.WriteElementString(
|
||||
"enddate",
|
||||
item.EndDate.Value.ToLocalTime().ToString(formatString));
|
||||
}
|
||||
}
|
||||
|
||||
if (item.CriticRating.HasValue)
|
||||
{
|
||||
writer.WriteElementString("criticrating", item.CriticRating.Value.ToString(UsCulture));
|
||||
writer.WriteElementString(
|
||||
"criticrating",
|
||||
item.CriticRating.Value.ToString(CultureInfo.InvariantCulture));
|
||||
}
|
||||
|
||||
var hasDisplayOrder = item as IHasDisplayOrder;
|
||||
|
||||
if (hasDisplayOrder != null)
|
||||
if (item is IHasDisplayOrder hasDisplayOrder)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(hasDisplayOrder.DisplayOrder))
|
||||
{
|
||||
|
@ -648,7 +651,9 @@ 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(CultureInfo.InvariantCulture));
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(item.Tagline))
|
||||
|
@ -756,9 +761,9 @@ namespace MediaBrowser.XbmcMetadata.Savers
|
|||
try
|
||||
{
|
||||
var tagName = GetTagForProviderKey(providerKey);
|
||||
//logger.LogDebug("Verifying custom provider tagname {0}", tagName);
|
||||
Logger.LogDebug("Verifying custom provider tagname {0}", tagName);
|
||||
XmlConvert.VerifyName(tagName);
|
||||
//logger.LogDebug("Saving custom provider tagname {0}", tagName);
|
||||
Logger.LogDebug("Saving custom provider tagname {0}", tagName);
|
||||
|
||||
writer.WriteElementString(GetTagForProviderKey(providerKey), providerId);
|
||||
}
|
||||
|
@ -783,8 +788,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);
|
||||
}
|
||||
|
@ -866,29 +870,43 @@ namespace MediaBrowser.XbmcMetadata.Savers
|
|||
|
||||
var userdata = userDataRepo.GetUserData(user, item);
|
||||
|
||||
writer.WriteElementString("isuserfavorite", userdata.IsFavorite.ToString(CultureInfo.InvariantCulture).ToLowerInvariant());
|
||||
writer.WriteElementString(
|
||||
"isuserfavorite",
|
||||
userdata.IsFavorite.ToString(CultureInfo.InvariantCulture).ToLowerInvariant());
|
||||
|
||||
if (userdata.Rating.HasValue)
|
||||
{
|
||||
writer.WriteElementString("userrating", userdata.Rating.Value.ToString(CultureInfo.InvariantCulture).ToLowerInvariant());
|
||||
writer.WriteElementString(
|
||||
"userrating",
|
||||
userdata.Rating.Value.ToString(CultureInfo.InvariantCulture).ToLowerInvariant());
|
||||
}
|
||||
|
||||
if (!item.IsFolder)
|
||||
{
|
||||
writer.WriteElementString("playcount", userdata.PlayCount.ToString(UsCulture));
|
||||
writer.WriteElementString("watched", userdata.Played.ToString(CultureInfo.InvariantCulture).ToLowerInvariant());
|
||||
writer.WriteElementString(
|
||||
"playcount",
|
||||
userdata.PlayCount.ToString(CultureInfo.InvariantCulture));
|
||||
writer.WriteElementString(
|
||||
"watched",
|
||||
userdata.Played.ToString(CultureInfo.InvariantCulture).ToLowerInvariant());
|
||||
|
||||
if (userdata.LastPlayedDate.HasValue)
|
||||
{
|
||||
writer.WriteElementString("lastplayed", userdata.LastPlayedDate.Value.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss").ToLowerInvariant());
|
||||
writer.WriteElementString(
|
||||
"lastplayed",
|
||||
userdata.LastPlayedDate.Value.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss").ToLowerInvariant());
|
||||
}
|
||||
|
||||
writer.WriteStartElement("resume");
|
||||
|
||||
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(CultureInfo.InvariantCulture));
|
||||
writer.WriteElementString(
|
||||
"total",
|
||||
TimeSpan.FromTicks(runTimeTicks).TotalSeconds.ToString(CultureInfo.InvariantCulture));
|
||||
}
|
||||
|
||||
writer.WriteEndElement();
|
||||
|
@ -922,24 +940,21 @@ namespace MediaBrowser.XbmcMetadata.Savers
|
|||
|
||||
if (person.SortOrder.HasValue)
|
||||
{
|
||||
writer.WriteElementString("sortorder", person.SortOrder.Value.ToString(UsCulture));
|
||||
writer.WriteElementString(
|
||||
"sortorder",
|
||||
person.SortOrder.Value.ToString(CultureInfo.InvariantCulture));
|
||||
}
|
||||
|
||||
if (saveImagePath)
|
||||
{
|
||||
try
|
||||
{
|
||||
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)
|
||||
{
|
||||
// Already logged in core
|
||||
writer.WriteElementString(
|
||||
"thumb",
|
||||
GetImagePathToSave(image, libraryManager, config));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -958,11 +973,10 @@ namespace MediaBrowser.XbmcMetadata.Savers
|
|||
}
|
||||
|
||||
private bool IsPersonType(PersonInfo person, string type)
|
||||
{
|
||||
return string.Equals(person.Type, type, StringComparison.OrdinalIgnoreCase) || string.Equals(person.Role, type, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
=> string.Equals(person.Type, type, StringComparison.OrdinalIgnoreCase)
|
||||
|| string.Equals(person.Role, type, StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
private void AddCustomTags(string path, List<string> xmlTagsUsed, XmlWriter writer, ILogger logger, IFileSystem fileSystem)
|
||||
private void AddCustomTags(string path, List<string> xmlTagsUsed, XmlWriter writer, ILogger logger)
|
||||
{
|
||||
var settings = new XmlReaderSettings()
|
||||
{
|
||||
|
@ -982,7 +996,7 @@ namespace MediaBrowser.XbmcMetadata.Savers
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError(ex, "Error reading existing xml tags from {path}.", path);
|
||||
logger.LogError(ex, "Error reading existing xml tags from {Path}.", path);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -995,7 +1009,8 @@ 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 +1028,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)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user