Merge remote-tracking branch 'jellyfin/master' into nfo-tests

This commit is contained in:
David 2021-02-15 12:00:51 +01:00
commit 9379f535c2
26 changed files with 312 additions and 91 deletions

View File

@ -60,7 +60,7 @@ namespace Emby.Naming.TV
bool supportSpecialAliases,
bool supportNumericSeasonFolders)
{
var filename = Path.GetFileName(path) ?? string.Empty;
string filename = Path.GetFileName(path);
if (supportSpecialAliases)
{

View File

@ -31,7 +31,6 @@ namespace MediaBrowser.Common.Json
WriteIndented = false,
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
NumberHandling = JsonNumberHandling.AllowReadingFromString,
PropertyNameCaseInsensitive = true,
Converters =
{
new JsonGuidConverter(),

View File

@ -254,7 +254,7 @@ namespace MediaBrowser.Model.Configuration
/// Gets or sets the preferred metadata language.
/// </summary>
/// <value>The preferred metadata language.</value>
public string PreferredMetadataLanguage { get; set; } = string.Empty;
public string PreferredMetadataLanguage { get; set; } = "en";
/// <summary>
/// Gets or sets the metadata country code.

View File

@ -12,6 +12,7 @@ using System.Xml;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Entities;
using MediaBrowser.XbmcMetadata.Configuration;
@ -24,20 +25,31 @@ namespace MediaBrowser.XbmcMetadata.Parsers
where T : BaseItem
{
private readonly IConfigurationManager _config;
private readonly IUserManager _userManager;
private readonly IUserDataManager _userDataManager;
private Dictionary<string, string> _validProviderIds;
/// <summary>
/// Initializes a new instance of the <see cref="BaseNfoParser{T}" /> class.
/// </summary>
/// <param name="logger">The logger.</param>
/// <param name="config">the configuration manager.</param>
/// <param name="providerManager">The provider manager.</param>
public BaseNfoParser(ILogger logger, IConfigurationManager config, IProviderManager providerManager)
/// <param name="logger">Instance of the <see cref="ILogger"/> interface.</param>
/// <param name="config">Instance of the <see cref="IConfigurationManager"/> interface.</param>
/// <param name="providerManager">Instance of the <see cref="IProviderManager"/> interface.</param>
/// <param name="userManager">Instance of the <see cref="IUserManager"/> interface.</param>
/// <param name="userDataManager">Instance of the <see cref="IUserDataManager"/> interface.</param>
public BaseNfoParser(
ILogger logger,
IConfigurationManager config,
IProviderManager providerManager,
IUserManager userManager,
IUserDataManager userDataManager)
{
Logger = logger;
_config = config;
ProviderManager = providerManager;
_validProviderIds = new Dictionary<string, string>();
_userManager = userManager;
_userDataManager = userDataManager;
}
protected CultureInfo UsCulture { get; } = new CultureInfo("en-US");
@ -261,6 +273,14 @@ namespace MediaBrowser.XbmcMetadata.Parsers
{
var item = itemResult.Item;
var nfoConfiguration = _config.GetNfoConfiguration();
UserItemData? userData = null;
if (!string.IsNullOrWhiteSpace(nfoConfiguration.UserId))
{
var user = _userManager.GetUserById(Guid.Parse(nfoConfiguration.UserId));
userData = _userDataManager.GetUserData(user, item);
}
switch (reader.Name)
{
// DateCreated
@ -355,6 +375,50 @@ namespace MediaBrowser.XbmcMetadata.Parsers
break;
}
case "watched":
{
var val = reader.ReadElementContentAsBoolean();
if (userData != null)
{
userData.Played = val;
}
break;
}
case "playcount":
{
var val = reader.ReadElementContentAsString();
if (!string.IsNullOrWhiteSpace(val) && userData != null)
{
if (int.TryParse(val, NumberStyles.Integer, UsCulture, out var count))
{
userData.PlayCount = count;
}
}
break;
}
case "lastplayed":
{
var val = reader.ReadElementContentAsString();
if (!string.IsNullOrWhiteSpace(val) && userData != null)
{
if (DateTime.TryParse(val, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal, out var added))
{
userData.LastPlayedDate = added.ToUniversalTime();
}
else
{
Logger.LogWarning("Invalid lastplayed value found: {Value}", val);
}
}
break;
}
case "countrycode":
{
var val = reader.ReadElementContentAsString();
@ -622,7 +686,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers
case "premiered":
case "releasedate":
{
var formatString = _config.GetNfoConfiguration().ReleaseDateFormat;
var formatString = nfoConfiguration.ReleaseDateFormat;
var val = reader.ReadElementContentAsString();
@ -640,7 +704,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers
case "enddate":
{
var formatString = _config.GetNfoConfiguration().ReleaseDateFormat;
var formatString = nfoConfiguration.ReleaseDateFormat;
var val = reader.ReadElementContentAsString();

View File

@ -6,6 +6,7 @@ using System.Threading;
using System.Xml;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Providers;
using Microsoft.Extensions.Logging;
@ -19,11 +20,18 @@ namespace MediaBrowser.XbmcMetadata.Parsers
/// <summary>
/// Initializes a new instance of the <see cref="EpisodeNfoParser"/> class.
/// </summary>
/// <param name="logger">The logger.</param>
/// <param name="config">the configuration manager.</param>
/// <param name="providerManager">The provider manager.</param>
public EpisodeNfoParser(ILogger logger, IConfigurationManager config, IProviderManager providerManager)
: base(logger, config, providerManager)
/// <param name="logger">Instance of the <see cref="ILogger{BaseNfoParser}"/> interface.</param>
/// <param name="config">Instance of the <see cref="IConfigurationManager"/> interface.</param>
/// <param name="providerManager">Instance of the <see cref="IProviderManager"/> interface.</param>
/// <param name="userManager">Instance of the <see cref="IUserManager"/> interface.</param>
/// <param name="userDataManager">Instance of the <see cref="IUserDataManager"/> interface.</param>
public EpisodeNfoParser(
ILogger logger,
IConfigurationManager config,
IProviderManager providerManager,
IUserManager userManager,
IUserDataManager userDataManager)
: base(logger, config, providerManager, userManager, userDataManager)
{
}

View File

@ -5,6 +5,7 @@ using System.Xml;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Movies;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Entities;
using Microsoft.Extensions.Logging;
@ -19,11 +20,18 @@ namespace MediaBrowser.XbmcMetadata.Parsers
/// <summary>
/// Initializes a new instance of the <see cref="MovieNfoParser"/> class.
/// </summary>
/// <param name="logger">The logger.</param>
/// <param name="config">the configuration manager.</param>
/// <param name="providerManager">The provider manager.</param>
public MovieNfoParser(ILogger logger, IConfigurationManager config, IProviderManager providerManager)
: base(logger, config, providerManager)
/// <param name="logger">Instance of the <see cref="ILogger"/> interface.</param>
/// <param name="config">Instance of the <see cref="IConfigurationManager"/> interface.</param>
/// <param name="providerManager">Instance of the <see cref="IProviderManager"/> interface.</param>
/// <param name="userManager">Instance of the <see cref="IUserManager"/> interface.</param>
/// <param name="userDataManager">Instance of the <see cref="IUserDataManager"/> interface.</param>
public MovieNfoParser(
ILogger logger,
IConfigurationManager config,
IProviderManager providerManager,
IUserManager userManager,
IUserDataManager userDataManager)
: base(logger, config, providerManager, userManager, userDataManager)
{
}

View File

@ -2,6 +2,7 @@ using System.Globalization;
using System.Xml;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Providers;
using Microsoft.Extensions.Logging;
@ -15,11 +16,18 @@ namespace MediaBrowser.XbmcMetadata.Parsers
/// <summary>
/// Initializes a new instance of the <see cref="SeasonNfoParser"/> class.
/// </summary>
/// <param name="logger">The logger.</param>
/// <param name="config">the configuration manager.</param>
/// <param name="providerManager">The provider manager.</param>
public SeasonNfoParser(ILogger logger, IConfigurationManager config, IProviderManager providerManager)
: base(logger, config, providerManager)
/// <param name="logger">Instance of the <see cref="ILogger"/> interface.</param>
/// <param name="config">Instance of the <see cref="IConfigurationManager"/> interface.</param>
/// <param name="providerManager">Instance of the <see cref="IProviderManager"/> interface.</param>
/// <param name="userManager">Instance of the <see cref="IUserManager"/> interface.</param>
/// <param name="userDataManager">Instance of the <see cref="IUserDataManager"/> interface.</param>
public SeasonNfoParser(
ILogger logger,
IConfigurationManager config,
IProviderManager providerManager,
IUserManager userManager,
IUserDataManager userDataManager)
: base(logger, config, providerManager, userManager, userDataManager)
{
}

View File

@ -17,11 +17,18 @@ namespace MediaBrowser.XbmcMetadata.Parsers
/// <summary>
/// Initializes a new instance of the <see cref="SeriesNfoParser"/> class.
/// </summary>
/// <param name="logger">The logger.</param>
/// <param name="config">the configuration manager.</param>
/// <param name="providerManager">The provider manager.</param>
public SeriesNfoParser(ILogger logger, IConfigurationManager config, IProviderManager providerManager)
: base(logger, config, providerManager)
/// <param name="logger">Instance of the <see cref="ILogger"/> interface.</param>
/// <param name="config">Instance of the <see cref="IConfigurationManager"/> interface.</param>
/// <param name="providerManager">Instance of the <see cref="IProviderManager"/> interface.</param>
/// <param name="userManager">Instance of the <see cref="IUserManager"/> interface.</param>
/// <param name="userDataManager">Instance of the <see cref="IUserDataManager"/> interface.</param>
public SeriesNfoParser(
ILogger logger,
IConfigurationManager config,
IProviderManager providerManager,
IUserManager userManager,
IUserDataManager userDataManager)
: base(logger, config, providerManager, userManager, userDataManager)
{
}

View File

@ -2,6 +2,7 @@ using System.IO;
using System.Threading;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.IO;
using MediaBrowser.XbmcMetadata.Parsers;
@ -17,30 +18,38 @@ namespace MediaBrowser.XbmcMetadata.Providers
private readonly ILogger<AlbumNfoProvider> _logger;
private readonly IConfigurationManager _config;
private readonly IProviderManager _providerManager;
private readonly IUserManager _userManager;
private readonly IUserDataManager _userDataManager;
/// <summary>
/// Initializes a new instance of the <see cref="AlbumNfoProvider"/> class.
/// </summary>
/// <param name="logger">The logger.</param>
/// <param name="fileSystem">The file system.</param>
/// <param name="config">the configuration manager.</param>
/// <param name="providerManager">The provider manager.</param>
/// <param name="logger">Instance of the <see cref="ILogger{AlbumNfoProvider}"/> interface.</param>
/// <param name="fileSystem">Instance of the <see cref="IFileSystem"/> interface.</param>
/// <param name="config">Instance of the <see cref="IConfigurationManager"/> interface.</param>
/// <param name="providerManager">Instance of the <see cref="IProviderManager"/> interface.</param>
/// <param name="userManager">Instance of the <see cref="IUserManager"/> interface.</param>
/// <param name="userDataManager">Instance of the <see cref="IUserDataManager"/> interface.</param>
public AlbumNfoProvider(
ILogger<AlbumNfoProvider> logger,
IFileSystem fileSystem,
IConfigurationManager config,
IProviderManager providerManager)
IProviderManager providerManager,
IUserManager userManager,
IUserDataManager userDataManager)
: base(fileSystem)
{
_logger = logger;
_config = config;
_providerManager = providerManager;
_userManager = userManager;
_userDataManager = userDataManager;
}
/// <inheritdoc />
protected override void Fetch(MetadataResult<MusicAlbum> result, string path, CancellationToken cancellationToken)
{
new BaseNfoParser<MusicAlbum>(_logger, _config, _providerManager).Fetch(result, path, cancellationToken);
new BaseNfoParser<MusicAlbum>(_logger, _config, _providerManager, _userManager, _userDataManager).Fetch(result, path, cancellationToken);
}
/// <inheritdoc />

View File

@ -2,6 +2,7 @@ using System.IO;
using System.Threading;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.IO;
using MediaBrowser.XbmcMetadata.Parsers;
@ -17,30 +18,38 @@ namespace MediaBrowser.XbmcMetadata.Providers
private readonly ILogger<ArtistNfoProvider> _logger;
private readonly IConfigurationManager _config;
private readonly IProviderManager _providerManager;
private readonly IUserManager _userManager;
private readonly IUserDataManager _userDataManager;
/// <summary>
/// Initializes a new instance of the <see cref="ArtistNfoProvider"/> class.
/// </summary>
/// <param name="logger">The logger.</param>
/// <param name="fileSystem">The file system.</param>
/// <param name="config">the configuration manager.</param>
/// <param name="providerManager">The provider manager.</param>
/// <param name="logger">Instance of the <see cref="ILogger{ArtistNfoProvider}"/> interface.</param>
/// <param name="fileSystem">Instance of the <see cref="IFileSystem"/> interface.</param>
/// <param name="config">Instance of the <see cref="IConfigurationManager"/> interface.</param>
/// <param name="providerManager">Instance of the <see cref="IProviderManager"/> interface.</param>
/// <param name="userManager">Instance of the <see cref="IUserManager"/> interface.</param>
/// <param name="userDataManager">Instance of the <see cref="IUserDataManager"/> interface.</param>
public ArtistNfoProvider(
IFileSystem fileSystem,
ILogger<ArtistNfoProvider> logger,
IConfigurationManager config,
IProviderManager providerManager)
IProviderManager providerManager,
IUserManager userManager,
IUserDataManager userDataManager)
: base(fileSystem)
{
_logger = logger;
_config = config;
_providerManager = providerManager;
_userManager = userManager;
_userDataManager = userDataManager;
}
/// <inheritdoc />
protected override void Fetch(MetadataResult<MusicArtist> result, string path, CancellationToken cancellationToken)
{
new BaseNfoParser<MusicArtist>(_logger, _config, _providerManager).Fetch(result, path, cancellationToken);
new BaseNfoParser<MusicArtist>(_logger, _config, _providerManager, _userManager, _userDataManager).Fetch(result, path, cancellationToken);
}
/// <inheritdoc />

View File

@ -4,6 +4,7 @@ using System.Linq;
using System.Threading;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.IO;
using MediaBrowser.XbmcMetadata.Parsers;
@ -18,17 +19,23 @@ namespace MediaBrowser.XbmcMetadata.Providers
private readonly ILogger<BaseVideoNfoProvider<T>> _logger;
private readonly IConfigurationManager _config;
private readonly IProviderManager _providerManager;
private readonly IUserManager _userManager;
private readonly IUserDataManager _userDataManager;
public BaseVideoNfoProvider(
ILogger<BaseVideoNfoProvider<T>> logger,
IFileSystem fileSystem,
IConfigurationManager config,
IProviderManager providerManager)
IProviderManager providerManager,
IUserManager userManager,
IUserDataManager userDataManager)
: base(fileSystem)
{
_logger = logger;
_config = config;
_providerManager = providerManager;
_userManager = userManager;
_userDataManager = userDataManager;
}
/// <inheritdoc />
@ -38,7 +45,7 @@ namespace MediaBrowser.XbmcMetadata.Providers
{
Item = result.Item
};
new MovieNfoParser(_logger, _config, _providerManager).Fetch(tmpItem, path, cancellationToken);
new MovieNfoParser(_logger, _config, _providerManager, _userManager, _userDataManager).Fetch(tmpItem, path, cancellationToken);
result.Item = (T)tmpItem.Item;
result.People = tmpItem.People;

View File

@ -2,6 +2,7 @@ using System.IO;
using System.Threading;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.IO;
using MediaBrowser.XbmcMetadata.Parsers;
@ -17,30 +18,38 @@ namespace MediaBrowser.XbmcMetadata.Providers
private readonly ILogger<EpisodeNfoProvider> _logger;
private readonly IConfigurationManager _config;
private readonly IProviderManager _providerManager;
private readonly IUserManager _userManager;
private readonly IUserDataManager _userDataManager;
/// <summary>
/// Initializes a new instance of the <see cref="EpisodeNfoProvider"/> class.
/// </summary>
/// <param name="logger">The logger.</param>
/// <param name="fileSystem">The file system.</param>
/// <param name="config">the configuration manager.</param>
/// <param name="providerManager">The provider manager.</param>
/// <param name="logger">Instance of the <see cref="ILogger{EpisodeNfoProvider}"/> interface.</param>
/// <param name="fileSystem">Instance of the <see cref="IFileSystem"/> interface.</param>
/// <param name="config">Instance of the <see cref="IConfigurationManager"/> interface.</param>
/// <param name="providerManager">Instance of the <see cref="IProviderManager"/> interface.</param>
/// <param name="userManager">Instance of the <see cref="IUserManager"/> interface.</param>
/// <param name="userDataManager">Instance of the <see cref="IUserDataManager"/> interface.</param>
public EpisodeNfoProvider(
ILogger<EpisodeNfoProvider> logger,
IFileSystem fileSystem,
IConfigurationManager config,
IProviderManager providerManager)
IProviderManager providerManager,
IUserManager userManager,
IUserDataManager userDataManager)
: base(fileSystem)
{
_logger = logger;
_config = config;
_providerManager = providerManager;
_userManager = userManager;
_userDataManager = userDataManager;
}
/// <inheritdoc />
protected override void Fetch(MetadataResult<Episode> result, string path, CancellationToken cancellationToken)
{
new EpisodeNfoParser(_logger, _config, _providerManager).Fetch(result, path, cancellationToken);
new EpisodeNfoParser(_logger, _config, _providerManager, _userManager, _userDataManager).Fetch(result, path, cancellationToken);
}
/// <inheritdoc />

View File

@ -1,5 +1,6 @@
using MediaBrowser.Common.Configuration;
using MediaBrowser.Controller.Entities.Movies;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.IO;
using Microsoft.Extensions.Logging;
@ -14,16 +15,20 @@ namespace MediaBrowser.XbmcMetadata.Providers
/// <summary>
/// Initializes a new instance of the <see cref="MovieNfoProvider"/> class.
/// </summary>
/// <param name="logger">The logger.</param>
/// <param name="fileSystem">The file system.</param>
/// <param name="config">the configuration manager.</param>
/// <param name="providerManager">The provider manager.</param>
/// <param name="logger">Instance of the <see cref="ILogger{MovieNfoProvider}"/> interface.</param>
/// <param name="fileSystem">Instance of the <see cref="IFileSystem"/> interface.</param>
/// <param name="config">Instance of the <see cref="IConfigurationManager"/> interface.</param>
/// <param name="providerManager">Instance of the <see cref="IProviderManager"/> interface.</param>
/// <param name="userManager">Instance of the <see cref="IUserManager"/> interface.</param>
/// <param name="userDataManager">Instance of the <see cref="IUserDataManager"/> interface.</param>
public MovieNfoProvider(
ILogger<MovieNfoProvider> logger,
IFileSystem fileSystem,
IConfigurationManager config,
IProviderManager providerManager)
: base(logger, fileSystem, config, providerManager)
IProviderManager providerManager,
IUserManager userManager,
IUserDataManager userDataManager)
: base(logger, fileSystem, config, providerManager, userManager, userDataManager)
{
}
}

View File

@ -1,5 +1,6 @@
using MediaBrowser.Common.Configuration;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.IO;
using Microsoft.Extensions.Logging;
@ -14,12 +15,20 @@ namespace MediaBrowser.XbmcMetadata.Providers
/// <summary>
/// Initializes a new instance of the <see cref="MusicVideoNfoProvider"/> class.
/// </summary>
/// <param name="logger">The logger.</param>
/// <param name="fileSystem">The file system.</param>
/// <param name="config">the configuration manager.</param>
/// <param name="providerManager">The provider manager.</param>
public MusicVideoNfoProvider(ILogger<MusicVideoNfoProvider> logger, IFileSystem fileSystem, IConfigurationManager config, IProviderManager providerManager)
: base(logger, fileSystem, config, providerManager)
/// <param name="logger">Instance of the <see cref="ILogger{SeasonNfoProvider}"/> interface.</param>
/// <param name="fileSystem">Instance of the <see cref="IFileSystem"/> interface.</param>
/// <param name="config">Instance of the <see cref="IConfigurationManager"/> interface.</param>
/// <param name="providerManager">Instance of the <see cref="IProviderManager"/> interface.</param>
/// <param name="userManager">Instance of the <see cref="IUserManager"/> interface.</param>
/// <param name="userDataManager">Instance of the <see cref="IUserDataManager"/> interface.</param>
public MusicVideoNfoProvider(
ILogger<MusicVideoNfoProvider> logger,
IFileSystem fileSystem,
IConfigurationManager config,
IProviderManager providerManager,
IUserManager userManager,
IUserDataManager userDataManager)
: base(logger, fileSystem, config, providerManager, userManager, userDataManager)
{
}
}

View File

@ -2,6 +2,7 @@ using System.IO;
using System.Threading;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.IO;
using MediaBrowser.XbmcMetadata.Parsers;
@ -17,30 +18,38 @@ namespace MediaBrowser.XbmcMetadata.Providers
private readonly ILogger<SeasonNfoProvider> _logger;
private readonly IConfigurationManager _config;
private readonly IProviderManager _providerManager;
private readonly IUserManager _userManager;
private readonly IUserDataManager _userDataManager;
/// <summary>
/// Initializes a new instance of the <see cref="SeasonNfoProvider"/> class.
/// </summary>
/// <param name="logger">The logger.</param>
/// <param name="fileSystem">The file system.</param>
/// <param name="config">the configuration manager.</param>
/// <param name="providerManager">The provider manager.</param>
/// <param name="logger">Instance of the <see cref="ILogger{SeasonNfoProvider}"/> interface.</param>
/// <param name="fileSystem">Instance of the <see cref="IFileSystem"/> interface.</param>
/// <param name="config">Instance of the <see cref="IConfigurationManager"/> interface.</param>
/// <param name="providerManager">Instance of the <see cref="IProviderManager"/> interface.</param>
/// <param name="userManager">Instance of the <see cref="IUserManager"/> interface.</param>
/// <param name="userDataManager">Instance of the <see cref="IUserDataManager"/> interface.</param>
public SeasonNfoProvider(
ILogger<SeasonNfoProvider> logger,
IFileSystem fileSystem,
IConfigurationManager config,
IProviderManager providerManager)
IProviderManager providerManager,
IUserManager userManager,
IUserDataManager userDataManager)
: base(fileSystem)
{
_logger = logger;
_config = config;
_providerManager = providerManager;
_userManager = userManager;
_userDataManager = userDataManager;
}
/// <inheritdoc />
protected override void Fetch(MetadataResult<Season> result, string path, CancellationToken cancellationToken)
{
new SeasonNfoParser(_logger, _config, _providerManager).Fetch(result, path, cancellationToken);
new SeasonNfoParser(_logger, _config, _providerManager, _userManager, _userDataManager).Fetch(result, path, cancellationToken);
}
/// <inheritdoc />

View File

@ -2,6 +2,7 @@ using System.IO;
using System.Threading;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.IO;
using MediaBrowser.XbmcMetadata.Parsers;
@ -17,30 +18,38 @@ namespace MediaBrowser.XbmcMetadata.Providers
private readonly ILogger<SeriesNfoProvider> _logger;
private readonly IConfigurationManager _config;
private readonly IProviderManager _providerManager;
private readonly IUserManager _userManager;
private readonly IUserDataManager _userDataManager;
/// <summary>
/// Initializes a new instance of the <see cref="SeriesNfoProvider"/> class.
/// </summary>
/// <param name="logger">The logger.</param>
/// <param name="fileSystem">The file system.</param>
/// <param name="config">the configuration manager.</param>
/// <param name="providerManager">The provider manager.</param>
/// <param name="logger">Instance of the <see cref="ILogger{SeriesNfoProvider}"/> interface.</param>
/// <param name="fileSystem">Instance of the <see cref="IFileSystem"/> interface.</param>
/// <param name="config">Instance of the <see cref="IConfigurationManager"/> interface.</param>
/// <param name="providerManager">Instance of the <see cref="IProviderManager"/> interface.</param>
/// <param name="userManager">Instance of the <see cref="IUserManager"/> interface.</param>
/// <param name="userDataManager">Instance of the <see cref="IUserDataManager"/> interface.</param>
public SeriesNfoProvider(
ILogger<SeriesNfoProvider> logger,
IFileSystem fileSystem,
IConfigurationManager config,
IProviderManager providerManager)
IProviderManager providerManager,
IUserManager userManager,
IUserDataManager userDataManager)
: base(fileSystem)
{
_logger = logger;
_config = config;
_providerManager = providerManager;
_userManager = userManager;
_userDataManager = userDataManager;
}
/// <inheritdoc />
protected override void Fetch(MetadataResult<Series> result, string path, CancellationToken cancellationToken)
{
new SeriesNfoParser(_logger, _config, _providerManager).Fetch(result, path, cancellationToken);
new SeriesNfoParser(_logger, _config, _providerManager, _userManager, _userDataManager).Fetch(result, path, cancellationToken);
}
/// <inheritdoc />

View File

@ -1,5 +1,6 @@
using MediaBrowser.Common.Configuration;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.IO;
using Microsoft.Extensions.Logging;
@ -14,12 +15,20 @@ namespace MediaBrowser.XbmcMetadata.Providers
/// <summary>
/// Initializes a new instance of the <see cref="VideoNfoProvider"/> class.
/// </summary>
/// <param name="logger">The logger.</param>
/// <param name="fileSystem">The file system.</param>
/// <param name="config">the configuration manager.</param>
/// <param name="providerManager">The provider manager.</param>
public VideoNfoProvider(ILogger<VideoNfoProvider> logger, IFileSystem fileSystem, IConfigurationManager config, IProviderManager providerManager)
: base(logger, fileSystem, config, providerManager)
/// <param name="logger">Instance of the <see cref="ILogger{VideoNfoProvider}"/> interface.</param>
/// <param name="fileSystem">Instance of the <see cref="IFileSystem"/> interface.</param>
/// <param name="config">Instance of the <see cref="IConfigurationManager"/> interface.</param>
/// <param name="providerManager">Instance of the <see cref="IProviderManager"/> interface.</param>
/// <param name="userManager">Instance of the <see cref="IUserManager"/> interface.</param>
/// <param name="userDataManager">Instance of the <see cref="IUserDataManager"/> interface.</param>
public VideoNfoProvider(
ILogger<VideoNfoProvider> logger,
IFileSystem fileSystem,
IConfigurationManager config,
IProviderManager providerManager,
IUserManager userManager,
IUserDataManager userDataManager)
: base(logger, fileSystem, config, providerManager, userManager, userDataManager)
{
}
}

View File

@ -3,6 +3,7 @@ using System.Linq;
using System.Threading;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.Entities;
@ -34,7 +35,10 @@ namespace Jellyfin.XbmcMetadata.Tests.Parsers
var config = new Mock<IConfigurationManager>();
config.Setup(x => x.GetConfiguration(It.IsAny<string>()))
.Returns(new XbmcMetadataOptions());
_parser = new EpisodeNfoParser(new NullLogger<EpisodeNfoParser>(), config.Object, providerManager.Object);
var user = new Mock<IUserManager>();
var userData = new Mock<IUserDataManager>();
_parser = new EpisodeNfoParser(new NullLogger<EpisodeNfoParser>(), config.Object, providerManager.Object, user.Object, userData.Object);
}
[Fact]

View File

@ -1,9 +1,11 @@
using System;
using System.Linq;
using System.Threading;
using Jellyfin.Data.Entities;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Movies;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.Entities;
@ -19,9 +21,13 @@ namespace Jellyfin.XbmcMetadata.Tests.Parsers
public class MovieNfoParserTests
{
private readonly MovieNfoParser _parser;
private readonly IUserDataManager _userDataManager;
private readonly User _testUser;
public MovieNfoParserTests()
{
_testUser = new User("Test User", "Auth provider", "Reset provider");
var providerManager = new Mock<IProviderManager>();
var tmdbExternalId = new TmdbMovieExternalId();
@ -30,10 +36,24 @@ namespace Jellyfin.XbmcMetadata.Tests.Parsers
providerManager.Setup(x => x.GetExternalIdInfos(It.IsAny<IHasProviderIds>()))
.Returns(new[] { externalIdInfo });
var config = new Mock<IConfigurationManager>();
config.Setup(x => x.GetConfiguration(It.IsAny<string>()))
.Returns(new XbmcMetadataOptions());
_parser = new MovieNfoParser(new NullLogger<MovieNfoParser>(), config.Object, providerManager.Object);
var nfoConfig = new XbmcMetadataOptions()
{
UserId = "F38E6443-090B-4F7A-BD12-9CFF5020F7BC"
};
var configManager = new Mock<IConfigurationManager>();
configManager.Setup(x => x.GetConfiguration(It.IsAny<string>()))
.Returns(nfoConfig);
var user = new Mock<IUserManager>();
user.Setup(x => x.GetUserById(It.IsAny<Guid>()))
.Returns(_testUser);
var userData = new Mock<IUserDataManager>();
userData.Setup(x => x.GetUserData(_testUser, It.IsAny<BaseItem>()))
.Returns(new UserItemData());
_userDataManager = userData.Object;
_parser = new MovieNfoParser(new NullLogger<MovieNfoParser>(), configManager.Object, providerManager.Object, user.Object, userData.Object);
}
[Fact]
@ -105,6 +125,12 @@ namespace Jellyfin.XbmcMetadata.Tests.Parsers
Assert.Equal(new DateTime(2019, 8, 6, 9, 1, 18), item.DateCreated);
// userData
var userData = _userDataManager.GetUserData(_testUser, item);
Assert.Equal(2, userData.PlayCount);
Assert.True(userData.Played);
Assert.Equal(new DateTime(2021, 02, 11, 07, 47, 23), userData.LastPlayedDate);
// Movie set
Assert.Equal("702342", item.ProviderIds[MetadataProvider.TmdbCollection.ToString()]);
Assert.Equal("Justice League Collection", item.CollectionName);

View File

@ -5,6 +5,7 @@ using System.Linq;
using System.Threading;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.Entities;
@ -35,7 +36,10 @@ namespace Jellyfin.XbmcMetadata.Tests.Parsers
var config = new Mock<IConfigurationManager>();
config.Setup(x => x.GetConfiguration(It.IsAny<string>()))
.Returns(new XbmcMetadataOptions());
_parser = new BaseNfoParser<MusicAlbum>(new NullLogger<BaseNfoParser<MusicAlbum>>(), config.Object, providerManager.Object);
var user = new Mock<IUserManager>();
var userData = new Mock<IUserDataManager>();
_parser = new BaseNfoParser<MusicAlbum>(new NullLogger<BaseNfoParser<MusicAlbum>>(), config.Object, providerManager.Object, user.Object, userData.Object);
}
[Fact]

View File

@ -3,6 +3,7 @@ using System.Linq;
using System.Threading;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.Entities;
@ -32,7 +33,10 @@ namespace Jellyfin.XbmcMetadata.Tests.Parsers
var config = new Mock<IConfigurationManager>();
config.Setup(x => x.GetConfiguration(It.IsAny<string>()))
.Returns(new XbmcMetadataOptions());
_parser = new BaseNfoParser<MusicArtist>(new NullLogger<BaseNfoParser<MusicArtist>>(), config.Object, providerManager.Object);
var user = new Mock<IUserManager>();
var userData = new Mock<IUserDataManager>();
_parser = new BaseNfoParser<MusicArtist>(new NullLogger<BaseNfoParser<MusicArtist>>(), config.Object, providerManager.Object, user.Object, userData.Object);
}
[Fact]

View File

@ -3,6 +3,7 @@ using System.Linq;
using System.Threading;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.Entities;
@ -26,7 +27,11 @@ namespace Jellyfin.XbmcMetadata.Tests.Parsers
var config = new Mock<IConfigurationManager>();
config.Setup(x => x.GetConfiguration(It.IsAny<string>()))
.Returns(new XbmcMetadataOptions());
_parser = new MovieNfoParser(new NullLogger<BaseNfoParser<MusicVideo>>(), config.Object, providerManager.Object);
var user = new Mock<IUserManager>();
var userData = new Mock<IUserDataManager>();
_parser = new MovieNfoParser(new NullLogger<BaseNfoParser<MusicVideo>>(), config.Object, providerManager.Object, user.Object, userData.Object);
}
[Fact]

View File

@ -5,6 +5,7 @@ using System.Linq;
using System.Threading;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.Entities;
@ -28,7 +29,10 @@ namespace Jellyfin.XbmcMetadata.Tests.Parsers
var config = new Mock<IConfigurationManager>();
config.Setup(x => x.GetConfiguration(It.IsAny<string>()))
.Returns(new XbmcMetadataOptions());
_parser = new SeasonNfoParser(new NullLogger<SeasonNfoParser>(), config.Object, providerManager.Object);
var user = new Mock<IUserManager>();
var userData = new Mock<IUserDataManager>();
_parser = new SeasonNfoParser(new NullLogger<SeasonNfoParser>(), config.Object, providerManager.Object, user.Object, userData.Object);
}
[Fact]

View File

@ -3,6 +3,7 @@ using System.Linq;
using System.Threading;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.Entities;
@ -26,7 +27,10 @@ namespace Jellyfin.XbmcMetadata.Tests.Parsers
var config = new Mock<IConfigurationManager>();
config.Setup(x => x.GetConfiguration(It.IsAny<string>()))
.Returns(new XbmcMetadataOptions());
_parser = new SeriesNfoParser(new NullLogger<SeriesNfoParser>(), config.Object, providerManager.Object);
var user = new Mock<IUserManager>();
var userData = new Mock<IUserDataManager>();
_parser = new SeriesNfoParser(new NullLogger<SeriesNfoParser>(), config.Object, providerManager.Object, user.Object, userData.Object);
}
[Fact]

View File

@ -35,6 +35,9 @@
<plot>Fueled by his restored faith in humanity and inspired by Superman&apos;s selfless act, Bruce Wayne enlists the help of his newfound ally, Diana Prince, to face an even greater enemy. Together, Batman and Wonder Woman work quickly to find and recruit a team of meta-humans to stand against this newly awakened threat. But despite the formation of this unprecedented league of heroes-Batman, Wonder Woman, Aquaman, Cyborg and The Flash-it may already be too late to save the planet from an assault of catastrophic proportions.</plot>
<tagline>Justice for all.</tagline>
<runtime>120</runtime>
<playcount>2</playcount>
<watched>true</watched>
<lastplayed>2021-02-11 07:47:23</lastplayed>
<tmdbId>141052</tmdbId>
<thumb aspect="set.poster" preview="https://assets.fanart.tv/preview/movies/468551/movieposter/justice-league-collection-5c24ea65591d3.jpg">https://assets.fanart.tv/fanart/movies/468551/movieposter/justice-league-collection-5c24ea65591d3.jpg</thumb>
<thumb aspect="set.poster" preview="https://assets.fanart.tv/preview/movies/468551/movieposter/justice-league-collection-5c24ea65591d3.jpg">https://assets.fanart.tv/fanart/movies/468551/movieposter/justice-league-collection-5c24ea65591d3.jpg</thumb>
@ -87,8 +90,6 @@
<thumb preview="https://assets.fanart.tv/preview/movies/141052/moviebackground/justice-league-5a119394ea362.jpg">https://assets.fanart.tv/fanart/movies/141052/moviebackground/justice-league-5a119394ea362.jpg</thumb>
</fanart>
<mpaa>Australia:M</mpaa>
<playcount>0</playcount>
<lastplayed></lastplayed>
<id>tt0974015</id>
<uniqueid type="imdb" default="true">tt0974015</uniqueid>
<genre>Action</genre>