From 7885167f547dfa3f73aec22996c0e22b65dbd84f Mon Sep 17 00:00:00 2001 From: David Ullmer Date: Tue, 8 Feb 2022 09:08:35 +0100 Subject: [PATCH 1/3] Fix nfo thumb tags without aspect --- MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs b/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs index 0071018681..09ff84044d 100644 --- a/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs +++ b/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs @@ -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 itemResult) + private void FetchThumbNode(XmlReader reader, MetadataResult 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 From fdfcb45c2aee2febfa428e339dc3cad7a221066e Mon Sep 17 00:00:00 2001 From: David Ullmer Date: Tue, 8 Feb 2022 09:09:33 +0100 Subject: [PATCH 2/3] Add regression test for #7285 --- .../Parsers/EpisodeNfoProviderTests.cs | 14 ++++++++ .../Test Data/Sonarr-Thumb.nfo | 34 +++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 tests/Jellyfin.XbmcMetadata.Tests/Test Data/Sonarr-Thumb.nfo diff --git a/tests/Jellyfin.XbmcMetadata.Tests/Parsers/EpisodeNfoProviderTests.cs b/tests/Jellyfin.XbmcMetadata.Tests/Parsers/EpisodeNfoProviderTests.cs index 3e726f23d9..073214083f 100644 --- a/tests/Jellyfin.XbmcMetadata.Tests/Parsers/EpisodeNfoProviderTests.cs +++ b/tests/Jellyfin.XbmcMetadata.Tests/Parsers/EpisodeNfoProviderTests.cs @@ -122,6 +122,20 @@ namespace Jellyfin.XbmcMetadata.Tests.Parsers Assert.Equal(2004, item.ProductionYear); } + [Fact] + public void Parse_GivenFileWithThumbWithoutAspect_Success() + { + var result = new MetadataResult() + { + 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() { diff --git a/tests/Jellyfin.XbmcMetadata.Tests/Test Data/Sonarr-Thumb.nfo b/tests/Jellyfin.XbmcMetadata.Tests/Test Data/Sonarr-Thumb.nfo new file mode 100644 index 0000000000..fb86768ef8 --- /dev/null +++ b/tests/Jellyfin.XbmcMetadata.Tests/Test Data/Sonarr-Thumb.nfo @@ -0,0 +1,34 @@ + + Sometimes a Genius's Every Action Is at the Mercy of X + 1 + 8 + 2019-05-26 + 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. + 4289 + https://artworks.thetvdb.com/banners/episodes/359095/7081317.jpg + false + + + + + + English + + + + From a00e6ff426daa46c4042bc8449516667ae66c524 Mon Sep 17 00:00:00 2001 From: David Ullmer Date: Wed, 9 Feb 2022 13:39:39 +0100 Subject: [PATCH 3/3] Update tests/Jellyfin.XbmcMetadata.Tests/Parsers/EpisodeNfoProviderTests.cs Co-authored-by: Claus Vium --- .../Parsers/EpisodeNfoProviderTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Jellyfin.XbmcMetadata.Tests/Parsers/EpisodeNfoProviderTests.cs b/tests/Jellyfin.XbmcMetadata.Tests/Parsers/EpisodeNfoProviderTests.cs index 073214083f..4f4ae5afb9 100644 --- a/tests/Jellyfin.XbmcMetadata.Tests/Parsers/EpisodeNfoProviderTests.cs +++ b/tests/Jellyfin.XbmcMetadata.Tests/Parsers/EpisodeNfoProviderTests.cs @@ -125,7 +125,7 @@ namespace Jellyfin.XbmcMetadata.Tests.Parsers [Fact] public void Parse_GivenFileWithThumbWithoutAspect_Success() { - var result = new MetadataResult() + var result = new MetadataResult { Item = new Episode() };