From fc59c9c284e18c013d7cf3ca15674fbf04c6d28a Mon Sep 17 00:00:00 2001 From: Jason Dove Date: Sat, 12 Jun 2021 11:14:27 -0500 Subject: [PATCH] include all content ratings in xmltv (#256) --- CHANGELOG.md | 2 ++ .../Emby/EmbyTelevisionLibraryScanner.cs | 5 +++-- ErsatzTV.Core/Iptv/ChannelGuide.cs | 16 +++++++++++----- .../Jellyfin/JellyfinTelevisionLibraryScanner.cs | 5 +++-- ErsatzTV.sln.DotSettings | 1 + 5 files changed, 20 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 499b7be9f..27fe70ac2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,9 +11,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Changed - Remove framerate normalization; it caused more problems than it solved +- Include non-US (and unknown) content ratings in XMLTV ### Fixed - Fix serving channels.m3u with missing content ratings +- Fix percent progress indicator for Jellyfin and Emby show library scans ## [0.0.44-prealpha] - 2021-06-09 ### Added diff --git a/ErsatzTV.Core/Emby/EmbyTelevisionLibraryScanner.cs b/ErsatzTV.Core/Emby/EmbyTelevisionLibraryScanner.cs index 592caed9d..5bfd0ce64 100644 --- a/ErsatzTV.Core/Emby/EmbyTelevisionLibraryScanner.cs +++ b/ErsatzTV.Core/Emby/EmbyTelevisionLibraryScanner.cs @@ -115,9 +115,10 @@ namespace ErsatzTV.Core.Emby List existingShows, List shows) { - foreach (EmbyShow incoming in shows.OrderBy(s => s.ShowMetadata.Head().Title)) + var sortedShows = shows.OrderBy(s => s.ShowMetadata.Head().Title).ToList(); + foreach (EmbyShow incoming in sortedShows) { - decimal percentCompletion = (decimal) shows.IndexOf(incoming) / shows.Count; + decimal percentCompletion = (decimal) sortedShows.IndexOf(incoming) / shows.Count; await _mediator.Publish(new LibraryScanProgress(library.Id, percentCompletion)); Option maybeExisting = existingShows.Find(ie => ie.ItemId == incoming.ItemId); diff --git a/ErsatzTV.Core/Iptv/ChannelGuide.cs b/ErsatzTV.Core/Iptv/ChannelGuide.cs index 48e1da3de..6378d25db 100644 --- a/ErsatzTV.Core/Iptv/ChannelGuide.cs +++ b/ErsatzTV.Core/Iptv/ChannelGuide.cs @@ -215,7 +215,11 @@ namespace ErsatzTV.Core.Iptv foreach (ContentRating rating in contentRating) { xml.WriteStartElement("rating"); - xml.WriteAttributeString("system", rating.System); + foreach (string system in rating.System) + { + xml.WriteAttributeString("system", system); + } + xml.WriteStartElement("value"); xml.WriteString(rating.Value); xml.WriteEndElement(); // value @@ -354,15 +358,17 @@ namespace ErsatzTV.Core.Iptv first => { string[] split = first.Split(':'); - if (split.Length == 2 && split[0].ToLowerInvariant() == "us") + if (split.Length == 2) { - return new ContentRating(system, split[1].ToUpperInvariant()); + return split[0].ToLowerInvariant() == "us" + ? new ContentRating(system, split[1].ToUpperInvariant()) + : new ContentRating(None, split[1].ToUpperInvariant()); } - return None; + return new ContentRating(None, first); }).Flatten(); } - private record ContentRating(string System, string Value); + private record ContentRating(Option System, string Value); } } diff --git a/ErsatzTV.Core/Jellyfin/JellyfinTelevisionLibraryScanner.cs b/ErsatzTV.Core/Jellyfin/JellyfinTelevisionLibraryScanner.cs index fde8bb6bb..c1c26a431 100644 --- a/ErsatzTV.Core/Jellyfin/JellyfinTelevisionLibraryScanner.cs +++ b/ErsatzTV.Core/Jellyfin/JellyfinTelevisionLibraryScanner.cs @@ -115,9 +115,10 @@ namespace ErsatzTV.Core.Jellyfin List existingShows, List shows) { - foreach (JellyfinShow incoming in shows.OrderBy(s => s.ShowMetadata.Head().Title)) + var sortedShows = shows.OrderBy(s => s.ShowMetadata.Head().Title).ToList(); + foreach (JellyfinShow incoming in sortedShows) { - decimal percentCompletion = (decimal) shows.IndexOf(incoming) / shows.Count; + decimal percentCompletion = (decimal) sortedShows.IndexOf(incoming) / shows.Count; await _mediator.Publish(new LibraryScanProgress(library.Id, percentCompletion)); Option maybeExisting = existingShows.Find(ie => ie.ItemId == incoming.ItemId); diff --git a/ErsatzTV.sln.DotSettings b/ErsatzTV.sln.DotSettings index 5347e21ca..9493040e0 100644 --- a/ErsatzTV.sln.DotSettings +++ b/ErsatzTV.sln.DotSettings @@ -49,5 +49,6 @@ True True True + True True True \ No newline at end of file