From 454d82c52ca884649cf62e5a583a601225a844ec Mon Sep 17 00:00:00 2001 From: David Date: Sat, 23 Jan 2021 18:06:26 +0100 Subject: [PATCH 1/2] Process actor type in nfo files --- .../Parsers/BaseNfoParser.cs | 39 +++++++++++++++++++ .../Parsers/MovieNfoParserTests.cs | 6 ++- .../Test Data/Justice League.nfo | 5 +++ 3 files changed, 49 insertions(+), 1 deletion(-) diff --git a/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs b/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs index f2d0bdc545..a230127167 100644 --- a/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs +++ b/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs @@ -1030,6 +1030,45 @@ namespace MediaBrowser.XbmcMetadata.Parsers break; } + case "type": + { + var val = reader.ReadElementContentAsString(); + + if (!string.IsNullOrWhiteSpace(val)) + { + switch (val) + { + case PersonType.Composer: + type = PersonType.Composer; + break; + case PersonType.Conductor: + type = PersonType.Conductor; + break; + case PersonType.Director: + type = PersonType.Director; + break; + case PersonType.Lyricist: + type = PersonType.Lyricist; + break; + case PersonType.Producer: + type = PersonType.Producer; + break; + case PersonType.Writer: + type = PersonType.Writer; + break; + case PersonType.GuestStar: + type = PersonType.GuestStar; + break; + // unknown type --> actor + default: + type = PersonType.Actor; + break; + } + } + + break; + } + case "order": case "sortorder": { diff --git a/tests/Jellyfin.XbmcMetadata.Tests/Parsers/MovieNfoParserTests.cs b/tests/Jellyfin.XbmcMetadata.Tests/Parsers/MovieNfoParserTests.cs index e1f50876fb..765464eced 100644 --- a/tests/Jellyfin.XbmcMetadata.Tests/Parsers/MovieNfoParserTests.cs +++ b/tests/Jellyfin.XbmcMetadata.Tests/Parsers/MovieNfoParserTests.cs @@ -60,7 +60,7 @@ namespace Jellyfin.XbmcMetadata.Tests.Parsers Assert.Equal(new TimeSpan(0, 0, 6268).Ticks, item.RunTimeTicks); Assert.True(item.HasSubtitles); - Assert.Equal(18, result.People.Count); + Assert.Equal(19, result.People.Count); var writers = result.People.Where(x => x.Type == PersonType.Writer).ToArray(); Assert.Equal(2, writers.Length); @@ -82,6 +82,10 @@ namespace Jellyfin.XbmcMetadata.Tests.Parsers Assert.Equal(5, aquaman!.SortOrder); Assert.Equal("https://m.media-amazon.com/images/M/MV5BMTI5MTU5NjM1MV5BMl5BanBnXkFtZTcwODc4MDk0Mw@@._V1_SX1024_SY1024_.jpg", aquaman!.ImageUrl); + var lyricist = result.People.FirstOrDefault(x => x.Type == PersonType.Lyricist); + Assert.NotNull(lyricist); + Assert.Equal("Test Lyricist", lyricist!.Name); + Assert.Equal(new DateTime(2019, 8, 6, 9, 1, 18), item.DateCreated); } diff --git a/tests/Jellyfin.XbmcMetadata.Tests/Test Data/Justice League.nfo b/tests/Jellyfin.XbmcMetadata.Tests/Test Data/Justice League.nfo index f838af8d04..6e6da25d30 100644 --- a/tests/Jellyfin.XbmcMetadata.Tests/Test Data/Justice League.nfo +++ b/tests/Jellyfin.XbmcMetadata.Tests/Test Data/Justice League.nfo @@ -221,6 +221,11 @@ 14 https://m.media-amazon.com/images/M/MV5BOTFjOTFhNTgtZjk3Ny00MTNjLWE3MWUtMWI3ZWM5NDljZjQwXkEyXkFqcGdeQXVyMjQwMDg0Ng@@._V1_SX1024_SY1024_.jpg + + Test Lyricist + Lyricist + 15 + 0.000000 0.000000 From 39f9a7981a48d939b1ca2dd742ef9051e7bf9598 Mon Sep 17 00:00:00 2001 From: David Ullmer Date: Sun, 24 Jan 2021 13:35:08 +0100 Subject: [PATCH 2/2] Update MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs Co-authored-by: Cody Robibero --- .../Parsers/BaseNfoParser.cs | 36 ++++++------------- 1 file changed, 10 insertions(+), 26 deletions(-) diff --git a/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs b/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs index a230127167..f889327e0e 100644 --- a/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs +++ b/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs @@ -1036,34 +1036,18 @@ namespace MediaBrowser.XbmcMetadata.Parsers if (!string.IsNullOrWhiteSpace(val)) { - switch (val) + type = val switch { - case PersonType.Composer: - type = PersonType.Composer; - break; - case PersonType.Conductor: - type = PersonType.Conductor; - break; - case PersonType.Director: - type = PersonType.Director; - break; - case PersonType.Lyricist: - type = PersonType.Lyricist; - break; - case PersonType.Producer: - type = PersonType.Producer; - break; - case PersonType.Writer: - type = PersonType.Writer; - break; - case PersonType.GuestStar: - type = PersonType.GuestStar; - break; + PersonType.Composer => PersonType.Composer, + PersonType.Conductor => PersonType.Conductor, + PersonType.Director => PersonType.Director, + PersonType.Lyricist => PersonType.Lyricist, + PersonType.Producer => PersonType.Producer, + PersonType.Writer => PersonType.Writer, + PersonType.GuestStar => PersonType.GuestStar, // unknown type --> actor - default: - type = PersonType.Actor; - break; - } + _ => PersonType.Actor + }; } break;