From bdcdc13485c340c48dfcbb53338e72255d042aab Mon Sep 17 00:00:00 2001 From: Qstick Date: Sun, 1 Apr 2018 01:05:03 -0400 Subject: [PATCH] Fixed: Artist Images for Kodi being saved as poster.jpg instead of folder.jpg Fixes #257 --- .../MediaBrowser/MediaBrowserMetadata.cs | 20 --- .../Consumers/Roksbox/RoksboxMetadata.cs | 58 --------- .../Roksbox/RoksboxMetadataSettings.cs | 2 +- .../Metadata/Consumers/Wdtv/WdtvMetadata.cs | 121 +----------------- .../Consumers/Wdtv/WdtvMetadataSettings.cs | 8 -- .../Metadata/Consumers/Xbmc/XbmcMetadata.cs | 28 +--- 6 files changed, 8 insertions(+), 229 deletions(-) diff --git a/src/NzbDrone.Core/Extras/Metadata/Consumers/MediaBrowser/MediaBrowserMetadata.cs b/src/NzbDrone.Core/Extras/Metadata/Consumers/MediaBrowser/MediaBrowserMetadata.cs index 9fc771d2b..84874371f 100644 --- a/src/NzbDrone.Core/Extras/Metadata/Consumers/MediaBrowser/MediaBrowserMetadata.cs +++ b/src/NzbDrone.Core/Extras/Metadata/Consumers/MediaBrowser/MediaBrowserMetadata.cs @@ -121,25 +121,5 @@ namespace NzbDrone.Core.Extras.Metadata.Consumers.MediaBrowser { return new List(); } - - private IEnumerable ProcessArtistImages(Artist artist) - { - return new List(); - } - - private IEnumerable ProcessAlbumImages(Artist artist, Album album) - { - return new List(); - } - - private string GetEpisodeNfoFilename(string episodeFilePath) - { - return null; - } - - private string GetEpisodeImageFilename(string episodeFilePath) - { - return null; - } } } diff --git a/src/NzbDrone.Core/Extras/Metadata/Consumers/Roksbox/RoksboxMetadata.cs b/src/NzbDrone.Core/Extras/Metadata/Consumers/Roksbox/RoksboxMetadata.cs index e8cf1ca59..419a14808 100644 --- a/src/NzbDrone.Core/Extras/Metadata/Consumers/Roksbox/RoksboxMetadata.cs +++ b/src/NzbDrone.Core/Extras/Metadata/Consumers/Roksbox/RoksboxMetadata.cs @@ -178,20 +178,6 @@ namespace NzbDrone.Core.Extras.Metadata.Consumers.Roksbox public override List TrackImages(Artist artist, TrackFile trackFile) { - //if (!Settings.EpisodeImages) - //{ - // return new List(); - //} - - //var screenshot = episodeFile.Tracks.Value.First().Images.SingleOrDefault(i => i.CoverType == MediaCoverTypes.Screenshot); - - //if (screenshot == null) - //{ - // _logger.Trace("Episode screenshot not available"); - // return new List(); - //} - - //return new List {new ImageFileResult(GetEpisodeImageFilename(episodeFile.RelativePath), screenshot.Url)}; return new List(); } @@ -199,49 +185,5 @@ namespace NzbDrone.Core.Extras.Metadata.Consumers.Roksbox { return Path.ChangeExtension(trackFilePath, "xml"); } - - private string GetTrackImageFilename(string trackFilePath) - { - return Path.ChangeExtension(trackFilePath, "jpg"); - } - - private Dictionary GetAlbumFolders(Artist artist) - { - var seasonFolderMap = new Dictionary(); - - foreach (var folder in _diskProvider.GetDirectories(artist.Path)) - { - var directoryinfo = new DirectoryInfo(folder); - var seasonMatch = SeasonImagesRegex.Match(directoryinfo.Name); - - if (seasonMatch.Success) - { - var seasonNumber = seasonMatch.Groups["season"].Value; - - if (seasonNumber.Contains("specials")) - { - seasonFolderMap[0] = folder; - } - else - { - int matchedSeason; - if (int.TryParse(seasonNumber, out matchedSeason)) - { - seasonFolderMap[matchedSeason] = folder; - } - else - { - _logger.Debug("Failed to parse season number from {0} for artist {1}.", folder, artist.Name); - } - } - } - else - { - _logger.Debug("Rejecting folder {0} for artist {1}.", Path.GetDirectoryName(folder), artist.Name); - } - } - - return seasonFolderMap; - } } } diff --git a/src/NzbDrone.Core/Extras/Metadata/Consumers/Roksbox/RoksboxMetadataSettings.cs b/src/NzbDrone.Core/Extras/Metadata/Consumers/Roksbox/RoksboxMetadataSettings.cs index 366be26b4..95245306d 100644 --- a/src/NzbDrone.Core/Extras/Metadata/Consumers/Roksbox/RoksboxMetadataSettings.cs +++ b/src/NzbDrone.Core/Extras/Metadata/Consumers/Roksbox/RoksboxMetadataSettings.cs @@ -20,7 +20,7 @@ namespace NzbDrone.Core.Extras.Metadata.Consumers.Roksbox AlbumImages = true; } - [FieldDefinition(0, Label = "Track Metadata", Type = FieldType.Checkbox, HelpText = "Season##\\filename.xml")] + [FieldDefinition(0, Label = "Track Metadata", Type = FieldType.Checkbox, HelpText = "Album\\filename.xml")] public bool TrackMetadata { get; set; } [FieldDefinition(1, Label = "Artist Images", Type = FieldType.Checkbox, HelpText = "Artist Title.jpg")] diff --git a/src/NzbDrone.Core/Extras/Metadata/Consumers/Wdtv/WdtvMetadata.cs b/src/NzbDrone.Core/Extras/Metadata/Consumers/Wdtv/WdtvMetadata.cs index f9896a1a7..fa2bcc602 100644 --- a/src/NzbDrone.Core/Extras/Metadata/Consumers/Wdtv/WdtvMetadata.cs +++ b/src/NzbDrone.Core/Extras/Metadata/Consumers/Wdtv/WdtvMetadata.cs @@ -31,8 +31,6 @@ namespace NzbDrone.Core.Extras.Metadata.Consumers.Wdtv _logger = logger; } - private static readonly Regex SeasonImagesRegex = new Regex(@"^(season (?\d+))|(?specials)", RegexOptions.Compiled | RegexOptions.IgnoreCase); - public override string Name => "WDTV"; public override string GetFilenameAfterMove(Artist artist, TrackFile trackFile, MetadataFile metadataFile) @@ -62,32 +60,6 @@ namespace NzbDrone.Core.Extras.Metadata.Consumers.Wdtv RelativePath = artist.Path.GetRelativePath(path) }; - //Series and season images are both named folder.jpg, only season ones sit in season folders - if (Path.GetFileName(filename).Equals("folder.jpg", StringComparison.InvariantCultureIgnoreCase)) - { - var parentdir = Directory.GetParent(path); - var seasonMatch = SeasonImagesRegex.Match(parentdir.Name); - if (seasonMatch.Success) - { - metadata.Type = MetadataType.AlbumImage; - - if (seasonMatch.Groups["specials"].Success) - { - metadata.AlbumId = 0; - } - - else - { - metadata.AlbumId = Convert.ToInt32(seasonMatch.Groups["season"].Value); - } - - return metadata; - } - - metadata.Type = MetadataType.ArtistImage; - return metadata; - } - var parseResult = Parser.Parser.ParseMusicTitle(filename); if (parseResult != null) @@ -164,56 +136,12 @@ namespace NzbDrone.Core.Extras.Metadata.Consumers.Wdtv public override List ArtistImages(Artist artist) { - if (!Settings.ArtistImages) - { - return new List(); - } - - //Because we only support one image, attempt to get the Poster type, then if that fails grab the first - var image = artist.Images.SingleOrDefault(c => c.CoverType == MediaCoverTypes.Poster) ?? artist.Images.FirstOrDefault(); - if (image == null) - { - _logger.Trace("Failed to find suitable Artist image for artist {0}.", artist.Name); - return new List(); - } - - var source = _mediaCoverService.GetCoverPath(artist.Id, image.CoverType); - var destination = "folder" + Path.GetExtension(source); - - return new List - { - new ImageFileResult(destination, source) - }; + return new List(); } public override List AlbumImages(Artist artist, Album album, string albumFolder) { - if (!Settings.AlbumImages) - { - return new List(); - } - - var seasonFolders = GetAlbumFolders(artist); - - //Work out the path to this season - if we don't have a matching path then skip this season. - string seasonFolder; - if (!seasonFolders.TryGetValue(album.Id, out seasonFolder)) - { - _logger.Trace("Failed to find album folder for artist {0}, album {1}.", artist.Name, album.Title); - return new List(); - } - - //WDTV only supports one season image, so first of all try for poster otherwise just use whatever is first in the collection - var image = album.Images.SingleOrDefault(c => c.CoverType == MediaCoverTypes.Poster) ?? album.Images.FirstOrDefault(); - if (image == null) - { - _logger.Trace("Failed to find suitable album image for artist {0}, album {1}.", artist.Name, album.Title); - return new List(); - } - - var path = Path.Combine(seasonFolder, "folder.jpg"); - - return new List{ new ImageFileResult(path, image.Url) }; + return new List(); } public override List TrackImages(Artist artist, TrackFile trackFile) @@ -226,50 +154,5 @@ namespace NzbDrone.Core.Extras.Metadata.Consumers.Wdtv { return Path.ChangeExtension(trackFilePath, "xml"); } - - private string GetTrackImageFilename(string trackFilePath) - { - return Path.ChangeExtension(trackFilePath, "metathumb"); - } - - private Dictionary GetAlbumFolders(Artist artist) - { - var seasonFolderMap = new Dictionary(); - - foreach (var folder in _diskProvider.GetDirectories(artist.Path)) - { - var directoryinfo = new DirectoryInfo(folder); - var seasonMatch = SeasonImagesRegex.Match(directoryinfo.Name); - - if (seasonMatch.Success) - { - var seasonNumber = seasonMatch.Groups["season"].Value; - - if (seasonNumber.Contains("specials")) - { - seasonFolderMap[0] = folder; - } - else - { - int matchedSeason; - if (int.TryParse(seasonNumber, out matchedSeason)) - { - seasonFolderMap[matchedSeason] = folder; - } - else - { - _logger.Debug("Failed to parse season number from {0} for artist {1}.", folder, artist.Name); - } - } - } - - else - { - _logger.Debug("Rejecting folder {0} for artist {1}.", Path.GetDirectoryName(folder), artist.Name); - } - } - - return seasonFolderMap; - } } } diff --git a/src/NzbDrone.Core/Extras/Metadata/Consumers/Wdtv/WdtvMetadataSettings.cs b/src/NzbDrone.Core/Extras/Metadata/Consumers/Wdtv/WdtvMetadataSettings.cs index 32102cc15..ae126f252 100644 --- a/src/NzbDrone.Core/Extras/Metadata/Consumers/Wdtv/WdtvMetadataSettings.cs +++ b/src/NzbDrone.Core/Extras/Metadata/Consumers/Wdtv/WdtvMetadataSettings.cs @@ -16,18 +16,10 @@ namespace NzbDrone.Core.Extras.Metadata.Consumers.Wdtv public WdtvMetadataSettings() { TrackMetadata = true; - ArtistImages = true; - AlbumImages = true; } [FieldDefinition(0, Label = "Track Metadata", Type = FieldType.Checkbox)] public bool TrackMetadata { get; set; } - - [FieldDefinition(1, Label = "Artist Images", Type = FieldType.Checkbox)] - public bool ArtistImages { get; set; } - - [FieldDefinition(2, Label = "Album Images", Type = FieldType.Checkbox)] - public bool AlbumImages { get; set; } public bool IsValid => true; diff --git a/src/NzbDrone.Core/Extras/Metadata/Consumers/Xbmc/XbmcMetadata.cs b/src/NzbDrone.Core/Extras/Metadata/Consumers/Xbmc/XbmcMetadata.cs index 5f8d929c7..9cb23dba2 100644 --- a/src/NzbDrone.Core/Extras/Metadata/Consumers/Xbmc/XbmcMetadata.cs +++ b/src/NzbDrone.Core/Extras/Metadata/Consumers/Xbmc/XbmcMetadata.cs @@ -30,7 +30,7 @@ namespace NzbDrone.Core.Extras.Metadata.Consumers.Xbmc _detectNfo = detectNfo; } - private static readonly Regex ArtistImagesRegex = new Regex(@"^(?poster|banner|fanart|logo)\.(?:png|jpg|jpeg)", RegexOptions.Compiled | RegexOptions.IgnoreCase); + private static readonly Regex ArtistImagesRegex = new Regex(@"^(?folder|banner|fanart|logo)\.(?:png|jpg|jpeg)", RegexOptions.Compiled | RegexOptions.IgnoreCase); private static readonly Regex AlbumImagesRegex = new Regex(@"^(?cover|disc)\.(?:png|jpg|jpeg)", RegexOptions.Compiled | RegexOptions.IgnoreCase); public override string Name => "Kodi (XBMC) / Emby"; @@ -121,28 +121,6 @@ namespace NzbDrone.Core.Extras.Metadata.Consumers.Xbmc artistElement.Add(new XElement("musicbrainzartistid", artist.ForeignArtistId)); artistElement.Add(new XElement("biography", artist.Overview)); artistElement.Add(new XElement("outline", artist.Overview)); - //tvShow.Add(new XElement("episodeguide", new XElement("url", episodeGuideUrl))); - //tvShow.Add(new XElement("episodeguideurl", episodeGuideUrl)); - - //foreach (var genre in artist.Genres) - //{ - // tvShow.Add(new XElement("genre", genre)); - //} - - - //foreach (var actor in artist.Members) - //{ - // var xmlActor = new XElement("actor", - // new XElement("name", actor.Name), - // new XElement("role", actor.Instrument)); - - // if (actor.Images.Any()) - // { - // xmlActor.Add(new XElement("thumb", actor.Images.First().Url)); - // } - - // tvShow.Add(xmlActor); - //} var doc = new XDocument(artistElement); doc.Save(xw); @@ -229,6 +207,10 @@ namespace NzbDrone.Core.Extras.Metadata.Consumers.Xbmc { var source = _mediaCoverService.GetCoverPath(artist.Id, image.CoverType); var destination = image.CoverType.ToString().ToLowerInvariant() + Path.GetExtension(image.Url); + if (image.CoverType == MediaCoverTypes.Poster) + { + destination = "folder" + Path.GetExtension(image.Url); + } yield return new ImageFileResult(destination, source); }