Sfoglia il codice sorgente

further improve last fm images

Luke Pulverenti 11 anni fa
parent
commit
5c3fcaf049

+ 11 - 9
MediaBrowser.Providers/ImageFromMediaLocationProvider.cs

@@ -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 path = image.Value;
-
-                return IsInMetaLocation(item, path) && args.GetMetaFileByPath(path) == null;
-
-            }).Select(i => i.Key).ToList();
+            var deletedKeys = item.Images
+                .ToList()
+                .Where(image => !File.Exists(image.Value))
+                .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)

+ 10 - 2
MediaBrowser.Providers/Music/LastfmAlbumProvider.cs

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

+ 1 - 1
MediaBrowser.Providers/Music/LastfmArtistProvider.cs

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

+ 1 - 1
MediaBrowser.Providers/Music/LastfmBaseProvider.cs

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

+ 4 - 1
MediaBrowser.Providers/Music/LastfmHelper.cs

@@ -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)) ?? 

+ 2 - 8
MediaBrowser.Providers/TV/EpisodeImageFromMediaLocationProvider.cs

@@ -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 (!string.Equals(Path.GetDirectoryName(path), metadataFolderPath, StringComparison.OrdinalIgnoreCase))
-            {
-                return;
-            }
-
-            if (episode.Parent.ResolveArgs.GetMetaFileByPath(path) == null)
+            if (!File.Exists(path))
             {
             {
                 episode.PrimaryImagePath = null;
                 episode.PrimaryImagePath = null;
             }
             }