diff --git a/CHANGELOG.md b/CHANGELOG.md index 210334e37..572d43ab6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [Unreleased] +### Added +- Include `Series` category tag for all episodes in XMLTV +- Include movie, episode (show) genres as `category` tags in XMLTV ## [0.4.0-alpha] - 2022-01-29 ### Fixed diff --git a/ErsatzTV.Core/Iptv/ChannelGuide.cs b/ErsatzTV.Core/Iptv/ChannelGuide.cs index 3db54c818..8a6c1decd 100644 --- a/ErsatzTV.Core/Iptv/ChannelGuide.cs +++ b/ErsatzTV.Core/Iptv/ChannelGuide.cs @@ -9,7 +9,6 @@ using ErsatzTV.Core.Domain.Filler; using ErsatzTV.Core.Emby; using ErsatzTV.Core.Jellyfin; using LanguageExt; -using LanguageExt.UnsafeValueAccess; using Serilog; using static LanguageExt.Prelude; @@ -158,15 +157,20 @@ namespace ErsatzTV.Core.Iptv xml.WriteString(metadata.Year.Value.ToString()); xml.WriteEndElement(); // date } - } - xml.WriteStartElement("category"); - xml.WriteAttributeString("lang", "en"); - xml.WriteString("Movie"); - xml.WriteEndElement(); // category + xml.WriteStartElement("category"); + xml.WriteAttributeString("lang", "en"); + xml.WriteString("Movie"); + xml.WriteEndElement(); // category + + foreach (Genre genre in Optional(metadata.Genres).Flatten()) + { + xml.WriteStartElement("category"); + xml.WriteAttributeString("lang", "en"); + xml.WriteString(genre.Name); + xml.WriteEndElement(); // category + } - foreach (MovieMetadata metadata in movie.MovieMetadata.HeadOrNone()) - { string poster = Optional(metadata.Artwork).Flatten() .Filter(a => a.ArtworkKind == ArtworkKind.Poster) .HeadOrNone() @@ -241,9 +245,21 @@ namespace ErsatzTV.Core.Iptv { Option maybeMetadata = Optional(episode.Season?.Show?.ShowMetadata.HeadOrNone()).Flatten(); - if (maybeMetadata.IsSome) + foreach (ShowMetadata metadata in maybeMetadata) { - ShowMetadata metadata = maybeMetadata.ValueUnsafe(); + xml.WriteStartElement("category"); + xml.WriteAttributeString("lang", "en"); + xml.WriteString("Series"); + xml.WriteEndElement(); // category + + foreach (Genre genre in Optional(metadata.Genres).Flatten()) + { + xml.WriteStartElement("category"); + xml.WriteAttributeString("lang", "en"); + xml.WriteString(genre.Name); + xml.WriteEndElement(); // category + } + string artwork = Optional(metadata.Artwork).Flatten() .Filter(a => a.ArtworkKind == ArtworkKind.Thumbnail) .HeadOrNone() diff --git a/ErsatzTV.Infrastructure/Data/Repositories/ChannelRepository.cs b/ErsatzTV.Infrastructure/Data/Repositories/ChannelRepository.cs index cd1495918..5a7cc5eb0 100644 --- a/ErsatzTV.Infrastructure/Data/Repositories/ChannelRepository.cs +++ b/ErsatzTV.Infrastructure/Data/Repositories/ChannelRepository.cs @@ -70,11 +70,23 @@ namespace ErsatzTV.Infrastructure.Data.Repositories .Include(c => c.Playouts) .ThenInclude(p => p.Items) .ThenInclude(i => i.MediaItem) + .ThenInclude(i => (i as Episode).Season) + .ThenInclude(s => s.Show) + .ThenInclude(s => s.ShowMetadata) + .ThenInclude(em => em.Genres) + .Include(c => c.Playouts) + .ThenInclude(p => p.Items) + .ThenInclude(i => i.MediaItem) .ThenInclude(i => (i as Movie).MovieMetadata) .ThenInclude(mm => mm.Artwork) .Include(c => c.Playouts) .ThenInclude(p => p.Items) .ThenInclude(i => i.MediaItem) + .ThenInclude(i => (i as Movie).MovieMetadata) + .ThenInclude(mm => mm.Genres) + .Include(c => c.Playouts) + .ThenInclude(p => p.Items) + .ThenInclude(i => i.MediaItem) .ThenInclude(i => (i as MusicVideo).MusicVideoMetadata) .ThenInclude(mm => mm.Artwork) .Include(c => c.Playouts)