Add test for generic nfo provider id parsing

This commit is contained in:
David Ullmer 2021-02-09 11:19:19 +01:00
parent 995b370017
commit 086254821f
9 changed files with 38 additions and 21 deletions

View File

@ -721,20 +721,6 @@ namespace MediaBrowser.XbmcMetadata.Parsers
break; break;
} }
case "musicBrainzArtistID":
{
if (reader.IsEmptyElement)
{
reader.Read();
break;
}
var id = reader.ReadElementContentAsString();
item.SetProviderId(MetadataProvider.MusicBrainzArtist.ToString(), id);
break;
}
default: default:
string readerName = reader.Name; string readerName = reader.Name;
if (_validProviderIds.TryGetValue(readerName, out string? providerIdValue)) if (_validProviderIds.TryGetValue(readerName, out string? providerIdValue))

View File

@ -31,6 +31,7 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="../../MediaBrowser.XbmcMetadata/MediaBrowser.XbmcMetadata.csproj" /> <ProjectReference Include="../../MediaBrowser.XbmcMetadata/MediaBrowser.XbmcMetadata.csproj" />
<ProjectReference Include="../../MediaBrowser.Providers/MediaBrowser.Providers.csproj" />
</ItemGroup> </ItemGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">

View File

@ -7,6 +7,7 @@ using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.Entities; using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Providers; using MediaBrowser.Model.Providers;
using MediaBrowser.Providers.Movies;
using MediaBrowser.XbmcMetadata.Parsers; using MediaBrowser.XbmcMetadata.Parsers;
using Microsoft.Extensions.Logging.Abstractions; using Microsoft.Extensions.Logging.Abstractions;
using Moq; using Moq;
@ -23,8 +24,13 @@ namespace Jellyfin.XbmcMetadata.Tests.Parsers
public EpisodeNfoProviderTests() public EpisodeNfoProviderTests()
{ {
var providerManager = new Mock<IProviderManager>(); var providerManager = new Mock<IProviderManager>();
var imdbExternalId = new ImdbExternalId();
var externalIdInfo = new ExternalIdInfo(imdbExternalId.ProviderName, imdbExternalId.Key, imdbExternalId.Type, imdbExternalId.UrlFormatString);
providerManager.Setup(x => x.GetExternalIdInfos(It.IsAny<IHasProviderIds>())) providerManager.Setup(x => x.GetExternalIdInfos(It.IsAny<IHasProviderIds>()))
.Returns(Enumerable.Empty<ExternalIdInfo>()); .Returns(new[] { externalIdInfo });
var config = new Mock<IConfigurationManager>(); var config = new Mock<IConfigurationManager>();
config.Setup(x => x.GetConfiguration(It.IsAny<string>())) config.Setup(x => x.GetConfiguration(It.IsAny<string>()))
.Returns(new XbmcMetadataOptions()); .Returns(new XbmcMetadataOptions());
@ -56,6 +62,8 @@ namespace Jellyfin.XbmcMetadata.Tests.Parsers
Assert.Equal(2017, item.ProductionYear); Assert.Equal(2017, item.ProductionYear);
Assert.Single(item.Studios); Assert.Single(item.Studios);
Assert.Contains("Starz", item.Studios); Assert.Contains("Starz", item.Studios);
Assert.Equal("tt5017734", item.ProviderIds[MetadataProvider.Imdb.ToString()]);
Assert.Equal("1276153", item.ProviderIds[MetadataProvider.Tmdb.ToString()]);
// Credits // Credits
var writers = result.People.Where(x => x.Type == PersonType.Writer).ToArray(); var writers = result.People.Where(x => x.Type == PersonType.Writer).ToArray();

View File

@ -7,6 +7,7 @@ using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.Entities; using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Providers; using MediaBrowser.Model.Providers;
using MediaBrowser.Providers.Plugins.Tmdb.Movies;
using MediaBrowser.XbmcMetadata.Parsers; using MediaBrowser.XbmcMetadata.Parsers;
using Microsoft.Extensions.Logging.Abstractions; using Microsoft.Extensions.Logging.Abstractions;
using Moq; using Moq;
@ -21,8 +22,13 @@ namespace Jellyfin.XbmcMetadata.Tests.Parsers
public MovieNfoParserTests() public MovieNfoParserTests()
{ {
var providerManager = new Mock<IProviderManager>(); var providerManager = new Mock<IProviderManager>();
var tmdbExternalId = new TmdbMovieExternalId();
var externalIdInfo = new ExternalIdInfo(tmdbExternalId.ProviderName, tmdbExternalId.Key, tmdbExternalId.Type, tmdbExternalId.UrlFormatString);
providerManager.Setup(x => x.GetExternalIdInfos(It.IsAny<IHasProviderIds>())) providerManager.Setup(x => x.GetExternalIdInfos(It.IsAny<IHasProviderIds>()))
.Returns(Enumerable.Empty<ExternalIdInfo>()); .Returns(new[] { externalIdInfo });
var config = new Mock<IConfigurationManager>(); var config = new Mock<IConfigurationManager>();
config.Setup(x => x.GetConfiguration(It.IsAny<string>())) config.Setup(x => x.GetConfiguration(It.IsAny<string>()))
.Returns(new XbmcMetadataOptions()); .Returns(new XbmcMetadataOptions());
@ -42,7 +48,8 @@ namespace Jellyfin.XbmcMetadata.Tests.Parsers
Assert.Equal("Justice League", item.OriginalTitle); Assert.Equal("Justice League", item.OriginalTitle);
Assert.Equal("Justice for all.", item.Tagline); Assert.Equal("Justice for all.", item.Tagline);
Assert.Equal("tt0974015", item.ProviderIds["imdb"]); Assert.Equal("tt0974015", item.ProviderIds[MetadataProvider.Imdb.ToString()]);
Assert.Equal("141052", item.ProviderIds[MetadataProvider.Tmdb.ToString()]);
Assert.Equal(4, item.Genres.Length); Assert.Equal(4, item.Genres.Length);
Assert.Contains("Action", item.Genres); Assert.Contains("Action", item.Genres);

View File

@ -9,6 +9,8 @@ using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.Entities; using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Providers; using MediaBrowser.Model.Providers;
using MediaBrowser.Providers.Music;
using MediaBrowser.Providers.Plugins.MusicBrainz;
using MediaBrowser.XbmcMetadata.Parsers; using MediaBrowser.XbmcMetadata.Parsers;
using Microsoft.Extensions.Logging.Abstractions; using Microsoft.Extensions.Logging.Abstractions;
using Moq; using Moq;
@ -23,8 +25,13 @@ namespace Jellyfin.XbmcMetadata.Tests.Parsers
public MusicAlbumNfoProviderTests() public MusicAlbumNfoProviderTests()
{ {
var providerManager = new Mock<IProviderManager>(); var providerManager = new Mock<IProviderManager>();
var musicBrainzArtist = new MusicBrainzArtistExternalId();
var externalIdInfo = new ExternalIdInfo(musicBrainzArtist.ProviderName, musicBrainzArtist.Key, musicBrainzArtist.Type, "MusicBrainzServer");
providerManager.Setup(x => x.GetExternalIdInfos(It.IsAny<IHasProviderIds>())) providerManager.Setup(x => x.GetExternalIdInfos(It.IsAny<IHasProviderIds>()))
.Returns(Enumerable.Empty<ExternalIdInfo>()); .Returns(new[] { externalIdInfo });
var config = new Mock<IConfigurationManager>(); var config = new Mock<IConfigurationManager>();
config.Setup(x => x.GetConfiguration(It.IsAny<string>())) config.Setup(x => x.GetConfiguration(It.IsAny<string>()))
.Returns(new XbmcMetadataOptions()); .Returns(new XbmcMetadataOptions());

View File

@ -7,6 +7,7 @@ using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.Entities; using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Providers; using MediaBrowser.Model.Providers;
using MediaBrowser.Providers.Music;
using MediaBrowser.XbmcMetadata.Parsers; using MediaBrowser.XbmcMetadata.Parsers;
using Microsoft.Extensions.Logging.Abstractions; using Microsoft.Extensions.Logging.Abstractions;
using Moq; using Moq;
@ -21,8 +22,13 @@ namespace Jellyfin.XbmcMetadata.Tests.Parsers
public MusicArtistNfoParserTests() public MusicArtistNfoParserTests()
{ {
var providerManager = new Mock<IProviderManager>(); var providerManager = new Mock<IProviderManager>();
var musicBrainzArtist = new MusicBrainzArtistExternalId();
var externalIdInfo = new ExternalIdInfo(musicBrainzArtist.ProviderName, musicBrainzArtist.Key, musicBrainzArtist.Type, "MusicBrainzServer");
providerManager.Setup(x => x.GetExternalIdInfos(It.IsAny<IHasProviderIds>())) providerManager.Setup(x => x.GetExternalIdInfos(It.IsAny<IHasProviderIds>()))
.Returns(Enumerable.Empty<ExternalIdInfo>()); .Returns(new[] { externalIdInfo });
var config = new Mock<IConfigurationManager>(); var config = new Mock<IConfigurationManager>();
config.Setup(x => x.GetConfiguration(It.IsAny<string>())) config.Setup(x => x.GetConfiguration(It.IsAny<string>()))
.Returns(new XbmcMetadataOptions()); .Returns(new XbmcMetadataOptions());

View File

@ -43,8 +43,8 @@ namespace Jellyfin.XbmcMetadata.Tests.Parsers
Assert.Equal("American Gods", item.OriginalTitle); Assert.Equal("American Gods", item.OriginalTitle);
Assert.Equal(string.Empty, item.Tagline); Assert.Equal(string.Empty, item.Tagline);
Assert.Equal(0, item.RunTimeTicks); Assert.Equal(0, item.RunTimeTicks);
Assert.Equal("46639", item.ProviderIds["tmdb"]); Assert.Equal("46639", item.ProviderIds[MetadataProvider.Tmdb.ToString()]);
Assert.Equal("253573", item.ProviderIds["tvdb"]); Assert.Equal("253573", item.ProviderIds[MetadataProvider.Tvdb.ToString()]);
Assert.Equal(3, item.Genres.Length); Assert.Equal(3, item.Genres.Length);
Assert.Contains("Drama", item.Genres); Assert.Contains("Drama", item.Genres);

View File

@ -30,6 +30,7 @@
<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> <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> <tagline>Justice for all.</tagline>
<runtime>120</runtime> <runtime>120</runtime>
<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>
<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>
<thumb aspect="set.clearlogo" preview="https://assets.fanart.tv/preview/movies/468551/hdmovielogo/justice-league-collection-5ba855ed4239a.png">https://assets.fanart.tv/fanart/movies/468551/hdmovielogo/justice-league-collection-5ba855ed4239a.png</thumb> <thumb aspect="set.clearlogo" preview="https://assets.fanart.tv/preview/movies/468551/hdmovielogo/justice-league-collection-5ba855ed4239a.png">https://assets.fanart.tv/fanart/movies/468551/hdmovielogo/justice-league-collection-5ba855ed4239a.png</thumb>

View File

@ -24,6 +24,7 @@
<lastplayed></lastplayed> <lastplayed></lastplayed>
<id>1276153</id> <id>1276153</id>
<uniqueid type="tmdb" default="true">1276153</uniqueid> <uniqueid type="tmdb" default="true">1276153</uniqueid>
<imdbId>tt5017734</imdbId>
<genre>Drama</genre> <genre>Drama</genre>
<genre>Mystery</genre> <genre>Mystery</genre>
<genre>Sci-Fi &amp; Fantasy</genre> <genre>Sci-Fi &amp; Fantasy</genre>