From f734ba23233f232f53f3b83d2018f3d45e44b39e Mon Sep 17 00:00:00 2001 From: jasimancas Date: Tue, 10 Nov 2020 21:23:46 +0100 Subject: [PATCH] Schematize NFO in XBMC with Kodi format: https://kodi.wiki/view/NFO_files/Movies --- .../Metadata/Consumers/Xbmc/XbmcMetadata.cs | 198 +++++++++++------- 1 file changed, 123 insertions(+), 75 deletions(-) diff --git a/src/NzbDrone.Core/Extras/Metadata/Consumers/Xbmc/XbmcMetadata.cs b/src/NzbDrone.Core/Extras/Metadata/Consumers/Xbmc/XbmcMetadata.cs index e91b19e8b..5d4983edb 100644 --- a/src/NzbDrone.Core/Extras/Metadata/Consumers/Xbmc/XbmcMetadata.cs +++ b/src/NzbDrone.Core/Extras/Metadata/Consumers/Xbmc/XbmcMetadata.cs @@ -1,3 +1,6 @@ +// Esquema obtenido de: https://kodi.wiki/view/NFO_files/Movies +// Validado para Kodiv V18 (Leila) + using System; using System.Collections.Generic; using System.IO; @@ -47,7 +50,7 @@ namespace NzbDrone.Core.Extras.Metadata.Consumers.Xbmc private static readonly Regex MovieImagesRegex = new Regex(@"^(?poster|banner|fanart|clearart|discart|keyart|landscape|logo|backdrop|clearlogo)\.(?:png|jpe?g)", RegexOptions.Compiled | RegexOptions.IgnoreCase); private static readonly Regex MovieFileImageRegex = new Regex(@"(?-thumb|-poster|-banner|-fanart|-clearart|-discart|-keyart|-landscape|-logo|-backdrop|-clearlogo)\.(?:png|jpe?g)", RegexOptions.Compiled | RegexOptions.IgnoreCase); - public override string Name => "Kodi (XBMC) / Emby"; + public override string Name => "Kodi/XBMC/Jellyfin"; public override string GetFilenameAfterMove(Movie movie, MovieFile movieFile, MetadataFile metadataFile) { @@ -141,99 +144,168 @@ namespace NzbDrone.Core.Extras.Metadata.Consumers.Xbmc var fanarts = movie.Images.Where(i => i.CoverType == MediaCoverTypes.Fanart); var details = new XElement("movie"); - + details.Add(new XElement("title", movieTranslation?.Title ?? movie.Title)); + details.Add(new XElement("originaltitle", movie.OriginalTitle)); + + details.Add(new XElement("sorttitle", movie.SortTitle)); + if (movie.Ratings != null && movie.Ratings.Votes > 0) { details.Add(new XElement("rating", movie.Ratings.Value)); } + #region userrating + // pendiente de poner + #endregion + + #region top250 + // pendiente de poner + #endregion + + #region outline + // pendiente de poner + #endregion + details.Add(new XElement("plot", movieTranslation?.Overview ?? movie.Overview)); - details.Add(new XElement("id", movie.ImdbId)); - details.Add(new XElement("tmdbid", movie.TmdbId)); - if (movie.ImdbId.IsNotNullOrWhiteSpace()) - { - var imdbId = new XElement("uniqueid", movie.ImdbId); - imdbId.SetAttributeValue("type", "imdb"); - imdbId.SetAttributeValue("default", true); - details.Add(imdbId); - } + #region tagline + // pendiente de poner + #endregion - var uniqueId = new XElement("uniqueid", movie.TmdbId); - uniqueId.SetAttributeValue("type", "tmdb"); - details.Add(uniqueId); + details.Add(new XElement("runtime", movie.Runtime)); - if (movie.Certification.IsNotNullOrWhiteSpace()) + // banner? clearart? clearlogo? discart? landscape? poster? + if (thumbnail != null) { - details.Add(new XElement("mpaa", movie.Certification)); + details.Add(new XElement("thumb", thumbnail.Url)); } - - details.Add(new XElement("year", movie.Year)); - - if (movie.InCinemas.HasValue) + else { - details.Add(new XElement("premiered", movie.InCinemas.Value.ToString("yyyy-MM-dd"))); + details.Add(new XElement("thumb")); } - if (movie.Collection?.Name != null) + foreach (var poster in posters) { - var setElement = new XElement("set"); - - setElement.Add(new XElement("name", movie.Collection.Name)); - - details.Add(setElement); + if (poster != null && poster.Url != null) + { + details.Add(new XElement("thumb", new XAttribute("aspect", "poster"), poster.Url)); + } } - if (movie.Collection?.TmdbId > 0) + if (fanarts.Any()) { - details.Add(new XElement("tmdbCollectionId", movie.Collection.TmdbId)); + var fanartElement = new XElement("fanart"); + foreach (var fanart in fanarts) + { + if (fanart != null && fanart.Url != null) + { + fanartElement.Add(new XElement("thumb", fanart.Url)); + } + } - var uniqueSetId = new XElement("uniqueid", movie.Collection.TmdbId); - uniqueSetId.SetAttributeValue("type", "tmdbSet"); - details.Add(uniqueSetId); + details.Add(fanartElement); } - foreach (var genre in movie.Genres) + if (movie.Certification.IsNotNullOrWhiteSpace()) { - details.Add(new XElement("genre", genre)); + details.Add(new XElement("mpaa", movie.Certification)); } - details.Add(new XElement("studio", movie.Studio)); + #region playcount + // pendiente de poner + #endregion + + #region lastplayed + // pendiente de poner + #endregion + + // #region id + // details.Add(new XElement("id", movie.ImdbId)); + // details.Add(new XElement("tmdbid", movie.TmdbId)); + // #endregion + + var uniqueId = new XElement("uniqueid", movie.TmdbId); + uniqueId.SetAttributeValue("type", "tmdb"); + details.Add(uniqueId); - if (thumbnail == null) + if (movie.ImdbId.IsNotNullOrWhiteSpace()) { - details.Add(new XElement("thumb")); + var imdbId = new XElement("uniqueid", movie.ImdbId); + imdbId.SetAttributeValue("type", "imdb"); + imdbId.SetAttributeValue("default", true); + details.Add(imdbId); } - else + + foreach (var genre in movie.Genres) { - details.Add(new XElement("thumb", thumbnail.Url)); + details.Add(new XElement("genre", genre)); } - foreach (var poster in posters) + #region country + // pendiente de poner + #endregion + + if (movie.Collection?.Name != null) { - if (poster != null && poster.Url != null) - { - details.Add(new XElement("thumb", new XAttribute("aspect", "poster"), poster.Url)); - } + var setElement = new XElement("set"); + + setElement.Add(new XElement("name", movie.Collection.Name)); + + details.Add(setElement); } - if (fanarts.Any()) + #region tag + //details.Add(new XElement("tag", movie.Tags)); //Añadido Tags //Estan vacios en la BBDD... + #endregion + + // esto hay que comprobarlo, porque este credits es el escritor y lo mete como ¿actores? + var credits = _creditService.GetAllCreditsForMovie(movie.Id); + + foreach (var credit in credits) { - var fanartElement = new XElement("fanart"); - foreach (var fanart in fanarts) + if (credit.Name != null && credit.Character != null) { - if (fanart != null && fanart.Url != null) + var actorElement = new XElement("actor"); + + actorElement.Add(new XElement("name", credit.Name)); + actorElement.Add(new XElement("role", credit.Character)); + actorElement.Add(new XElement("order", credit.Order)); + + var headshot = credit.Images.FirstOrDefault(m => m.CoverType == MediaCoverTypes.Headshot); + + if (headshot != null && headshot.Url != null) { - fanartElement.Add(new XElement("thumb", fanart.Url)); + actorElement.Add(new XElement("thumb", headshot.Url)); } + + details.Add(actorElement); } + } - details.Add(fanartElement); + if (movie.InCinemas.HasValue) + { + details.Add(new XElement("premiered", movie.InCinemas.Value.ToString("yyyy-MM-dd"))); } - details.Add(new XElement("watched", watched)); + details.Add(new XElement("year", movie.Year)); + + #region collection + // Esto no aparece en el NFO de Kodi, pendiente de ver si borrar o no + // if (movie.Collection?.TmdbId > 0) + // { + // details.Add(new XElement("tmdbCollectionId", movie.Collection.TmdbId)); + + // var uniqueSetId = new XElement("uniqueid", movie.Collection.TmdbId); + // uniqueSetId.SetAttributeValue("type", "tmdbSet"); + // details.Add(uniqueSetId); + // } + #endregion + + details.Add(new XElement("studio", movie.Studio)); + + details.Add(new XElement("trailer", "https://www.youtube.com/watch?v=" + movie.YouTubeTrailerId)); //Añadido el trailer if (movieFile.MediaInfo != null) { @@ -274,33 +346,9 @@ namespace NzbDrone.Core.Extras.Metadata.Consumers.Xbmc streamDetails.Add(subtitle); } - var credits = _creditService.GetAllCreditsForMovie(movie.Id); - - foreach (var credit in credits) - { - if (credit.Name != null && credit.Character != null) - { - var actorElement = new XElement("actor"); - - actorElement.Add(new XElement("name", credit.Name)); - actorElement.Add(new XElement("role", credit.Character)); - actorElement.Add(new XElement("order", credit.Order)); - - var headshot = credit.Images.FirstOrDefault(m => m.CoverType == MediaCoverTypes.Headshot); - - if (headshot != null && headshot.Url != null) - { - actorElement.Add(new XElement("thumb", headshot.Url)); - } - - details.Add(actorElement); - } - } - fileInfo.Add(streamDetails); details.Add(fileInfo); } - doc.Add(details); doc.Save(xw);