Merge pull request #7286 from daullmer/sonarr-thumb

This commit is contained in:
Bond-009 2022-02-09 19:09:53 +01:00 committed by GitHub
commit bb7916767c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 57 additions and 4 deletions

View File

@ -778,7 +778,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers
case "thumb":
{
FetchThumbNode(reader, itemResult);
FetchThumbNode(reader, itemResult, "thumb");
break;
}
@ -796,7 +796,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers
break;
}
FetchThumbNode(subtree, itemResult);
FetchThumbNode(subtree, itemResult, "fanart");
break;
}
@ -819,17 +819,22 @@ namespace MediaBrowser.XbmcMetadata.Parsers
}
}
private void FetchThumbNode(XmlReader reader, MetadataResult<T> itemResult)
private void FetchThumbNode(XmlReader reader, MetadataResult<T> itemResult, string parentNode)
{
var artType = reader.GetAttribute("aspect");
var val = reader.ReadElementContentAsString();
// artType is null if the thumb node is a child of the fanart tag
// -> set image type to fanart
if (string.IsNullOrWhiteSpace(artType))
if (string.IsNullOrWhiteSpace(artType) && parentNode.Equals("fanart", StringComparison.Ordinal))
{
artType = "fanart";
}
else if (string.IsNullOrWhiteSpace(artType))
{
// Sonarr writes thumb tags for posters without aspect property
artType = "poster";
}
// skip:
// - empty uri

View File

@ -122,6 +122,20 @@ namespace Jellyfin.XbmcMetadata.Tests.Parsers
Assert.Equal(2004, item.ProductionYear);
}
[Fact]
public void Parse_GivenFileWithThumbWithoutAspect_Success()
{
var result = new MetadataResult<Episode>
{
Item = new Episode()
};
_parser.Fetch(result, "Test Data/Sonarr-Thumb.nfo", CancellationToken.None);
Assert.Single(result.RemoteImages.Where(x => x.Type == ImageType.Primary));
Assert.Equal("https://artworks.thetvdb.com/banners/episodes/359095/7081317.jpg", result.RemoteImages.First(x => x.Type == ImageType.Primary).Url);
}
[Fact]
public void Fetch_WithNullItem_ThrowsArgumentException()
{

View File

@ -0,0 +1,34 @@
<episodedetails>
<title>Sometimes a Genius's Every Action Is at the Mercy of X</title>
<season>1</season>
<episode>8</episode>
<aired>2019-05-26</aired>
<plot>After Nariyuki wins a smartphone in a lottery, he can't wait to use it for apps like the dictionary, schedule managing, and the like. He also learns that studying in the bathtub is effective and quickly puts the method into practice.</plot>
<uniqueid type="sonarr" default="true">4289</uniqueid>
<thumb>https://artworks.thetvdb.com/banners/episodes/359095/7081317.jpg</thumb>
<watched>false</watched>
<fileinfo>
<streamdetails>
<video>
<aspect>1.77777779</aspect>
<bitrate>2208901</bitrate>
<codec>x265</codec>
<framerate>23.976</framerate>
<height>1080</height>
<scantype></scantype>
<width>1920</width>
<duration>23.683416666666666</duration>
<durationinseconds>1421</durationinseconds>
</video>
<audio>
<bitrate>1468567</bitrate>
<channels>2</channels>
<codec>FLAC</codec>
<language>Japanese / Japanese</language>
</audio>
<subtitle>
<language>English</language>
</subtitle>
</streamdetails>
</fileinfo>
</episodedetails>