Add more tags to nfo tests

This commit is contained in:
David 2021-02-13 22:41:12 +01:00
parent 34e10622c6
commit eecdc3c110
6 changed files with 78 additions and 10 deletions

View File

@ -56,6 +56,10 @@ namespace Jellyfin.XbmcMetadata.Tests.Parsers
Assert.Equal(2017, item.ProductionYear);
Assert.Single(item.Studios);
Assert.Contains("Starz", item.Studios);
Assert.Equal(1, item.IndexNumberEnd);
Assert.Equal(2, item.AirsAfterSeasonNumber);
Assert.Equal(3, item.AirsBeforeSeasonNumber);
Assert.Equal(1, item.AirsBeforeEpisodeNumber);
// Credits
var writers = result.People.Where(x => x.Type == PersonType.Writer).ToArray();

View File

@ -3,6 +3,7 @@ using System.Linq;
using System.Threading;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Movies;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.Entities;
@ -34,11 +35,11 @@ namespace Jellyfin.XbmcMetadata.Tests.Parsers
{
var result = new MetadataResult<Video>()
{
Item = new Video()
Item = new Movie()
};
_parser.Fetch(result, "Test Data/Justice League.nfo", CancellationToken.None);
var item = result.Item;
var item = (Movie)result.Item;
Assert.Equal("Justice League", item.OriginalTitle);
Assert.Equal("Justice for all.", item.Tagline);
@ -51,22 +52,31 @@ namespace Jellyfin.XbmcMetadata.Tests.Parsers
Assert.Contains("Sci-Fi", item.Genres);
Assert.Equal(new DateTime(2017, 11, 15), item.PremiereDate);
Assert.Equal(new DateTime(2017, 11, 16), item.EndDate);
Assert.Single(item.Studios);
Assert.Contains("DC Comics", item.Studios);
Assert.Equal("1.777778", item.AspectRatio);
Assert.Equal(Video3DFormat.HalfSideBySide, item.Video3DFormat);
Assert.Equal(1920, item.Width);
Assert.Equal(1080, item.Height);
Assert.Equal(new TimeSpan(0, 0, 6268).Ticks, item.RunTimeTicks);
Assert.True(item.HasSubtitles);
Assert.Equal(7.6f, item.CriticRating);
Assert.Equal("8.7", item.CustomRating);
Assert.Equal("en", item.PreferredMetadataLanguage);
Assert.Equal("us", item.PreferredMetadataCountryCode);
Assert.Single(item.RemoteTrailers);
Assert.Equal("https://www.youtube.com/watch?v=dQw4w9WgXcQ", item.RemoteTrailers[0].Url);
Assert.Equal(19, result.People.Count);
Assert.Equal(20, result.People.Count);
var writers = result.People.Where(x => x.Type == PersonType.Writer).ToArray();
Assert.Equal(2, writers.Length);
Assert.Equal(3, writers.Length);
var writerNames = writers.Select(x => x.Name);
Assert.Contains("Jerry Siegel", writerNames);
Assert.Contains("Joe Shuster", writerNames);
Assert.Contains("Test", writerNames);
var directors = result.People.Where(x => x.Type == PersonType.Director).ToArray();
Assert.Single(directors);
@ -87,6 +97,26 @@ namespace Jellyfin.XbmcMetadata.Tests.Parsers
Assert.Equal("Test Lyricist", lyricist!.Name);
Assert.Equal(new DateTime(2019, 8, 6, 9, 1, 18), item.DateCreated);
// Movie set
Assert.Equal("702342", item.ProviderIds[MetadataProvider.TmdbCollection.ToString()]);
Assert.Equal("Justice League Collection", item.CollectionName);
}
[Theory]
[InlineData("Test Data\\Tmdb.nfo", "Tmdb", "30287")]
[InlineData("Test Data\\Imdb.nfo", "Imdb", "tt0944947")]
public void Parse_UrlFile_Success(string path, string provider, string id)
{
var result = new MetadataResult<Video>()
{
Item = new Movie()
};
_parser.Fetch(result, path, CancellationToken.None);
var item = (Movie)result.Item;
Assert.Equal(id, item.ProviderIds[provider]);
}
[Fact]
@ -102,7 +132,7 @@ namespace Jellyfin.XbmcMetadata.Tests.Parsers
{
var result = new MetadataResult<Video>()
{
Item = new Video()
Item = new Movie()
};
Assert.Throws<ArgumentException>(() => _parser.Fetch(result, string.Empty, CancellationToken.None));

View File

@ -45,6 +45,7 @@ namespace Jellyfin.XbmcMetadata.Tests.Parsers
Assert.Equal(0, item.RunTimeTicks);
Assert.Equal("46639", item.ProviderIds["tmdb"]);
Assert.Equal("253573", item.ProviderIds["tvdb"]);
Assert.Equal("tt11111", item.ProviderIds[MetadataProvider.Imdb.ToString()]);
Assert.Equal(3, item.Genres.Length);
Assert.Contains("Drama", item.Genres);
@ -54,6 +55,10 @@ namespace Jellyfin.XbmcMetadata.Tests.Parsers
Assert.Equal(new DateTime(2017, 4, 30), item.PremiereDate);
Assert.Single(item.Studios);
Assert.Contains("Starz", item.Studios);
Assert.Equal("9 PM", item.AirTime);
Assert.Single(item.AirDays);
Assert.Contains(DayOfWeek.Friday, item.AirDays);
Assert.Equal(SeriesStatus.Ended, item.Status);
Assert.Equal(6, result.People.Count);
@ -69,6 +74,21 @@ namespace Jellyfin.XbmcMetadata.Tests.Parsers
Assert.Equal(new DateTime(2017, 10, 7, 14, 25, 47), item.DateCreated);
}
[Theory]
[InlineData("Test Data\\Tvdb.nfo", "Tvdb", "121361")]
public void Parse_UrlFile_Success(string path, string provider, string id)
{
var result = new MetadataResult<Series>()
{
Item = new Series()
};
_parser.Fetch(result, path, CancellationToken.None);
var item = (Series)result.Item;
Assert.Equal(id, item.ProviderIds[provider]);
}
[Fact]
public void Fetch_WithNullItem_ThrowsArgumentException()
{

View File

@ -126,7 +126,7 @@
<episodeguide>
<url cache="tmdb-46639-en.json">http://api.themoviedb.org/3/tv/46639?api_key=6a5be4999abf74eba1f9a8311294c267&amp;language=en</url>
</episodeguide>
<id>46639</id>
<id IMDB="tt11111" TMDB="46639">253573</id>
<uniqueid type="tmdb" default="true">46639</uniqueid>
<uniqueid type="tvdb">253573</uniqueid>
<genre>Drama</genre>
@ -134,7 +134,9 @@
<genre>Sci-Fi &amp; Fantasy</genre>
<premiered>2017-04-30</premiered>
<year>2017</year>
<status></status>
<status>ended</status>
<airs_time>9 PM</airs_time>
<airs_dayofweek>Friday</airs_dayofweek>
<code></code>
<aired></aired>
<studio>Starz</studio>

View File

@ -24,6 +24,11 @@
<votes>119873</votes>
</rating>
</ratings>
<criticrating>7.6</criticrating>
<language>en</language>
<countrycode>us</countrycode>
<customrating>8.7</customrating>
<aspectratio>1.777778</aspectratio>
<userrating>0</userrating>
<top250>0</top250>
<outline>Fueled by his restored faith in humanity and inspired by Superman&apos;s selfless act, Bruce Wayne enlists the help of his new-found ally, Diana Prince, to face an even greater enemy.</outline>
@ -92,20 +97,22 @@
<country>USA</country>
<country>Canada</country>
<country>UK</country>
<set>
<set tmdbcolid="702342">
<name>Justice League Collection</name>
<overview>Based on the DC Comics superhero team</overview>
</set>
<credits>Jerry Siegel</credits>
<credits>Joe Shuster</credits>
<director>Zack Snyder</director>
<director>Zack Snyder,</director>
<writer>Test</writer>
<premiered>2017-11-15</premiered>
<enddate>2017-11-16</enddate>
<year>2017</year>
<status></status>
<code></code>
<aired></aired>
<studio>DC Comics</studio>
<trailer></trailer>
<trailer>plugin://plugin.video.youtube/?action=play_video&amp;videoid=dQw4w9WgXcQ</trailer>
<fileinfo>
<streamdetails>
<video>
@ -115,6 +122,7 @@
<height>1080</height>
<durationinseconds>6268</durationinseconds>
<stereomode></stereomode>
<format3d>HSBS</format3d>
</video>
<audio>
<codec>truehd</codec>

View File

@ -14,6 +14,10 @@
<episode>1</episode>
<displayseason>-1</displayseason>
<displayepisode>-1</displayepisode>
<episodenumberend>1</episodenumberend>
<airsbefore_episode>1</airsbefore_episode>
<airsafter_season>2</airsafter_season>
<airsbefore_season>3</airsbefore_season>
<outline></outline>
<plot>When Shadow Moon is released from prison early after the death of his wife, he meets Mr. Wednesday and is recruited as his bodyguard. Shadow discovers that this may be more than he bargained for.</plot>
<tagline></tagline>