further improve last fm images

This commit is contained in:
Luke Pulverenti 2013-09-06 13:26:56 -04:00
parent 062d2dc29f
commit 5c3fcaf049
6 changed files with 29 additions and 22 deletions

View File

@ -136,13 +136,11 @@ namespace MediaBrowser.Providers
private void ValidateImages(BaseItem item, ItemResolveArgs args) private void ValidateImages(BaseItem item, ItemResolveArgs args)
{ {
// Only validate paths from the same directory - need to copy to a list because we are going to potentially modify the collection below // Only validate paths from the same directory - need to copy to a list because we are going to potentially modify the collection below
var deletedKeys = item.Images.ToList().Where(image => var deletedKeys = item.Images
{ .ToList()
var path = image.Value; .Where(image => !File.Exists(image.Value))
.Select(i => i.Key)
return IsInMetaLocation(item, path) && args.GetMetaFileByPath(path) == null; .ToList();
}).Select(i => i.Key).ToList();
// Now remove them from the dictionary // Now remove them from the dictionary
foreach (var key in deletedKeys) foreach (var key in deletedKeys)
@ -159,7 +157,9 @@ namespace MediaBrowser.Providers
private void ValidateBackdrops(BaseItem item, ItemResolveArgs args) private void ValidateBackdrops(BaseItem item, ItemResolveArgs args)
{ {
// Only validate paths from the same directory - need to copy to a list because we are going to potentially modify the collection below // Only validate paths from the same directory - need to copy to a list because we are going to potentially modify the collection below
var deletedImages = item.BackdropImagePaths.Where(path => IsInMetaLocation(item, path) && args.GetMetaFileByPath(path) == null).ToList(); var deletedImages = item.BackdropImagePaths
.Where(path => !File.Exists(path))
.ToList();
// Now remove them from the dictionary // Now remove them from the dictionary
foreach (var path in deletedImages) foreach (var path in deletedImages)
@ -176,7 +176,9 @@ namespace MediaBrowser.Providers
private void ValidateScreenshots(BaseItem item, ItemResolveArgs args) private void ValidateScreenshots(BaseItem item, ItemResolveArgs args)
{ {
// Only validate paths from the same directory - need to copy to a list because we are going to potentially modify the collection below // Only validate paths from the same directory - need to copy to a list because we are going to potentially modify the collection below
var deletedImages = item.ScreenshotImagePaths.Where(path => IsInMetaLocation(item, path) && args.GetMetaFileByPath(path) == null).ToList(); var deletedImages = item.ScreenshotImagePaths
.Where(path => !File.Exists(path))
.ToList();
// Now remove them from the dictionary // Now remove them from the dictionary
foreach (var path in deletedImages) foreach (var path in deletedImages)

View File

@ -1,5 +1,4 @@
using System.IO; using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.Net; using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities;
@ -10,6 +9,7 @@ using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Serialization; using MediaBrowser.Model.Serialization;
using MoreLinq; using MoreLinq;
using System; using System;
using System.IO;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -40,6 +40,14 @@ namespace MediaBrowser.Providers.Music
get { return MetadataProviderPriority.Third; } get { return MetadataProviderPriority.Third; }
} }
protected override string ProviderVersion
{
get
{
return "8";
}
}
private bool HasAltMeta(BaseItem item) private bool HasAltMeta(BaseItem item)
{ {
return item.LocationType == LocationType.FileSystem && item.ResolveArgs.ContainsMetaFileByName("album.xml"); return item.LocationType == LocationType.FileSystem && item.ResolveArgs.ContainsMetaFileByName("album.xml");

View File

@ -58,7 +58,7 @@ namespace MediaBrowser.Providers.Music
{ {
get get
{ {
return "6"; return "8";
} }
} }

View File

@ -47,7 +47,7 @@ namespace MediaBrowser.Providers.Music
{ {
get get
{ {
return "5"; return "8";
} }
} }

View File

@ -54,8 +54,11 @@ namespace MediaBrowser.Providers.Music
return null; return null;
} }
var img = data.image var validImages = data.image
.Where(i => !string.IsNullOrWhiteSpace(i.url)) .Where(i => !string.IsNullOrWhiteSpace(i.url))
.ToList();
var img = validImages
.FirstOrDefault(i => string.Equals(i.size, "mega", StringComparison.OrdinalIgnoreCase)) ?? .FirstOrDefault(i => string.Equals(i.size, "mega", StringComparison.OrdinalIgnoreCase)) ??
data.image.FirstOrDefault(i => string.Equals(i.size, "extralarge", StringComparison.OrdinalIgnoreCase)) ?? data.image.FirstOrDefault(i => string.Equals(i.size, "extralarge", StringComparison.OrdinalIgnoreCase)) ??
data.image.FirstOrDefault(i => string.Equals(i.size, "large", StringComparison.OrdinalIgnoreCase)) ?? data.image.FirstOrDefault(i => string.Equals(i.size, "large", StringComparison.OrdinalIgnoreCase)) ??

View File

@ -4,11 +4,11 @@ using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Providers; using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Entities; using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Logging;
using System; using System;
using System.IO; using System.IO;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using MediaBrowser.Model.Logging;
namespace MediaBrowser.Providers.TV namespace MediaBrowser.Providers.TV
{ {
@ -115,13 +115,7 @@ namespace MediaBrowser.Providers.TV
return; return;
} }
// Only validate images in the season/metadata folder if (!File.Exists(path))
if (!string.Equals(Path.GetDirectoryName(path), metadataFolderPath, StringComparison.OrdinalIgnoreCase))
{
return;
}
if (episode.Parent.ResolveArgs.GetMetaFileByPath(path) == null)
{ {
episode.PrimaryImagePath = null; episode.PrimaryImagePath = null;
} }