Fixed: Artist Images for Kodi being saved as poster.jpg instead of folder.jpg

Fixes #257
pull/6/head
Qstick 7 years ago
parent 289647b6b1
commit bdcdc13485

@ -121,25 +121,5 @@ namespace NzbDrone.Core.Extras.Metadata.Consumers.MediaBrowser
{
return new List<ImageFileResult>();
}
private IEnumerable<ImageFileResult> ProcessArtistImages(Artist artist)
{
return new List<ImageFileResult>();
}
private IEnumerable<ImageFileResult> ProcessAlbumImages(Artist artist, Album album)
{
return new List<ImageFileResult>();
}
private string GetEpisodeNfoFilename(string episodeFilePath)
{
return null;
}
private string GetEpisodeImageFilename(string episodeFilePath)
{
return null;
}
}
}

@ -178,20 +178,6 @@ namespace NzbDrone.Core.Extras.Metadata.Consumers.Roksbox
public override List<ImageFileResult> TrackImages(Artist artist, TrackFile trackFile)
{
//if (!Settings.EpisodeImages)
//{
// return new List<ImageFileResult>();
//}
//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<ImageFileResult>();
//}
//return new List<ImageFileResult> {new ImageFileResult(GetEpisodeImageFilename(episodeFile.RelativePath), screenshot.Url)};
return new List<ImageFileResult>();
}
@ -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<int, string> GetAlbumFolders(Artist artist)
{
var seasonFolderMap = new Dictionary<int, string>();
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;
}
}
}

@ -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")]

@ -31,8 +31,6 @@ namespace NzbDrone.Core.Extras.Metadata.Consumers.Wdtv
_logger = logger;
}
private static readonly Regex SeasonImagesRegex = new Regex(@"^(season (?<season>\d+))|(?<specials>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,58 +136,14 @@ namespace NzbDrone.Core.Extras.Metadata.Consumers.Wdtv
public override List<ImageFileResult> ArtistImages(Artist artist)
{
if (!Settings.ArtistImages)
{
return new List<ImageFileResult>();
}
//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<ImageFileResult>();
}
var source = _mediaCoverService.GetCoverPath(artist.Id, image.CoverType);
var destination = "folder" + Path.GetExtension(source);
return new List<ImageFileResult>
{
new ImageFileResult(destination, source)
};
}
public override List<ImageFileResult> AlbumImages(Artist artist, Album album, string albumFolder)
{
if (!Settings.AlbumImages)
{
return new List<ImageFileResult>();
}
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<ImageFileResult>();
}
//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<ImageFileResult>();
}
var path = Path.Combine(seasonFolder, "folder.jpg");
return new List<ImageFileResult>{ new ImageFileResult(path, image.Url) };
}
public override List<ImageFileResult> 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<int, string> GetAlbumFolders(Artist artist)
{
var seasonFolderMap = new Dictionary<int, string>();
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;
}
}
}

@ -16,19 +16,11 @@ 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;
public NzbDroneValidationResult Validate()

@ -30,7 +30,7 @@ namespace NzbDrone.Core.Extras.Metadata.Consumers.Xbmc
_detectNfo = detectNfo;
}
private static readonly Regex ArtistImagesRegex = new Regex(@"^(?<type>poster|banner|fanart|logo)\.(?:png|jpg|jpeg)", RegexOptions.Compiled | RegexOptions.IgnoreCase);
private static readonly Regex ArtistImagesRegex = new Regex(@"^(?<type>folder|banner|fanart|logo)\.(?:png|jpg|jpeg)", RegexOptions.Compiled | RegexOptions.IgnoreCase);
private static readonly Regex AlbumImagesRegex = new Regex(@"^(?<type>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);
}

Loading…
Cancel
Save