/// <summary> /// Get the Album Art /// </summary> /// <param name="mv"></param> /// <returns></returns> public bool GetAlbumArt(DBAlbumInfo mvAlbumObject) { Logger.Debug("In Method : GetAlbumArt(DBAlbumInfo mv)"); if (mvAlbumObject == null) return false; List<string> albumImageList = mvAlbumObject.ArtUrls; // Reload existing Artwork - Why springs to mind?? if (albumImageList.Count > 0) { // grab album art loading settings int maxAlbumArt = mvCentralCore.Settings.MaxAlbumArts; int albumartAdded = 0; int count = 0; foreach (string albumImage in albumImageList) { if (mvAlbumObject.AlternateArts.Count >= maxAlbumArt) break; if (mvAlbumObject.AddArtFromURL(albumImage) == ImageLoadResults.SUCCESS) albumartAdded++; count++; } // We added some artwork so commit if (count > 0) mvAlbumObject.Commit(); } // Now add any new art from this provider string strAlbumHTML; DBArtistInfo artist = null; List<DBTrackInfo> tracksOnAlbum = DBTrackInfo.GetEntriesByAlbum(mvAlbumObject); if (tracksOnAlbum.Count > 0) { artist = DBArtistInfo.Get(tracksOnAlbum[0]); if (GetAlbumHTML(artist.Artist, mvAlbumObject.Album, out strAlbumHTML)) { var albumInfo = new MusicAlbumInfo(); if (albumInfo.Parse(strAlbumHTML)) { ImageLoadResults imageLoadResults = mvAlbumObject.AddArtFromURL(albumInfo.ImageURL); if (imageLoadResults == ImageLoadResults.SUCCESS || imageLoadResults == ImageLoadResults.SUCCESS_REDUCED_SIZE) mvAlbumObject.Commit(); } } } // We always return sucess... return true; }
/// <summary> /// Get the Album Art /// </summary> /// <param name="mv"></param> /// <returns></returns> public bool GetAlbumArt(DBAlbumInfo mv) { if (string.IsNullOrEmpty(mv.MdID.Trim())) return false; logger.Debug("In Method: GetAlbumArt(DBAlbumInfo mv)"); // Get the images // If we have a MBID for this Artist use this to retrive the image otherwise fall back to keyword search var html = getJSON(SearchAlbumImage, APIKey, mv.MdID.Trim()); // If we reveived nothing back, bail out if (string.IsNullOrEmpty(html)) return false; int albumartAdded = 0; var URLList = new List<string>(); URLList = ExtractURL("albumcover", html); if (URLList != null) { foreach (string _url in URLList) { var _fileURL = _url.Substring(checked(_url.IndexOf("|") + 1)); if (mv.AddArtFromURL(_fileURL) == ImageLoadResults.SUCCESS) albumartAdded++; } } return (albumartAdded > 0); }