New: Add Episode Guide option for Kodi MetadataFile

Closes #5415
This commit is contained in:
Mark McDowall 2023-02-20 12:35:22 -08:00
parent bbd9b1657d
commit 6740257135
3 changed files with 55 additions and 5 deletions

View File

@ -0,0 +1,35 @@
using System.Text.Json.Serialization;
using NzbDrone.Core.Tv;
namespace NzbDrone.Core.Extras.Metadata.Consumers.Xbmc
{
public class KodiEpisodeGuide
{
[JsonPropertyName("tvdb")]
public string Tvdb { get; set; }
[JsonPropertyName("tvmaze")]
public string TvMaze { get; set; }
[JsonPropertyName("tvrage")]
public string TvRage { get; set; }
[JsonPropertyName("tmdb")]
public string Tmdb { get; set; }
[JsonPropertyName("imdb")]
public string Imdb { get; set; }
public KodiEpisodeGuide()
{
}
public KodiEpisodeGuide(Series series)
{
Tvdb = series.TvdbId.ToString();
TvMaze = series.TvMazeId > 0 ? series.TvMazeId.ToString() : null;
TvRage = series.TvRageId > 0 ? series.TvMazeId.ToString() : null;
Imdb = series.ImdbId;
}
}
}

View File

@ -3,12 +3,14 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.Json;
using System.Text.RegularExpressions;
using System.Xml;
using System.Xml.Linq;
using NLog;
using NzbDrone.Common.Disk;
using NzbDrone.Common.Extensions;
using NzbDrone.Common.Serializer;
using NzbDrone.Core.Extras.Metadata.Files;
using NzbDrone.Core.MediaCover;
using NzbDrone.Core.MediaFiles;
@ -211,6 +213,15 @@ namespace NzbDrone.Core.Extras.Metadata.Consumers.Xbmc
tvShow.Add(xmlActor);
}
if (Settings.SeriesMetadataEpisodeGuide)
{
var episodeGuide = new KodiEpisodeGuide(series);
var serializerSettings = STJson.GetSerializerSettings();
serializerSettings.WriteIndented = false;
tvShow.Add(new XElement("episodeguide", JsonSerializer.Serialize(episodeGuide, serializerSettings)));
}
var doc = new XDocument(tvShow);
doc.Save(xw);

View File

@ -19,6 +19,7 @@ namespace NzbDrone.Core.Extras.Metadata.Consumers.Xbmc
public XbmcMetadataSettings()
{
SeriesMetadata = true;
SeriesMetadataEpisodeGuide = false;
SeriesMetadataUrl = false;
EpisodeMetadata = true;
SeriesImages = true;
@ -29,19 +30,22 @@ namespace NzbDrone.Core.Extras.Metadata.Consumers.Xbmc
[FieldDefinition(0, Label = "Series Metadata", Type = FieldType.Checkbox, Section = MetadataSectionType.Metadata, HelpText = "tvshow.nfo with full series metadata")]
public bool SeriesMetadata { get; set; }
[FieldDefinition(1, Label = "Series Metadata URL", Type = FieldType.Checkbox, Section = MetadataSectionType.Metadata, HelpText = "tvshow.nfo with TheTVDB show URL (can be combined with 'Series Metadata')", Advanced = true)]
[FieldDefinition(1, Label = "Series Metadata Episode Guide", Type = FieldType.Checkbox, Section = MetadataSectionType.Metadata, HelpText = "Include JSON formatted episode guide element in tvshow.nfo (Requires 'Series Metadata')", Advanced = true)]
public bool SeriesMetadataEpisodeGuide { get; set; }
[FieldDefinition(2, Label = "Series Metadata URL", Type = FieldType.Checkbox, Section = MetadataSectionType.Metadata, HelpText = "Include TheTVDB show URL in tvshow.nfo (can be combined with 'Series Metadata')", Advanced = true)]
public bool SeriesMetadataUrl { get; set; }
[FieldDefinition(2, Label = "Episode Metadata", Type = FieldType.Checkbox, Section = MetadataSectionType.Metadata, HelpText = "<filename>.nfo")]
[FieldDefinition(3, Label = "Episode Metadata", Type = FieldType.Checkbox, Section = MetadataSectionType.Metadata, HelpText = "<filename>.nfo")]
public bool EpisodeMetadata { get; set; }
[FieldDefinition(3, Label = "Series Images", Type = FieldType.Checkbox, Section = MetadataSectionType.Image, HelpText = "fanart.jpg, poster.jpg, banner.jpg")]
[FieldDefinition(4, Label = "Series Images", Type = FieldType.Checkbox, Section = MetadataSectionType.Image, HelpText = "fanart.jpg, poster.jpg, banner.jpg")]
public bool SeriesImages { get; set; }
[FieldDefinition(4, Label = "Season Images", Type = FieldType.Checkbox, Section = MetadataSectionType.Image, HelpText = "season##-poster.jpg, season##-banner.jpg, season-specials-poster.jpg, season-specials-banner.jpg")]
[FieldDefinition(5, Label = "Season Images", Type = FieldType.Checkbox, Section = MetadataSectionType.Image, HelpText = "season##-poster.jpg, season##-banner.jpg, season-specials-poster.jpg, season-specials-banner.jpg")]
public bool SeasonImages { get; set; }
[FieldDefinition(5, Label = "Episode Images", Type = FieldType.Checkbox, Section = MetadataSectionType.Image, HelpText = "<filename>-thumb.jpg")]
[FieldDefinition(6, Label = "Episode Images", Type = FieldType.Checkbox, Section = MetadataSectionType.Image, HelpText = "<filename>-thumb.jpg")]
public bool EpisodeImages { get; set; }
public bool IsValid => true;