Add episode nfo parser test
This commit is contained in:
parent
0279af5f6b
commit
dbd70bd394
|
@ -208,6 +208,18 @@ namespace MediaBrowser.XbmcMetadata.Parsers
|
|||
break;
|
||||
}
|
||||
|
||||
case "showtitle":
|
||||
{
|
||||
var showtitle = reader.ReadElementContentAsString();
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(showtitle))
|
||||
{
|
||||
item.SeriesName = showtitle;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
base.FetchDataFromXmlNode(reader, itemResult);
|
||||
break;
|
||||
|
|
|
@ -56,6 +56,8 @@ namespace MediaBrowser.XbmcMetadata.Savers
|
|||
{
|
||||
var episode = (Episode)item;
|
||||
|
||||
writer.WriteElementString("showtitle", episode.SeriesName);
|
||||
|
||||
if (episode.IndexNumber.HasValue)
|
||||
{
|
||||
writer.WriteElementString("episode", episode.IndexNumber.Value.ToString(_usCulture));
|
||||
|
@ -122,7 +124,8 @@ namespace MediaBrowser.XbmcMetadata.Savers
|
|||
"airsbefore_episode",
|
||||
"airsbefore_season",
|
||||
"displayseason",
|
||||
"displayepisode"
|
||||
"displayepisode",
|
||||
"showtitle"
|
||||
});
|
||||
|
||||
return list;
|
||||
|
|
|
@ -0,0 +1,103 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using MediaBrowser.Common.Configuration;
|
||||
using MediaBrowser.Controller.Entities.TV;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Model.Configuration;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Providers;
|
||||
using MediaBrowser.XbmcMetadata.Parsers;
|
||||
using Microsoft.Extensions.Logging.Abstractions;
|
||||
using Moq;
|
||||
using Xunit;
|
||||
|
||||
#pragma warning disable CA5369
|
||||
|
||||
namespace Jellyfin.XbmcMetadata.Tests.Parsers
|
||||
{
|
||||
public class EpisodeNfoProviderTests
|
||||
{
|
||||
private readonly EpisodeNfoParser _parser;
|
||||
|
||||
public EpisodeNfoProviderTests()
|
||||
{
|
||||
var providerManager = new Mock<IProviderManager>();
|
||||
providerManager.Setup(x => x.GetExternalIdInfos(It.IsAny<IHasProviderIds>()))
|
||||
.Returns(Enumerable.Empty<ExternalIdInfo>());
|
||||
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);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Fetch_Valid_Succes()
|
||||
{
|
||||
var result = new MetadataResult<Episode>()
|
||||
{
|
||||
Item = new Episode()
|
||||
};
|
||||
|
||||
_parser.Fetch(result, "Test Data/The Bone Orchard.nfo", CancellationToken.None);
|
||||
|
||||
var item = result.Item;
|
||||
Assert.Equal("The Bone Orchard", item.Name);
|
||||
Assert.Equal("American Gods", item.SeriesName);
|
||||
Assert.Equal(1, item.IndexNumber);
|
||||
Assert.Equal(1, item.ParentIndexNumber);
|
||||
Assert.Equal("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.", item.Overview);
|
||||
Assert.Equal(0, item.RunTimeTicks);
|
||||
Assert.Equal("16", item.OfficialRating);
|
||||
Assert.Contains("Drama", item.Genres);
|
||||
Assert.Contains("Mystery", item.Genres);
|
||||
Assert.Contains("Sci-Fi & Fantasy", item.Genres);
|
||||
Assert.Equal(new DateTime(2017, 4, 30), item.PremiereDate);
|
||||
Assert.Equal(2017, item.ProductionYear);
|
||||
Assert.Single(item.Studios);
|
||||
Assert.Contains("Starz", item.Studios);
|
||||
|
||||
// Credits
|
||||
var writers = result.People.Where(x => x.Type == PersonType.Writer).ToArray();
|
||||
Assert.Equal(2, writers.Length);
|
||||
Assert.Contains("Bryan Fuller", writers.Select(x => x.Name));
|
||||
Assert.Contains("Michael Green", writers.Select(x => x.Name));
|
||||
|
||||
// Direcotrs
|
||||
var directors = result.People.Where(x => x.Type == PersonType.Director).ToArray();
|
||||
Assert.Single(directors);
|
||||
Assert.Contains("David Slade", directors.Select(x => x.Name));
|
||||
|
||||
// Actors
|
||||
var actors = result.People.Where(x => x.Type == PersonType.Actor).ToArray();
|
||||
Assert.Equal(11, actors.Length);
|
||||
// Only test one actor
|
||||
var shadow = actors.FirstOrDefault(x => x.Role.Equals("Shadow Moon", StringComparison.Ordinal));
|
||||
Assert.NotNull(shadow);
|
||||
Assert.Equal("Ricky Whittle", shadow!.Name);
|
||||
Assert.Equal(0, shadow!.SortOrder);
|
||||
Assert.Equal("http://image.tmdb.org/t/p/original/cjeDbVfBp6Qvb3C74Dfy7BKDTQN.jpg", shadow!.ImageUrl);
|
||||
|
||||
Assert.Equal(new DateTime(2017, 10, 7, 14, 25, 47), item.DateCreated);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Fetch_WithNullItem_ThrowsArgumentException()
|
||||
{
|
||||
var result = new MetadataResult<Episode>();
|
||||
|
||||
Assert.Throws<ArgumentException>(() => _parser.Fetch(result, "Test Data/The Bone Orchard.nfo", CancellationToken.None));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Fetch_NullResult_ThrowsArgumentException()
|
||||
{
|
||||
var result = new MetadataResult<Episode>()
|
||||
{
|
||||
Item = new Episode()
|
||||
};
|
||||
|
||||
Assert.Throws<ArgumentException>(() => _parser.Fetch(result, string.Empty, CancellationToken.None));
|
||||
}
|
||||
}
|
||||
}
|
111
tests/Jellyfin.XbmcMetadata.Tests/Test Data/The Bone Orchard.nfo
Normal file
111
tests/Jellyfin.XbmcMetadata.Tests/Test Data/The Bone Orchard.nfo
Normal file
|
@ -0,0 +1,111 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||
<episodedetails>
|
||||
<title>The Bone Orchard</title>
|
||||
<showtitle>American Gods</showtitle>
|
||||
<ratings>
|
||||
<rating name="tmdb" max="10" default="true">
|
||||
<value>7.532000</value>
|
||||
<votes>31</votes>
|
||||
</rating>
|
||||
</ratings>
|
||||
<userrating>0</userrating>
|
||||
<top250>0</top250>
|
||||
<season>1</season>
|
||||
<episode>1</episode>
|
||||
<displayseason>-1</displayseason>
|
||||
<displayepisode>-1</displayepisode>
|
||||
<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>
|
||||
<runtime>0</runtime>
|
||||
<thumb>http://image.tmdb.org/t/p/original/uvry4weK00pFLn7fxQ9M4m3Da2A.jpg</thumb>
|
||||
<mpaa>16</mpaa>
|
||||
<playcount>0</playcount>
|
||||
<lastplayed></lastplayed>
|
||||
<id>1276153</id>
|
||||
<uniqueid type="tmdb" default="true">1276153</uniqueid>
|
||||
<genre>Drama</genre>
|
||||
<genre>Mystery</genre>
|
||||
<genre>Sci-Fi & Fantasy</genre>
|
||||
<credits>Bryan Fuller</credits>
|
||||
<credits>Michael Green</credits>
|
||||
<director>David Slade</director>
|
||||
<premiered>2017-04-30</premiered>
|
||||
<year>2017</year>
|
||||
<status></status>
|
||||
<code></code>
|
||||
<aired>2017-04-30</aired>
|
||||
<studio>Starz</studio>
|
||||
<trailer></trailer>
|
||||
<actor>
|
||||
<name>Jonathan Tucker</name>
|
||||
<role>'Low Key' Lyesmith</role>
|
||||
<order>10</order>
|
||||
<thumb>http://image.tmdb.org/t/p/original/jvJpYDbwmUTACw7Yn7PKOP6CdlJ.jpg</thumb>
|
||||
</actor>
|
||||
<actor>
|
||||
<name>Demore Barnes</name>
|
||||
<role>Mr. Ibis</role>
|
||||
<order>11</order>
|
||||
<thumb>http://image.tmdb.org/t/p/original/4rEVzSIFPgiN14xYQnjKcKQ7tYE.jpg</thumb>
|
||||
</actor>
|
||||
<actor>
|
||||
<name>Betty Gilpin</name>
|
||||
<role>Audrey</role>
|
||||
<order>12</order>
|
||||
<thumb>http://image.tmdb.org/t/p/original/xFeqyem5i4Kf0nFjBZ4Oi9NM26k.jpg</thumb>
|
||||
</actor>
|
||||
<actor>
|
||||
<name>Beth Grant</name>
|
||||
<role>Jack</role>
|
||||
<order>13</order>
|
||||
<thumb>http://image.tmdb.org/t/p/original/zAT9GvzJE0ytL3C36L461cgKI9p.jpg</thumb>
|
||||
</actor>
|
||||
<actor>
|
||||
<name>Joel Murray</name>
|
||||
<role>Paunch</role>
|
||||
<order>14</order>
|
||||
<thumb>http://image.tmdb.org/t/p/original/t5syYfCgxbTC7XPrNeXhhhQULUf.jpg</thumb>
|
||||
</actor>
|
||||
<actor>
|
||||
<name>Ricky Whittle</name>
|
||||
<role>Shadow Moon</role>
|
||||
<order>0</order>
|
||||
<thumb>http://image.tmdb.org/t/p/original/cjeDbVfBp6Qvb3C74Dfy7BKDTQN.jpg</thumb>
|
||||
</actor>
|
||||
<actor>
|
||||
<name>Ian McShane</name>
|
||||
<role>Mr. Wednesday</role>
|
||||
<order>1</order>
|
||||
<thumb>http://image.tmdb.org/t/p/original/pY9ud4BJwHekNiO4MMItPbgkdAy.jpg</thumb>
|
||||
</actor>
|
||||
<actor>
|
||||
<name>Emily Browning</name>
|
||||
<role>Laura Moon</role>
|
||||
<order>2</order>
|
||||
<thumb>http://image.tmdb.org/t/p/original/fa1Kyj02wxwcdS6EHb2i27TNXvU.jpg</thumb>
|
||||
</actor>
|
||||
<actor>
|
||||
<name>Pablo Schreiber</name>
|
||||
<role>Mad Sweeney</role>
|
||||
<order>3</order>
|
||||
<thumb>http://image.tmdb.org/t/p/original/uo8YljeePz3pbj7gvWXdB4gOOW4.jpg</thumb>
|
||||
</actor>
|
||||
<actor>
|
||||
<name>Bruce Langley</name>
|
||||
<role>Technical Boy</role>
|
||||
<order>4</order>
|
||||
<thumb>http://image.tmdb.org/t/p/original/f4EOWUmznLqboq8Ce7jnlkHVK3Y.jpg</thumb>
|
||||
</actor>
|
||||
<actor>
|
||||
<name>Yetide Badaki</name>
|
||||
<role>Bilquis</role>
|
||||
<order>5</order>
|
||||
<thumb>http://image.tmdb.org/t/p/original/qfzkREHuI1JvMxBteIAjKX8qMEr.jpg</thumb>
|
||||
</actor>
|
||||
<resume>
|
||||
<position>0.000000</position>
|
||||
<total>0.000000</total>
|
||||
</resume>
|
||||
<dateadded>2017-10-07 14:25:47</dateadded>
|
||||
</episodedetails>
|
Loading…
Reference in New Issue
Block a user