diff options
Diffstat (limited to 'MediaBrowser.Controller')
29 files changed, 363 insertions, 241 deletions
diff --git a/MediaBrowser.Controller/Dto/DtoBuilder.cs b/MediaBrowser.Controller/Dto/DtoBuilder.cs index 2631488a5..371241d1b 100644 --- a/MediaBrowser.Controller/Dto/DtoBuilder.cs +++ b/MediaBrowser.Controller/Dto/DtoBuilder.cs @@ -528,7 +528,7 @@ namespace MediaBrowser.Controller.Dto recursiveItemCount++; // Check is recently added - if (child.IsRecentlyAdded(user)) + if (child.IsRecentlyAdded()) { rcentlyAddedItemCount++; } diff --git a/MediaBrowser.Controller/Entities/Audio/Artist.cs b/MediaBrowser.Controller/Entities/Audio/Artist.cs index dcd6af92d..567b67868 100644 --- a/MediaBrowser.Controller/Entities/Audio/Artist.cs +++ b/MediaBrowser.Controller/Entities/Audio/Artist.cs @@ -12,7 +12,7 @@ namespace MediaBrowser.Controller.Entities.Audio /// <returns>System.String.</returns> public override string GetUserDataKey() { - return Name; + return "Artist-" + Name; } } } diff --git a/MediaBrowser.Controller/Entities/Audio/Audio.cs b/MediaBrowser.Controller/Entities/Audio/Audio.cs index 9deb8241d..01bdd84ac 100644 --- a/MediaBrowser.Controller/Entities/Audio/Audio.cs +++ b/MediaBrowser.Controller/Entities/Audio/Audio.cs @@ -113,5 +113,15 @@ namespace MediaBrowser.Controller.Entities.Audio return (ProductionYear != null ? ProductionYear.Value.ToString("000-") : "") + (IndexNumber != null ? IndexNumber.Value.ToString("0000 - ") : "") + Name; } + + /// <summary> + /// Determines whether the specified name has artist. + /// </summary> + /// <param name="name">The name.</param> + /// <returns><c>true</c> if the specified name has artist; otherwise, <c>false</c>.</returns> + public bool HasArtist(string name) + { + return Artists.Contains(name, StringComparer.OrdinalIgnoreCase) || string.Equals(AlbumArtist, name, StringComparison.OrdinalIgnoreCase); + } } } diff --git a/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs b/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs index 7b64c0e85..7d6577b4e 100644 --- a/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs +++ b/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs @@ -40,7 +40,7 @@ namespace MediaBrowser.Controller.Entities.Audio /// <summary> /// The unknwon artist /// </summary> - private static readonly MusicArtist UnknwonArtist = new MusicArtist {Name = "<Unknown>"}; + private static readonly MusicArtist UnknwonArtist = new MusicArtist { Name = "<Unknown>" }; /// <summary> /// Override this to return the folder that should be used to construct a container diff --git a/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs b/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs index b5627e061..1f1d5e083 100644 --- a/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs +++ b/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs @@ -1,6 +1,4 @@ -using System.Collections.Generic; - namespace MediaBrowser.Controller.Entities.Audio { /// <summary> @@ -8,12 +6,6 @@ namespace MediaBrowser.Controller.Entities.Audio /// </summary> public class MusicArtist : Folder { - public Dictionary<string, string> AlbumCovers { get; set; } - public override void ClearMetaValues() - { - AlbumCovers = null; - base.ClearMetaValues(); - } } } diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index f7963c6e6..1d803ea45 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -23,6 +23,14 @@ namespace MediaBrowser.Controller.Entities /// </summary> public abstract class BaseItem : IHasProviderIds { + protected BaseItem() + { + Genres = new List<string>(); + TrailerUrls = new List<string>(); + Studios = new List<string>(); + People = new List<PersonInfo>(); + } + /// <summary> /// The trailer folder name /// </summary> @@ -925,16 +933,10 @@ namespace MediaBrowser.Controller.Entities /// <summary> /// Determines if the item is considered new based on user settings /// </summary> - /// <param name="user">The user.</param> /// <returns><c>true</c> if [is recently added] [the specified user]; otherwise, <c>false</c>.</returns> /// <exception cref="System.ArgumentNullException"></exception> - public bool IsRecentlyAdded(User user) + public bool IsRecentlyAdded() { - if (user == null) - { - throw new ArgumentNullException(); - } - return (DateTime.UtcNow - DateCreated).TotalDays < ConfigurationManager.Configuration.RecentItemDays; } diff --git a/MediaBrowser.Controller/Entities/Genre.cs b/MediaBrowser.Controller/Entities/Genre.cs index 619c7a12b..b2b465353 100644 --- a/MediaBrowser.Controller/Entities/Genre.cs +++ b/MediaBrowser.Controller/Entities/Genre.cs @@ -12,7 +12,7 @@ namespace MediaBrowser.Controller.Entities /// <returns>System.String.</returns> public override string GetUserDataKey() { - return Name; + return "Genre-" + Name; } } } diff --git a/MediaBrowser.Controller/Entities/Person.cs b/MediaBrowser.Controller/Entities/Person.cs index f5570448d..0f2803744 100644 --- a/MediaBrowser.Controller/Entities/Person.cs +++ b/MediaBrowser.Controller/Entities/Person.cs @@ -12,7 +12,7 @@ namespace MediaBrowser.Controller.Entities /// <returns>System.String.</returns> public override string GetUserDataKey() { - return Name; + return "Person-" + Name; } } diff --git a/MediaBrowser.Controller/Entities/Studio.cs b/MediaBrowser.Controller/Entities/Studio.cs index 06511d959..0dec024f8 100644 --- a/MediaBrowser.Controller/Entities/Studio.cs +++ b/MediaBrowser.Controller/Entities/Studio.cs @@ -12,7 +12,7 @@ namespace MediaBrowser.Controller.Entities /// <returns>System.String.</returns> public override string GetUserDataKey() { - return Name; + return "Studio-" + Name; } } } diff --git a/MediaBrowser.Controller/Entities/Year.cs b/MediaBrowser.Controller/Entities/Year.cs index 1e4e6cb06..307ce306b 100644 --- a/MediaBrowser.Controller/Entities/Year.cs +++ b/MediaBrowser.Controller/Entities/Year.cs @@ -12,7 +12,7 @@ namespace MediaBrowser.Controller.Entities /// <returns>System.String.</returns> public override string GetUserDataKey() { - return Name; + return "Year-" + Name; } } } diff --git a/MediaBrowser.Controller/Library/ILibraryManager.cs b/MediaBrowser.Controller/Library/ILibraryManager.cs index 86fd25e66..060f52e37 100644 --- a/MediaBrowser.Controller/Library/ILibraryManager.cs +++ b/MediaBrowser.Controller/Library/ILibraryManager.cs @@ -213,5 +213,13 @@ namespace MediaBrowser.Controller.Library /// <param name="parent">The parent.</param> /// <returns>IEnumerable{BaseItem}.</returns> IEnumerable<BaseItem> RetrieveChildren(Folder parent); + + /// <summary> + /// Validates the artists. + /// </summary> + /// <param name="cancellationToken">The cancellation token.</param> + /// <param name="progress">The progress.</param> + /// <returns>Task.</returns> + Task ValidateArtists(CancellationToken cancellationToken, IProgress<double> progress); } }
\ No newline at end of file diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj index 926639d0c..09a59286e 100644 --- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj +++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj @@ -53,8 +53,12 @@ <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> </PropertyGroup> <ItemGroup> + <Reference Include="MoreLinq"> + <HintPath>..\packages\morelinq.1.0.15631-beta\lib\net35\MoreLinq.dll</HintPath> + </Reference> <Reference Include="System" /> <Reference Include="System.Core" /> + <Reference Include="System.Data" /> <Reference Include="System.Drawing" /> <Reference Include="System.Net" /> <Reference Include="System.Runtime.Serialization" /> @@ -111,9 +115,11 @@ <Compile Include="Providers\IProviderManager.cs" /> <Compile Include="Providers\MediaInfo\MediaEncoderHelpers.cs" /> <Compile Include="Providers\MetadataProviderPriority.cs" /> + <Compile Include="Providers\Music\FanArtArtistByNameProvider.cs" /> <Compile Include="Providers\Music\LastfmAlbumProvider.cs" /> <Compile Include="Providers\Music\FanArtAlbumProvider.cs" /> <Compile Include="Providers\Music\FanArtArtistProvider.cs" /> + <Compile Include="Providers\Music\LastfmArtistByNameProvider.cs" /> <Compile Include="Providers\Music\LastfmArtistProvider.cs" /> <Compile Include="Providers\Music\LastfmHelper.cs" /> <Compile Include="Providers\Music\MusicArtistProviderFromJson.cs" /> @@ -197,6 +203,9 @@ <Name>MediaBrowser.Model</Name> </ProjectReference> </ItemGroup> + <ItemGroup> + <None Include="packages.config" /> + </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <PropertyGroup> <PostBuildEvent>if $(ConfigurationName) == Release ( diff --git a/MediaBrowser.Controller/Providers/IProviderManager.cs b/MediaBrowser.Controller/Providers/IProviderManager.cs index cb7237a9d..fa10c8585 100644 --- a/MediaBrowser.Controller/Providers/IProviderManager.cs +++ b/MediaBrowser.Controller/Providers/IProviderManager.cs @@ -14,11 +14,12 @@ namespace MediaBrowser.Controller.Providers /// <param name="item">The item.</param> /// <param name="source">The source.</param> /// <param name="targetName">Name of the target.</param> + /// <param name="saveLocally">if set to <c>true</c> [save locally].</param> /// <param name="resourcePool">The resource pool.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns>Task{System.String}.</returns> /// <exception cref="System.ArgumentNullException">item</exception> - Task<string> DownloadAndSaveImage(BaseItem item, string source, string targetName, SemaphoreSlim resourcePool, CancellationToken cancellationToken); + Task<string> DownloadAndSaveImage(BaseItem item, string source, string targetName, bool saveLocally, SemaphoreSlim resourcePool, CancellationToken cancellationToken); /// <summary> /// Saves to library filesystem. diff --git a/MediaBrowser.Controller/Providers/Movies/FanArtMovieProvider.cs b/MediaBrowser.Controller/Providers/Movies/FanArtMovieProvider.cs index 94fe38680..b6155f612 100644 --- a/MediaBrowser.Controller/Providers/Movies/FanArtMovieProvider.cs +++ b/MediaBrowser.Controller/Providers/Movies/FanArtMovieProvider.cs @@ -150,7 +150,7 @@ namespace MediaBrowser.Controller.Providers.Movies Logger.Debug("FanArtProvider getting ClearLogo for " + movie.Name); try { - movie.SetImage(ImageType.Logo, await _providerManager.DownloadAndSaveImage(movie, path, LOGO_FILE, FanArtResourcePool, cancellationToken).ConfigureAwait(false)); + movie.SetImage(ImageType.Logo, await _providerManager.DownloadAndSaveImage(movie, path, LOGO_FILE, ConfigurationManager.Configuration.SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false)); } catch (HttpException) { @@ -176,7 +176,7 @@ namespace MediaBrowser.Controller.Providers.Movies Logger.Debug("FanArtProvider getting ClearArt for " + movie.Name); try { - movie.SetImage(ImageType.Art, await _providerManager.DownloadAndSaveImage(movie, path, ART_FILE, FanArtResourcePool, cancellationToken).ConfigureAwait(false)); + movie.SetImage(ImageType.Art, await _providerManager.DownloadAndSaveImage(movie, path, ART_FILE, ConfigurationManager.Configuration.SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false)); } catch (HttpException) { @@ -199,7 +199,7 @@ namespace MediaBrowser.Controller.Providers.Movies Logger.Debug("FanArtProvider getting DiscArt for " + movie.Name); try { - movie.SetImage(ImageType.Disc, await _providerManager.DownloadAndSaveImage(movie, path, DISC_FILE, FanArtResourcePool, cancellationToken).ConfigureAwait(false)); + movie.SetImage(ImageType.Disc, await _providerManager.DownloadAndSaveImage(movie, path, DISC_FILE, ConfigurationManager.Configuration.SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false)); } catch (HttpException) { @@ -223,7 +223,7 @@ namespace MediaBrowser.Controller.Providers.Movies Logger.Debug("FanArtProvider getting Banner for " + movie.Name); try { - movie.SetImage(ImageType.Banner, await _providerManager.DownloadAndSaveImage(movie, path, BANNER_FILE, FanArtResourcePool, cancellationToken).ConfigureAwait(false)); + movie.SetImage(ImageType.Banner, await _providerManager.DownloadAndSaveImage(movie, path, BANNER_FILE, ConfigurationManager.Configuration.SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false)); } catch (HttpException) { @@ -247,7 +247,7 @@ namespace MediaBrowser.Controller.Providers.Movies Logger.Debug("FanArtProvider getting Banner for " + movie.Name); try { - movie.SetImage(ImageType.Thumb, await _providerManager.DownloadAndSaveImage(movie, path, THUMB_FILE, FanArtResourcePool, cancellationToken).ConfigureAwait(false)); + movie.SetImage(ImageType.Thumb, await _providerManager.DownloadAndSaveImage(movie, path, THUMB_FILE, ConfigurationManager.Configuration.SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false)); } catch (HttpException) { diff --git a/MediaBrowser.Controller/Providers/Movies/MovieDbProvider.cs b/MediaBrowser.Controller/Providers/Movies/MovieDbProvider.cs index c086aab77..69023c339 100644 --- a/MediaBrowser.Controller/Providers/Movies/MovieDbProvider.cs +++ b/MediaBrowser.Controller/Providers/Movies/MovieDbProvider.cs @@ -253,7 +253,7 @@ namespace MediaBrowser.Controller.Providers.Movies new Regex(@"(?<name>.*)") // last resort matches the whole string as the name }; - public const string LOCAL_META_FILE_NAME = "MBMovie.json"; + public const string LOCAL_META_FILE_NAME = "mbmovie.js"; public const string ALT_META_FILE_NAME = "movie.xml"; protected string ItemType = "movie"; @@ -270,7 +270,7 @@ namespace MediaBrowser.Controller.Providers.Movies } - if (providerInfo.LastRefreshStatus == ProviderRefreshStatus.CompletedWithErrors) + if (providerInfo.LastRefreshStatus != ProviderRefreshStatus.Success) { Logger.Debug("MovieProvider for {0} - last attempt had errors. Will try again.", item.Path); return true; @@ -283,9 +283,6 @@ namespace MediaBrowser.Controller.Providers.Movies return false; } - if (DateTime.Today.Subtract(item.DateCreated).TotalDays > 180 && downloadDate != DateTime.MinValue) - return false; // don't trigger a refresh data for item that are more than 6 months old and have been refreshed before - if (DateTime.Today.Subtract(downloadDate).TotalDays < ConfigurationManager.Configuration.MetadataRefreshDays) // only refresh every n days return false; @@ -1028,7 +1025,7 @@ namespace MediaBrowser.Controller.Providers.Movies { try { - item.PrimaryImagePath = await ProviderManager.DownloadAndSaveImage(item, tmdbImageUrl + poster.file_path, "folder" + Path.GetExtension(poster.file_path), MovieDbResourcePool, cancellationToken).ConfigureAwait(false); + item.PrimaryImagePath = await ProviderManager.DownloadAndSaveImage(item, tmdbImageUrl + poster.file_path, "folder" + Path.GetExtension(poster.file_path), ConfigurationManager.Configuration.SaveLocalMeta, MovieDbResourcePool, cancellationToken).ConfigureAwait(false); } catch (HttpException) { @@ -1060,7 +1057,7 @@ namespace MediaBrowser.Controller.Providers.Movies { try { - item.BackdropImagePaths.Add(await ProviderManager.DownloadAndSaveImage(item, tmdbImageUrl + images.backdrops[i].file_path, bdName + Path.GetExtension(images.backdrops[i].file_path), MovieDbResourcePool, cancellationToken).ConfigureAwait(false)); + item.BackdropImagePaths.Add(await ProviderManager.DownloadAndSaveImage(item, tmdbImageUrl + images.backdrops[i].file_path, bdName + Path.GetExtension(images.backdrops[i].file_path), ConfigurationManager.Configuration.SaveLocalMeta, MovieDbResourcePool, cancellationToken).ConfigureAwait(false)); } catch (HttpException) { diff --git a/MediaBrowser.Controller/Providers/Movies/TmdbPersonProvider.cs b/MediaBrowser.Controller/Providers/Movies/TmdbPersonProvider.cs index 583e0bb97..affd4757a 100644 --- a/MediaBrowser.Controller/Providers/Movies/TmdbPersonProvider.cs +++ b/MediaBrowser.Controller/Providers/Movies/TmdbPersonProvider.cs @@ -24,7 +24,7 @@ namespace MediaBrowser.Controller.Providers.Movies /// <summary> /// The meta file name /// </summary> - protected const string MetaFileName = "MBPerson.json"; + protected const string MetaFileName = "mbperson.js"; protected readonly IProviderManager ProviderManager; diff --git a/MediaBrowser.Controller/Providers/Music/FanArtAlbumProvider.cs b/MediaBrowser.Controller/Providers/Music/FanArtAlbumProvider.cs index f850722d1..4d7f78413 100644 --- a/MediaBrowser.Controller/Providers/Music/FanArtAlbumProvider.cs +++ b/MediaBrowser.Controller/Providers/Music/FanArtAlbumProvider.cs @@ -1,29 +1,34 @@ -using System.Collections.Generic; -using MediaBrowser.Common.Extensions; +using MediaBrowser.Common.Net; using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities.Audio; using MediaBrowser.Model.Entities; using MediaBrowser.Model.Logging; +using MediaBrowser.Model.Net; using System; +using System.IO; using System.Threading; using System.Threading.Tasks; +using System.Xml; namespace MediaBrowser.Controller.Providers.Music { public class FanArtAlbumProvider : FanartBaseProvider { private readonly IProviderManager _providerManager; - - public FanArtAlbumProvider(ILogManager logManager, IServerConfigurationManager configurationManager, IProviderManager providerManager) + + protected IHttpClient HttpClient { get; private set; } + + public FanArtAlbumProvider(IHttpClient httpClient, ILogManager logManager, IServerConfigurationManager configurationManager, IProviderManager providerManager) : base(logManager, configurationManager) { _providerManager = providerManager; + HttpClient = httpClient; } public override bool Supports(BaseItem item) { - return item is MusicAlbum && item.Parent is MusicArtist; + return item is MusicAlbum; } /// <summary> @@ -35,7 +40,7 @@ namespace MediaBrowser.Controller.Providers.Music protected override bool NeedsRefreshInternal(BaseItem item, BaseProviderInfo providerInfo) { //we fetch if image needed and haven't already tried recently - return string.IsNullOrEmpty(item.PrimaryImagePath) && + return (string.IsNullOrEmpty(item.PrimaryImagePath) || !item.HasImage(ImageType.Disc)) && DateTime.Today.Subtract(providerInfo.LastRefreshed).TotalDays > ConfigurationManager.Configuration.MetadataRefreshDays; } @@ -45,46 +50,81 @@ namespace MediaBrowser.Controller.Providers.Music if (mbid == null) { Logger.Warn("No Musicbrainz id associated with album {0}", item.Name); - SetLastRefreshed(item, DateTime.UtcNow, ProviderRefreshStatus.CompletedWithErrors); - return false; + SetLastRefreshed(item, DateTime.UtcNow); + return true; } cancellationToken.ThrowIfCancellationRequested(); - //Look at our parent for our album cover - var artist = (MusicArtist)item.Parent; + var url = string.Format("http://api.fanart.tv/webservice/album/{0}/{1}/xml/all/1/1", APIKey, item.GetProviderId(MetadataProviders.Musicbrainz)); - var cover = artist.AlbumCovers != null ? GetValueOrDefault(artist.AlbumCovers, mbid, null) : null; + var doc = new XmlDocument(); - if (cover == null) + try + { + using (var xml = await HttpClient.Get(url, FanArtResourcePool, cancellationToken).ConfigureAwait(false)) + { + doc.Load(xml); + } + } + catch (HttpException) { - Logger.Warn("Unable to find cover art for {0}", item.Name); - SetLastRefreshed(item, DateTime.UtcNow, ProviderRefreshStatus.CompletedWithErrors); - return false; } - item.SetImage(ImageType.Primary, await _providerManager.DownloadAndSaveImage(item, cover, "folder.jpg", FanArtResourcePool, cancellationToken).ConfigureAwait(false)); - return true; - } + cancellationToken.ThrowIfCancellationRequested(); - /// <summary> - /// Helper method for Dictionaries since they throw on not-found keys - /// </summary> - /// <typeparam name="T"></typeparam> - /// <typeparam name="U"></typeparam> - /// <param name="dictionary">The dictionary.</param> - /// <param name="key">The key.</param> - /// <param name="defaultValue">The default value.</param> - /// <returns>``1.</returns> - private static U GetValueOrDefault<T, U>(Dictionary<T, U> dictionary, T key, U defaultValue) - { - U val; - if (!dictionary.TryGetValue(key, out val)) + if (doc.HasChildNodes) { - val = defaultValue; + if (ConfigurationManager.Configuration.DownloadMusicAlbumImages.Disc && !item.ResolveArgs.ContainsMetaFileByName(DISC_FILE)) + { + var node = doc.SelectSingleNode("//fanart/music/albums/album//cdart/@url"); + + var path = node != null ? node.Value : null; + + if (!string.IsNullOrEmpty(path)) + { + Logger.Debug("FanArtProvider getting Disc for " + item.Name); + try + { + item.SetImage(ImageType.Disc, await _providerManager.DownloadAndSaveImage(item, path, DISC_FILE, ConfigurationManager.Configuration.SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false)); + } + catch (HttpException) + { + } + catch (IOException) + { + + } + } + } + + if (ConfigurationManager.Configuration.DownloadMusicAlbumImages.Primary && !item.ResolveArgs.ContainsMetaFileByName(PRIMARY_FILE)) + { + var node = doc.SelectSingleNode("//fanart/music/albums/album//albumcover/@url"); + + var path = node != null ? node.Value : null; + + if (!string.IsNullOrEmpty(path)) + { + Logger.Debug("FanArtProvider getting albumcover for " + item.Name); + try + { + item.SetImage(ImageType.Primary, await _providerManager.DownloadAndSaveImage(item, path, PRIMARY_FILE, ConfigurationManager.Configuration.SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false)); + } + catch (HttpException) + { + } + catch (IOException) + { + + } + } + } } - return val; + SetLastRefreshed(item, DateTime.UtcNow); + + return true; } } } diff --git a/MediaBrowser.Controller/Providers/Music/FanArtArtistByNameProvider.cs b/MediaBrowser.Controller/Providers/Music/FanArtArtistByNameProvider.cs new file mode 100644 index 000000000..58200a458 --- /dev/null +++ b/MediaBrowser.Controller/Providers/Music/FanArtArtistByNameProvider.cs @@ -0,0 +1,48 @@ +using MediaBrowser.Common.Net; +using MediaBrowser.Controller.Configuration; +using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Entities.Audio; +using MediaBrowser.Model.Logging; + +namespace MediaBrowser.Controller.Providers.Music +{ + /// <summary> + /// Class FanArtArtistByNameProvider + /// </summary> + public class FanArtArtistByNameProvider : FanArtArtistProvider + { + /// <summary> + /// Initializes a new instance of the <see cref="FanArtArtistByNameProvider" /> class. + /// </summary> + /// <param name="httpClient">The HTTP client.</param> + /// <param name="logManager">The log manager.</param> + /// <param name="configurationManager">The configuration manager.</param> + /// <param name="providerManager">The provider manager.</param> + public FanArtArtistByNameProvider(IHttpClient httpClient, ILogManager logManager, IServerConfigurationManager configurationManager, IProviderManager providerManager) + : base(httpClient, logManager, configurationManager, providerManager) + { + } + + /// <summary> + /// Supportses the specified item. + /// </summary> + /// <param name="item">The item.</param> + /// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns> + public override bool Supports(BaseItem item) + { + return item is Artist; + } + + /// <summary> + /// Gets a value indicating whether [save local meta]. + /// </summary> + /// <value><c>true</c> if [save local meta]; otherwise, <c>false</c>.</value> + protected override bool SaveLocalMeta + { + get + { + return true; + } + } + } +} diff --git a/MediaBrowser.Controller/Providers/Music/FanArtArtistProvider.cs b/MediaBrowser.Controller/Providers/Music/FanArtArtistProvider.cs index 1dd5c7cd2..ec99a78a7 100644 --- a/MediaBrowser.Controller/Providers/Music/FanArtArtistProvider.cs +++ b/MediaBrowser.Controller/Providers/Music/FanArtArtistProvider.cs @@ -18,7 +18,7 @@ namespace MediaBrowser.Controller.Providers.Music /// <summary> /// Class FanArtArtistProvider /// </summary> - class FanArtArtistProvider : FanartBaseProvider + public class FanArtArtistProvider : FanartBaseProvider { /// <summary> /// Gets the HTTP client. @@ -54,6 +54,11 @@ namespace MediaBrowser.Controller.Providers.Music return item is MusicArtist; } + protected virtual bool SaveLocalMeta + { + get { return ConfigurationManager.Configuration.SaveLocalMeta; } + } + /// <summary> /// Shoulds the fetch. /// </summary> @@ -62,16 +67,11 @@ namespace MediaBrowser.Controller.Providers.Music /// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns> protected override bool ShouldFetch(BaseItem item, BaseProviderInfo providerInfo) { - var artist = (MusicArtist)item; - if (item.Path == null || item.DontFetchMeta || string.IsNullOrEmpty(artist.GetProviderId(MetadataProviders.Musicbrainz))) return false; //nothing to do - var artExists = item.ResolveArgs.ContainsMetaFileByName(ART_FILE); - var logoExists = item.ResolveArgs.ContainsMetaFileByName(LOGO_FILE); - var discExists = item.ResolveArgs.ContainsMetaFileByName(DISC_FILE); + if (item.Path == null || item.DontFetchMeta || string.IsNullOrEmpty(item.GetProviderId(MetadataProviders.Musicbrainz))) return false; //nothing to do - return (!artExists && ConfigurationManager.Configuration.DownloadMusicArtistImages.Art) - || (!logoExists && ConfigurationManager.Configuration.DownloadMusicArtistImages.Logo) - || (!discExists && ConfigurationManager.Configuration.DownloadMusicArtistImages.Disc) - || ((artist.AlbumCovers == null || artist.AlbumCovers.Count == 0) && ConfigurationManager.Configuration.DownloadMusicAlbumImages.Primary); + return (!item.ResolveArgs.ContainsMetaFileByName(ART_FILE) && ConfigurationManager.Configuration.DownloadMusicArtistImages.Art) + || (!item.ResolveArgs.ContainsMetaFileByName(LOGO_FILE) && ConfigurationManager.Configuration.DownloadMusicArtistImages.Logo) + || (!item.ResolveArgs.ContainsMetaFileByName(DISC_FILE) && ConfigurationManager.Configuration.DownloadMusicArtistImages.Disc); } /// <summary> @@ -85,7 +85,7 @@ namespace MediaBrowser.Controller.Providers.Music { cancellationToken.ThrowIfCancellationRequested(); - var artist = (MusicArtist)item; + //var artist = item; BaseProviderInfo providerData; @@ -94,9 +94,9 @@ namespace MediaBrowser.Controller.Providers.Music providerData = new BaseProviderInfo(); } - if (ShouldFetch(artist, providerData)) + if (ShouldFetch(item, providerData)) { - var url = string.Format(FanArtBaseUrl, APIKey, artist.GetProviderId(MetadataProviders.Musicbrainz)); + var url = string.Format(FanArtBaseUrl, APIKey, item.GetProviderId(MetadataProviders.Musicbrainz)); var doc = new XmlDocument(); try @@ -124,10 +124,10 @@ namespace MediaBrowser.Controller.Providers.Music path = node != null ? node.Value : null; if (!string.IsNullOrEmpty(path)) { - Logger.Debug("FanArtProvider getting ClearLogo for " + artist.Name); + Logger.Debug("FanArtProvider getting ClearLogo for " + item.Name); try { - artist.SetImage(ImageType.Logo, await _providerManager.DownloadAndSaveImage(artist, path, LOGO_FILE, FanArtResourcePool, cancellationToken).ConfigureAwait(false)); + item.SetImage(ImageType.Logo, await _providerManager.DownloadAndSaveImage(item, path, LOGO_FILE, SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false)); } catch (HttpException) { @@ -146,16 +146,16 @@ namespace MediaBrowser.Controller.Providers.Music if (nodes != null) { var numBackdrops = 0; - artist.BackdropImagePaths = new List<string>(); + item.BackdropImagePaths = new List<string>(); foreach (XmlNode node in nodes) { path = node.Value; if (!string.IsNullOrEmpty(path)) { - Logger.Debug("FanArtProvider getting Backdrop for " + artist.Name); + Logger.Debug("FanArtProvider getting Backdrop for " + item.Name); try { - artist.BackdropImagePaths.Add(await _providerManager.DownloadAndSaveImage(artist, path, ("Backdrop" + (numBackdrops > 0 ? numBackdrops.ToString() : "") + ".jpg"), FanArtResourcePool, cancellationToken).ConfigureAwait(false)); + item.BackdropImagePaths.Add(await _providerManager.DownloadAndSaveImage(item, path, ("Backdrop" + (numBackdrops > 0 ? numBackdrops.ToString() : "") + ".jpg"), SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false)); numBackdrops++; if (numBackdrops >= ConfigurationManager.Configuration.MaxBackdrops) break; } @@ -175,32 +175,6 @@ namespace MediaBrowser.Controller.Providers.Music cancellationToken.ThrowIfCancellationRequested(); - if (ConfigurationManager.Configuration.DownloadMusicAlbumImages.Primary) - { - var nodes = doc.SelectNodes("//fanart/music/albums/*"); - if (nodes != null) - { - artist.AlbumCovers = new Dictionary<string, string>(); - foreach (XmlNode node in nodes) - { - - var key = node.Attributes["id"] != null ? node.Attributes["id"].Value : null; - var cover = node.SelectSingleNode("albumcover/@url"); - path = cover != null ? cover.Value : null; - - if (!string.IsNullOrEmpty(path) && !string.IsNullOrEmpty(key)) - { - Logger.Debug("FanArtProvider getting Album Cover for " + artist.Name); - artist.AlbumCovers[key] = path; - } - } - - } - - } - - cancellationToken.ThrowIfCancellationRequested(); - if (ConfigurationManager.Configuration.DownloadMusicArtistImages.Art && !item.ResolveArgs.ContainsMetaFileByName(ART_FILE)) { var node = @@ -209,10 +183,10 @@ namespace MediaBrowser.Controller.Providers.Music path = node != null ? node.Value : null; if (!string.IsNullOrEmpty(path)) { - Logger.Debug("FanArtProvider getting ClearArt for " + artist.Name); + Logger.Debug("FanArtProvider getting ClearArt for " + item.Name); try { - artist.SetImage(ImageType.Art, await _providerManager.DownloadAndSaveImage(artist, path, ART_FILE, FanArtResourcePool, cancellationToken).ConfigureAwait(false)); + item.SetImage(ImageType.Art, await _providerManager.DownloadAndSaveImage(item, path, ART_FILE, SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false)); } catch (HttpException) { @@ -232,10 +206,10 @@ namespace MediaBrowser.Controller.Providers.Music path = node != null ? node.Value : null; if (!string.IsNullOrEmpty(path)) { - Logger.Debug("FanArtProvider getting Banner for " + artist.Name); + Logger.Debug("FanArtProvider getting Banner for " + item.Name); try { - artist.SetImage(ImageType.Banner, await _providerManager.DownloadAndSaveImage(artist, path, BANNER_FILE, FanArtResourcePool, cancellationToken).ConfigureAwait(false)); + item.SetImage(ImageType.Banner, await _providerManager.DownloadAndSaveImage(item, path, BANNER_FILE, SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false)); } catch (HttpException) { @@ -256,10 +230,10 @@ namespace MediaBrowser.Controller.Providers.Music path = node != null ? node.Value : null; if (!string.IsNullOrEmpty(path)) { - Logger.Debug("FanArtProvider getting Primary image for " + artist.Name); + Logger.Debug("FanArtProvider getting Primary image for " + item.Name); try { - artist.SetImage(ImageType.Primary, await _providerManager.DownloadAndSaveImage(artist, path, PRIMARY_FILE, FanArtResourcePool, cancellationToken).ConfigureAwait(false)); + item.SetImage(ImageType.Primary, await _providerManager.DownloadAndSaveImage(item, path, PRIMARY_FILE, SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false)); } catch (HttpException) { @@ -272,7 +246,7 @@ namespace MediaBrowser.Controller.Providers.Music } } } - SetLastRefreshed(artist, DateTime.UtcNow); + SetLastRefreshed(item, DateTime.UtcNow); return true; } } diff --git a/MediaBrowser.Controller/Providers/Music/LastfmAlbumProvider.cs b/MediaBrowser.Controller/Providers/Music/LastfmAlbumProvider.cs index 697a6604c..b48999176 100644 --- a/MediaBrowser.Controller/Providers/Music/LastfmAlbumProvider.cs +++ b/MediaBrowser.Controller/Providers/Music/LastfmAlbumProvider.cs @@ -1,14 +1,15 @@ -using System.IO; -using System.Net; -using System.Threading; -using System.Threading.Tasks; -using MediaBrowser.Common.Net; +using MediaBrowser.Common.Net; using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities.Audio; using MediaBrowser.Model.Logging; -using MediaBrowser.Model.Net; using MediaBrowser.Model.Serialization; +using MoreLinq; +using System; +using System.IO; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; namespace MediaBrowser.Controller.Providers.Music { @@ -33,26 +34,7 @@ namespace MediaBrowser.Controller.Providers.Music protected override async Task FetchLastfmData(BaseItem item, string id, CancellationToken cancellationToken) { - // Get albu info using artist and album name - var url = RootUrl + string.Format("method=album.getInfo&artist={0}&album={1}&api_key={2}&format=json", UrlEncode(item.Parent.Name), UrlEncode(item.Name), ApiKey); - - LastfmGetAlbumResult result; - - try - { - using (var json = await HttpClient.Get(url, LastfmResourcePool, cancellationToken).ConfigureAwait(false)) - { - result = JsonSerializer.DeserializeFromStream<LastfmGetAlbumResult>(json); - } - } - catch (HttpException e) - { - if (e.StatusCode == HttpStatusCode.NotFound) - { - throw new LastfmProviderException(string.Format("Unable to retrieve album info for {0} with artist {1}", item.Name, item.Parent.Name)); - } - throw; - } + var result = await GetAlbumResult(item, cancellationToken).ConfigureAwait(false); if (result != null && result.album != null) { @@ -71,9 +53,60 @@ namespace MediaBrowser.Controller.Providers.Music } } + private async Task<LastfmGetAlbumResult> GetAlbumResult(BaseItem item, CancellationToken cancellationToken) + { + var result = await GetAlbumResult(item.Parent.Name, item.Name, cancellationToken); + + if (result != null && result.album != null) + { + return result; + } + + var folder = (Folder)item; + + // Get each song, distinct by the combination of AlbumArtist and Album + var songs = folder.Children.OfType<Audio>().DistinctBy(i => (i.AlbumArtist ?? string.Empty) + (i.Album ?? string.Empty), StringComparer.OrdinalIgnoreCase).ToList(); + + foreach (var song in songs.Where(song => !string.IsNullOrEmpty(song.Album) && !string.IsNullOrEmpty(song.AlbumArtist))) + { + result = await GetAlbumResult(song.AlbumArtist, song.Album, cancellationToken).ConfigureAwait(false); + + if (result != null && result.album != null) + { + return result; + } + } + + return null; + } + + private async Task<LastfmGetAlbumResult> GetAlbumResult(string artist, string album, CancellationToken cancellationToken) + { + // Get albu info using artist and album name + var url = RootUrl + string.Format("method=album.getInfo&artist={0}&album={1}&api_key={2}&format=json", UrlEncode(artist), UrlEncode(album), ApiKey); + + using (var json = await HttpClient.Get(url, LastfmResourcePool, cancellationToken).ConfigureAwait(false)) + { + return JsonSerializer.DeserializeFromStream<LastfmGetAlbumResult>(json); + } + } + + protected override Task FetchData(BaseItem item, CancellationToken cancellationToken) + { + return FetchLastfmData(item, string.Empty, cancellationToken); + } + public override bool Supports(BaseItem item) { return item is MusicAlbum; } + + protected override bool RefreshOnFileSystemStampChange + { + get + { + return true; + } + } } } diff --git a/MediaBrowser.Controller/Providers/Music/LastfmArtistByNameProvider.cs b/MediaBrowser.Controller/Providers/Music/LastfmArtistByNameProvider.cs new file mode 100644 index 000000000..f9ec2cc74 --- /dev/null +++ b/MediaBrowser.Controller/Providers/Music/LastfmArtistByNameProvider.cs @@ -0,0 +1,50 @@ +using MediaBrowser.Common.Net; +using MediaBrowser.Controller.Configuration; +using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Entities.Audio; +using MediaBrowser.Model.Logging; +using MediaBrowser.Model.Serialization; + +namespace MediaBrowser.Controller.Providers.Music +{ + /// <summary> + /// Class LastfmArtistByNameProvider + /// </summary> + public class LastfmArtistByNameProvider : LastfmArtistProvider + { + /// <summary> + /// Initializes a new instance of the <see cref="LastfmArtistByNameProvider"/> class. + /// </summary> + /// <param name="jsonSerializer">The json serializer.</param> + /// <param name="httpClient">The HTTP client.</param> + /// <param name="logManager">The log manager.</param> + /// <param name="configurationManager">The configuration manager.</param> + /// <param name="providerManager">The provider manager.</param> + public LastfmArtistByNameProvider(IJsonSerializer jsonSerializer, IHttpClient httpClient, ILogManager logManager, IServerConfigurationManager configurationManager, IProviderManager providerManager) + : base(jsonSerializer, httpClient, logManager, configurationManager, providerManager) + { + } + + /// <summary> + /// Gets a value indicating whether [save local meta]. + /// </summary> + /// <value><c>true</c> if [save local meta]; otherwise, <c>false</c>.</value> + protected override bool SaveLocalMeta + { + get + { + return true; + } + } + + /// <summary> + /// Supportses the specified item. + /// </summary> + /// <param name="item">The item.</param> + /// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns> + public override bool Supports(BaseItem item) + { + return item is Artist; + } + } +} diff --git a/MediaBrowser.Controller/Providers/Music/LastfmArtistProvider.cs b/MediaBrowser.Controller/Providers/Music/LastfmArtistProvider.cs index 8a17bcbf6..165b996f6 100644 --- a/MediaBrowser.Controller/Providers/Music/LastfmArtistProvider.cs +++ b/MediaBrowser.Controller/Providers/Music/LastfmArtistProvider.cs @@ -29,7 +29,7 @@ namespace MediaBrowser.Controller.Providers.Music //Execute the Artist search against our name and assume first one is the one we want var url = RootUrl + string.Format("method=artist.search&artist={0}&api_key={1}&format=json", UrlEncode(item.Name), ApiKey); - LastfmArtistSearchResults searchResult = null; + LastfmArtistSearchResults searchResult; try { @@ -60,29 +60,18 @@ namespace MediaBrowser.Controller.Providers.Music // Get artist info with provided id var url = RootUrl + string.Format("method=artist.getInfo&mbid={0}&api_key={1}&format=json", UrlEncode(id), ApiKey); - LastfmGetArtistResult result = null; + LastfmGetArtistResult result; - try + using (var json = await HttpClient.Get(url, LastfmResourcePool, cancellationToken).ConfigureAwait(false)) { - using (var json = await HttpClient.Get(url, LastfmResourcePool, cancellationToken).ConfigureAwait(false)) - { - result = JsonSerializer.DeserializeFromStream<LastfmGetArtistResult>(json); - } - } - catch (HttpException e) - { - if (e.StatusCode == HttpStatusCode.NotFound) - { - throw new LastfmProviderException(string.Format("Unable to retrieve artist info for {0} with id {1}", item.Name, id)); - } - throw; + result = JsonSerializer.DeserializeFromStream<LastfmGetArtistResult>(json); } if (result != null && result.artist != null) { LastfmHelper.ProcessArtistData(item, result.artist); //And save locally if indicated - if (ConfigurationManager.Configuration.SaveLocalMeta) + if (SaveLocalMeta) { var ms = new MemoryStream(); JsonSerializer.SerializeToStream(result.artist, ms); diff --git a/MediaBrowser.Controller/Providers/Music/LastfmBaseProvider.cs b/MediaBrowser.Controller/Providers/Music/LastfmBaseProvider.cs index f7e0eef48..dc586cb51 100644 --- a/MediaBrowser.Controller/Providers/Music/LastfmBaseProvider.cs +++ b/MediaBrowser.Controller/Providers/Music/LastfmBaseProvider.cs @@ -1,26 +1,17 @@ -using System.Collections.Generic; -using System.Net; -using MediaBrowser.Common.Net; -using MediaBrowser.Common.Extensions; +using MediaBrowser.Common.Net; using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Entities; using MediaBrowser.Model.Entities; using MediaBrowser.Model.Logging; +using MediaBrowser.Model.Serialization; using System; +using System.Collections.Generic; +using System.Net; using System.Threading; using System.Threading.Tasks; -using MediaBrowser.Model.Serialization; namespace MediaBrowser.Controller.Providers.Music { - class LastfmProviderException : ApplicationException - { - public LastfmProviderException(string msg) - : base(msg) - { - } - - } /// <summary> /// Class MovieDbProvider /// </summary> @@ -84,6 +75,14 @@ namespace MediaBrowser.Controller.Providers.Music /// </summary> protected string LocalMetaFileName { get; set; } + protected virtual bool SaveLocalMeta + { + get + { + return ConfigurationManager.Configuration.SaveLocalMeta; + } + } + /// <summary> /// If we save locally, refresh if they delete something /// </summary> @@ -91,7 +90,7 @@ namespace MediaBrowser.Controller.Providers.Music { get { - return ConfigurationManager.Configuration.SaveLocalMeta; + return SaveLocalMeta; } } @@ -173,16 +172,15 @@ namespace MediaBrowser.Controller.Providers.Music { if (item.DontFetchMeta) return false; - if (ConfigurationManager.Configuration.SaveLocalMeta && HasFileSystemStampChanged(item, providerInfo)) + if (RefreshOnFileSystemStampChange && HasFileSystemStampChanged(item, providerInfo)) { //If they deleted something from file system, chances are, this item was mis-identified the first time item.SetProviderId(MetadataProviders.Musicbrainz, null); Logger.Debug("LastfmProvider reports file system stamp change..."); return true; - } - if (providerInfo.LastRefreshStatus == ProviderRefreshStatus.CompletedWithErrors) + if (providerInfo.LastRefreshStatus != ProviderRefreshStatus.Success) { Logger.Debug("LastfmProvider for {0} - last attempt had errors. Will try again.", item.Path); return true; @@ -194,22 +192,10 @@ namespace MediaBrowser.Controller.Providers.Music return true; } - var downloadDate = providerInfo.LastRefreshed; - - if (ConfigurationManager.Configuration.MetadataRefreshDays == -1 && downloadDate != DateTime.MinValue) - { - return false; - } - - if (DateTime.Today.Subtract(item.DateCreated).TotalDays > 180 && downloadDate != DateTime.MinValue) - return false; // don't trigger a refresh data for item that are more than 6 months old and have been refreshed before - - if (DateTime.Today.Subtract(downloadDate).TotalDays < ConfigurationManager.Configuration.MetadataRefreshDays) // only refresh every n days - return false; - + if (DateTime.UtcNow.Subtract(providerInfo.LastRefreshed).TotalDays > ConfigurationManager.Configuration.MetadataRefreshDays) // only refresh every n days + return true; - Logger.Debug("LastfmProvider - " + item.Name + " needs refresh. Download date: " + downloadDate + " item created date: " + item.DateCreated + " Check for Update age: " + ConfigurationManager.Configuration.MetadataRefreshDays); - return true; + return false; } /// <summary> @@ -221,36 +207,9 @@ namespace MediaBrowser.Controller.Providers.Music /// <returns>Task{System.Boolean}.</returns> public override async Task<bool> FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken) { - if (item.DontFetchMeta) - { - Logger.Info("LastfmProvider - Not fetching because requested to ignore " + item.Name); - return false; - } - cancellationToken.ThrowIfCancellationRequested(); - BaseProviderInfo providerData; - - if (!item.ProviderData.TryGetValue(Id, out providerData)) - { - providerData = new BaseProviderInfo(); - } - - if (!ConfigurationManager.Configuration.SaveLocalMeta || !HasLocalMeta(item) || (force && !HasLocalMeta(item)) || (RefreshOnVersionChange && providerData.ProviderVersion != ProviderVersion)) - { - try - { - await FetchData(item, cancellationToken).ConfigureAwait(false); - SetLastRefreshed(item, DateTime.UtcNow); - } - catch (LastfmProviderException) - { - SetLastRefreshed(item, DateTime.UtcNow, ProviderRefreshStatus.CompletedWithErrors); - } - - return true; - } - Logger.Debug("LastfmProvider not fetching because local meta exists for " + item.Name); + await FetchData(item, cancellationToken).ConfigureAwait(false); SetLastRefreshed(item, DateTime.UtcNow); return true; } diff --git a/MediaBrowser.Controller/Providers/Music/LastfmHelper.cs b/MediaBrowser.Controller/Providers/Music/LastfmHelper.cs index 842d10e4d..442dd4b69 100644 --- a/MediaBrowser.Controller/Providers/Music/LastfmHelper.cs +++ b/MediaBrowser.Controller/Providers/Music/LastfmHelper.cs @@ -6,20 +6,23 @@ namespace MediaBrowser.Controller.Providers.Music { public static class LastfmHelper { - public static string LocalArtistMetaFileName = "MBArtist.json"; - public static string LocalAlbumMetaFileName = "MBAlbum.json"; + public static string LocalArtistMetaFileName = "mbartist.js"; + public static string LocalAlbumMetaFileName = "mbalbum.js"; public static void ProcessArtistData(BaseItem artist, LastfmArtist data) { - var overview = data.bio != null ? data.bio.content : null; - - artist.Overview = overview; - var yearFormed = 0; if (data.bio != null) { Int32.TryParse(data.bio.yearformed, out yearFormed); + + artist.Overview = data.bio.content; + + if (!string.IsNullOrEmpty(data.bio.placeformed)) + { + artist.AddProductionLocation(data.bio.placeformed); + } } artist.PremiereDate = yearFormed > 0 ? new DateTime(yearFormed, 1,1) : DateTime.MinValue; @@ -52,7 +55,10 @@ namespace MediaBrowser.Controller.Providers.Music { foreach (var tag in tags.tag) { - item.AddGenre(tag.name); + if (!string.IsNullOrEmpty(tag.name)) + { + item.AddGenre(tag.name); + } } } } diff --git a/MediaBrowser.Controller/Providers/TV/FanArtTVProvider.cs b/MediaBrowser.Controller/Providers/TV/FanArtTVProvider.cs index a7fc4586f..cdbfb0883 100644 --- a/MediaBrowser.Controller/Providers/TV/FanArtTVProvider.cs +++ b/MediaBrowser.Controller/Providers/TV/FanArtTVProvider.cs @@ -100,7 +100,7 @@ namespace MediaBrowser.Controller.Providers.TV Logger.Debug("FanArtProvider getting ClearLogo for " + series.Name); try { - series.SetImage(ImageType.Logo, await _providerManager.DownloadAndSaveImage(series, path, LOGO_FILE, FanArtResourcePool, cancellationToken).ConfigureAwait(false)); + series.SetImage(ImageType.Logo, await _providerManager.DownloadAndSaveImage(series, path, LOGO_FILE, ConfigurationManager.Configuration.SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false)); } catch (HttpException) { @@ -124,7 +124,7 @@ namespace MediaBrowser.Controller.Providers.TV Logger.Debug("FanArtProvider getting ClearArt for " + series.Name); try { - series.SetImage(ImageType.Art, await _providerManager.DownloadAndSaveImage(series, path, ART_FILE, FanArtResourcePool, cancellationToken).ConfigureAwait(false)); + series.SetImage(ImageType.Art, await _providerManager.DownloadAndSaveImage(series, path, ART_FILE, ConfigurationManager.Configuration.SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false)); } catch (HttpException) { @@ -148,7 +148,7 @@ namespace MediaBrowser.Controller.Providers.TV Logger.Debug("FanArtProvider getting ThumbArt for " + series.Name); try { - series.SetImage(ImageType.Disc, await _providerManager.DownloadAndSaveImage(series, path, THUMB_FILE, FanArtResourcePool, cancellationToken).ConfigureAwait(false)); + series.SetImage(ImageType.Disc, await _providerManager.DownloadAndSaveImage(series, path, THUMB_FILE, ConfigurationManager.Configuration.SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false)); } catch (HttpException) { diff --git a/MediaBrowser.Controller/Providers/TV/RemoteEpisodeProvider.cs b/MediaBrowser.Controller/Providers/TV/RemoteEpisodeProvider.cs index b5c6df7ec..74cb1bfd4 100644 --- a/MediaBrowser.Controller/Providers/TV/RemoteEpisodeProvider.cs +++ b/MediaBrowser.Controller/Providers/TV/RemoteEpisodeProvider.cs @@ -233,7 +233,7 @@ namespace MediaBrowser.Controller.Providers.TV try { - episode.PrimaryImagePath = await _providerManager.DownloadAndSaveImage(episode, TVUtils.BannerUrl + p, Path.GetFileName(p), RemoteSeriesProvider.Current.TvDbResourcePool, cancellationToken); + episode.PrimaryImagePath = await _providerManager.DownloadAndSaveImage(episode, TVUtils.BannerUrl + p, Path.GetFileName(p), ConfigurationManager.Configuration.SaveLocalMeta, RemoteSeriesProvider.Current.TvDbResourcePool, cancellationToken); } catch (HttpException) { diff --git a/MediaBrowser.Controller/Providers/TV/RemoteSeasonProvider.cs b/MediaBrowser.Controller/Providers/TV/RemoteSeasonProvider.cs index f39e91834..9d1a7c256 100644 --- a/MediaBrowser.Controller/Providers/TV/RemoteSeasonProvider.cs +++ b/MediaBrowser.Controller/Providers/TV/RemoteSeasonProvider.cs @@ -177,7 +177,7 @@ namespace MediaBrowser.Controller.Providers.TV try { if (n != null) - season.PrimaryImagePath = await _providerManager.DownloadAndSaveImage(season, TVUtils.BannerUrl + n.InnerText, "folder" + Path.GetExtension(n.InnerText), RemoteSeriesProvider.Current.TvDbResourcePool, cancellationToken).ConfigureAwait(false); + season.PrimaryImagePath = await _providerManager.DownloadAndSaveImage(season, TVUtils.BannerUrl + n.InnerText, "folder" + Path.GetExtension(n.InnerText), ConfigurationManager.Configuration.SaveLocalMeta, RemoteSeriesProvider.Current.TvDbResourcePool, cancellationToken).ConfigureAwait(false); } catch (HttpException) { @@ -204,7 +204,7 @@ namespace MediaBrowser.Controller.Providers.TV TVUtils.BannerUrl + n.InnerText, "banner" + Path.GetExtension(n.InnerText), - RemoteSeriesProvider.Current.TvDbResourcePool, cancellationToken). + ConfigurationManager.Configuration.SaveLocalMeta, RemoteSeriesProvider.Current.TvDbResourcePool, cancellationToken). ConfigureAwait(false); season.SetImage(ImageType.Banner, bannerImagePath); @@ -231,7 +231,7 @@ namespace MediaBrowser.Controller.Providers.TV try { if (season.BackdropImagePaths == null) season.BackdropImagePaths = new List<string>(); - season.BackdropImagePaths.Add(await _providerManager.DownloadAndSaveImage(season, TVUtils.BannerUrl + n.InnerText, "backdrop" + Path.GetExtension(n.InnerText), RemoteSeriesProvider.Current.TvDbResourcePool, cancellationToken).ConfigureAwait(false)); + season.BackdropImagePaths.Add(await _providerManager.DownloadAndSaveImage(season, TVUtils.BannerUrl + n.InnerText, "backdrop" + Path.GetExtension(n.InnerText), ConfigurationManager.Configuration.SaveLocalMeta, RemoteSeriesProvider.Current.TvDbResourcePool, cancellationToken).ConfigureAwait(false)); } catch (HttpException) { @@ -265,7 +265,7 @@ namespace MediaBrowser.Controller.Providers.TV "backdrop" + Path.GetExtension( n.InnerText), - RemoteSeriesProvider.Current.TvDbResourcePool, cancellationToken) + ConfigurationManager.Configuration.SaveLocalMeta, RemoteSeriesProvider.Current.TvDbResourcePool, cancellationToken) .ConfigureAwait(false)); } catch (HttpException) diff --git a/MediaBrowser.Controller/Providers/TV/RemoteSeriesProvider.cs b/MediaBrowser.Controller/Providers/TV/RemoteSeriesProvider.cs index 89cb89289..5a68981bf 100644 --- a/MediaBrowser.Controller/Providers/TV/RemoteSeriesProvider.cs +++ b/MediaBrowser.Controller/Providers/TV/RemoteSeriesProvider.cs @@ -228,7 +228,7 @@ namespace MediaBrowser.Controller.Providers.TV string n = doc.SafeGetString("//banner"); if (!string.IsNullOrWhiteSpace(n)) { - series.SetImage(ImageType.Banner, await _providerManager.DownloadAndSaveImage(series, TVUtils.BannerUrl + n, "banner" + Path.GetExtension(n), TvDbResourcePool, cancellationToken).ConfigureAwait(false)); + series.SetImage(ImageType.Banner, await _providerManager.DownloadAndSaveImage(series, TVUtils.BannerUrl + n, "banner" + Path.GetExtension(n), ConfigurationManager.Configuration.SaveLocalMeta, TvDbResourcePool, cancellationToken).ConfigureAwait(false)); } string s = doc.SafeGetString("//Network"); @@ -369,7 +369,7 @@ namespace MediaBrowser.Controller.Providers.TV { try { - series.PrimaryImagePath = await _providerManager.DownloadAndSaveImage(series, TVUtils.BannerUrl + n.InnerText, "folder" + Path.GetExtension(n.InnerText), TvDbResourcePool, cancellationToken).ConfigureAwait(false); + series.PrimaryImagePath = await _providerManager.DownloadAndSaveImage(series, TVUtils.BannerUrl + n.InnerText, "folder" + Path.GetExtension(n.InnerText), ConfigurationManager.Configuration.SaveLocalMeta, TvDbResourcePool, cancellationToken).ConfigureAwait(false); } catch (HttpException) { @@ -392,7 +392,7 @@ namespace MediaBrowser.Controller.Providers.TV { try { - var bannerImagePath = await _providerManager.DownloadAndSaveImage(series, TVUtils.BannerUrl + n.InnerText, "banner" + Path.GetExtension(n.InnerText), TvDbResourcePool, cancellationToken); + var bannerImagePath = await _providerManager.DownloadAndSaveImage(series, TVUtils.BannerUrl + n.InnerText, "banner" + Path.GetExtension(n.InnerText), ConfigurationManager.Configuration.SaveLocalMeta, TvDbResourcePool, cancellationToken); series.SetImage(ImageType.Banner, bannerImagePath); } @@ -421,7 +421,7 @@ namespace MediaBrowser.Controller.Providers.TV { try { - series.BackdropImagePaths.Add(await _providerManager.DownloadAndSaveImage(series, TVUtils.BannerUrl + p.InnerText, bdName + Path.GetExtension(p.InnerText), TvDbResourcePool, cancellationToken).ConfigureAwait(false)); + series.BackdropImagePaths.Add(await _providerManager.DownloadAndSaveImage(series, TVUtils.BannerUrl + p.InnerText, bdName + Path.GetExtension(p.InnerText), ConfigurationManager.Configuration.SaveLocalMeta, TvDbResourcePool, cancellationToken).ConfigureAwait(false)); } catch (HttpException) { diff --git a/MediaBrowser.Controller/packages.config b/MediaBrowser.Controller/packages.config new file mode 100644 index 000000000..44996f0e8 --- /dev/null +++ b/MediaBrowser.Controller/packages.config @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="utf-8"?> +<packages> + <package id="morelinq" version="1.0.15631-beta" targetFramework="net45" /> +</packages>
\ No newline at end of file |
