aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Providers/Music/LastfmHelper.cs
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Providers/Music/LastfmHelper.cs')
-rw-r--r--MediaBrowser.Providers/Music/LastfmHelper.cs76
1 files changed, 0 insertions, 76 deletions
diff --git a/MediaBrowser.Providers/Music/LastfmHelper.cs b/MediaBrowser.Providers/Music/LastfmHelper.cs
deleted file mode 100644
index 7c83cec6b..000000000
--- a/MediaBrowser.Providers/Music/LastfmHelper.cs
+++ /dev/null
@@ -1,76 +0,0 @@
-using MediaBrowser.Common.Configuration;
-using MediaBrowser.Model.Logging;
-using System;
-using System.IO;
-using System.Linq;
-
-namespace MediaBrowser.Providers.Music
-{
- public static class LastfmHelper
- {
- public static string GetImageUrl(IHasLastFmImages data, out string size)
- {
- size = null;
-
- if (data.image == null)
- {
- return null;
- }
-
- var validImages = data.image
- .Where(i => !string.IsNullOrWhiteSpace(i.url))
- .ToList();
-
- var img = validImages
- .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, "large", StringComparison.OrdinalIgnoreCase)) ??
- data.image.FirstOrDefault(i => string.Equals(i.size, "medium", StringComparison.OrdinalIgnoreCase)) ??
- data.image.FirstOrDefault();
-
- if (img != null)
- {
- size = img.size;
- return img.url;
- }
-
- return null;
- }
-
- public static void SaveImageInfo(IApplicationPaths appPaths, ILogger logger, string musicBrainzId, string url, string size)
- {
- if (appPaths == null)
- {
- throw new ArgumentNullException("appPaths");
- }
- if (string.IsNullOrEmpty(musicBrainzId))
- {
- throw new ArgumentNullException("musicBrainzId");
- }
- if (string.IsNullOrEmpty(url))
- {
- throw new ArgumentNullException("url");
- }
-
- var cachePath = Path.Combine(appPaths.CachePath, "lastfm", musicBrainzId, "image.txt");
-
- try
- {
- if (string.IsNullOrEmpty(url))
- {
- File.Delete(cachePath);
- }
- else
- {
- Directory.CreateDirectory(Path.GetDirectoryName(cachePath));
- File.WriteAllText(cachePath, url + "|" + size);
- }
- }
- catch (IOException ex)
- {
- // Don't fail if this is unable to write
- logger.ErrorException("Error saving to {0}", ex, cachePath);
- }
- }
- }
-}