/// <summary> /// Get the Album Artwork from Mediaportal folder /// </summary> /// <param name="mvArtistObject"></param> /// <returns></returns> private bool getMPAlbumArt(DBAlbumInfo mvAlbumObject) { logger.Debug("In Method: getMPAlbumArt(DBAlbumInfo mvAlbumObject)"); bool found = false; string artist = string.Empty; string album = mvAlbumObject.Album; List <DBTrackInfo> a1 = DBTrackInfo.GetEntriesByAlbum(mvAlbumObject); if (a1.Count > 0) { artist = a1[0].ArtistInfo[0].Artist; } string thumbFolder = Thumbs.MusicAlbum; string cleanTitle = string.Format("{0}-{1}", MediaPortal.Util.Utils.MakeFileName(artist), MediaPortal.Util.Utils.MakeFileName(album)); string filename = thumbFolder + @"\" + cleanTitle + "L.jpg"; if (File.Exists(filename)) { found &= mvAlbumObject.AddArtFromFile(filename); } logger.Debug("In Method: getMPAlbumArt(DBAlbumInfo mvAlbumObject) filename: " + filename + " - " + found); return(found); }
/// <summary> /// Get the album details /// </summary> /// <param name="basicInfo"></param> /// <param name="albumTitle"></param> /// <param name="albumMbid"></param> /// <returns></returns> public bool GetAlbumDetails(DBBasicInfo basicInfo, string albumTitle, string albumMbid) { List <DBTrackInfo> tracksOnAlbum = DBTrackInfo.GetEntriesByAlbum((DBAlbumInfo)basicInfo); if (tracksOnAlbum.Count > 0) { string artist = tracksOnAlbum[0].ArtistInfo[0].Artist; DBAlbumInfo mv1 = (DBAlbumInfo)basicInfo; basicInfo.ArtUrls.Clear(); setMusicVideoAlbum(ref mv1, albumMbid); GetAlbumArt((DBAlbumInfo)basicInfo); } return(true); }
public bool GetAlbumDetails(DBBasicInfo basicInfo, string albumTitle, string albumMbid) { logger.Debug("In Method: GetAlbumDetails(DBBasicInfo basicInfo, Album: " + albumTitle + " MBID: " + albumMbid + ")"); List <DBTrackInfo> tracksOnAlbum = DBTrackInfo.GetEntriesByAlbum((DBAlbumInfo)basicInfo); if (tracksOnAlbum.Count > 0) { string artist = tracksOnAlbum[0].ArtistInfo[0].Artist; DBAlbumInfo mv1 = (DBAlbumInfo)basicInfo; basicInfo.ArtUrls.Clear(); setMusicVideoAlbum(ref mv1, artist, albumTitle, albumMbid); GetAlbumArt((DBAlbumInfo)basicInfo); } return(true); }
private void AlbumActions(MediaPortal.GUI.Library.Action.ActionType actionType) { if ((actionType == Action.ActionType.ACTION_MUSIC_PLAY) || (actionType == Action.ActionType.ACTION_PLAY) || (actionType == Action.ActionType.ACTION_PAUSE)) { if ((actionType == Action.ActionType.ACTION_MUSIC_PLAY) || (actionType == Action.ActionType.ACTION_PLAY) || (actionType == Action.ActionType.ACTION_PAUSE && !g_Player.HasVideo)) { DBArtistInfo currArtist = DBArtistInfo.Get(facadeLayout.SelectedListItem.Label); List <DBTrackInfo> allTracksOnAlbum = DBTrackInfo.GetEntriesByAlbum((DBAlbumInfo)facadeLayout.SelectedListItem.MusicTag); AddToPlaylist(allTracksOnAlbum, true, mvCentralCore.Settings.ClearPlaylistOnAdd, mvCentralCore.Settings.GeneratedPlaylistAutoShuffle); } else { _currentView = MvView.Artist; artistID = facadeLayout.SelectedListItem.ItemId; logger.Debug("Calling loadCurrent from AlbumActions"); loadCurrent(); } } }
/// <summary> /// Get the Artist, Album Details /// </summary> /// <param name="mv"></param> /// <returns></returns> public bool GetDetails(DBBasicInfo mv) { string strArtistHTML; string strAlbumHTML; string strArtistURL; ReportProgress(string.Empty); // Get details of the artist if (mv.GetType() == typeof(DBArtistInfo)) { string artist = ((DBArtistInfo)mv).Artist; ReportProgress("Getting Artist..."); if (GetArtistHTML(artist, out strArtistHTML, out strArtistURL)) { var artistInfo = AMGHTMLParser.ParseArtistHTML(strArtistHTML, artist); if (artistInfo != null) { artistInfo.Artist = artist; DBArtistInfo mv1 = (DBArtistInfo)mv; SetMusicVideoArtist(ref mv1, artistInfo, strArtistHTML); GetArtistArt((DBArtistInfo)mv); ReportProgress("Done..."); return(true); } } return(false); } // get details of the album if (mv.GetType() == typeof(DBAlbumInfo)) { string album = ((DBAlbumInfo)mv).Album; List <DBTrackInfo> trackList = DBTrackInfo.GetEntriesByAlbum((DBAlbumInfo)mv); DBArtistInfo artist = DBArtistInfo.Get(trackList[0]); if (GetAlbumHTML(artist.Artist, album, out strAlbumHTML)) { var albumInfo = AMGHTMLParser.ParseAlbumHTML(strAlbumHTML, album, artist.Artist); if (albumInfo != null) { albumInfo.Artist = album; DBAlbumInfo mv1 = (DBAlbumInfo)mv; SetMusicVideoAlbum(ref mv1, albumInfo); } } return(false); } // get details of the track if (mv.GetType() == typeof(DBTrackInfo)) { if (((DBTrackInfo)mv).LocalMedia[0].IsDVD) { string track = ((DBTrackInfo)mv).Track; GetDVDDetails((DBTrackInfo)mv); return(true); } else { string track = ((DBTrackInfo)mv).Track; GetTrackDetails((DBTrackInfo)mv); return(true); } } return(true); }
/// <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); }
public bool GetDetails(DBBasicInfo mv) { if (mv.GetType() == typeof(DBAlbumInfo)) { List <DBTrackInfo> a1 = DBTrackInfo.GetEntriesByAlbum((DBAlbumInfo)mv); if (a1.Count > 0) { string artist = a1[0].ArtistInfo[0].Artist; //first get artist info XmlNodeList xml = null; if (artist != null) { xml = getXML(apiArtistGetInfo, artist); } else { return(false); } if (xml == null) { return(false); } XmlNode root = xml.Item(0).ParentNode; if (root.Attributes != null && root.Attributes["stat"].Value != "ok") { return(false); } XmlNode n1 = root.SelectSingleNode(@"/resp/artist/releases"); List <Release> r1 = new List <Release>(); foreach (XmlNode x1 in n1.ChildNodes) { Release r2 = new Release(x1); r1.Add(r2); } r1.Sort(Release.TitleComparison); DetailsPopup d1 = new DetailsPopup(r1); if (d1.ShowDialog() == DialogResult.OK) { DBAlbumInfo mv1 = (DBAlbumInfo)mv; setMusicVideoAlbum(ref mv1, d1.label8.Text); GetAlbumArt((DBAlbumInfo)mv); } ; } } if (mv.GetType() == typeof(DBTrackInfo)) { string artist = ((DBTrackInfo)mv).ArtistInfo[0].Artist; //first get artist info XmlNodeList xml = null; if (artist != null) { xml = getXML(apiArtistGetInfo, artist); } else { return(false); } if (xml == null) { return(false); } XmlNode root = xml.Item(0).ParentNode; if (root.Attributes != null && root.Attributes["stat"].Value != "ok") { return(false); } XmlNode n1 = root.SelectSingleNode(@"/resp/artist/releases"); if (n1 == null) { return(false); } List <Release> r1 = new List <Release>(); foreach (XmlNode x1 in n1.ChildNodes) { Release r2 = new Release(x1); r1.Add(r2); } r1.Sort(Release.TitleComparison); DetailsPopup d1 = new DetailsPopup(r1); if (d1.ShowDialog() == DialogResult.OK) { DBTrackInfo mv1 = (DBTrackInfo)mv; setMusicVideoTrack(ref mv1, d1.label8.Text); GetTrackArt((DBTrackInfo)mv); } ; } return(true); }
public bool GetDetails(DBBasicInfo mv) { logger.Debug("In Method: GetDetails(DBBasicInfo mv)"); MusicDatabase m_db = null; string inLang = mvCentralCore.Settings.DataProviderAutoLanguage; ReportProgress(string.Empty); try { m_db = MusicDatabase.Instance; } catch (Exception e) { logger.Error("GetDetails: Music database init failed " + e.ToString()); return(false); } // ---------------- Get Artist Info --------------------- if (mv.GetType() == typeof(DBArtistInfo)) { var artist = ((DBArtistInfo)mv).Artist; var releases = new List <Release>(); var artists = new ArrayList(); // Grab the Artist Info if (artist != null) { ReportProgress("Getting Artists..."); logger.Debug("GetDetails: Getting Artists: " + artist); artists.Clear(); string strArtist = NormalizeArtist(artist); string strSQL = String.Format("SELECT a.strArtist FROM artist a, artistinfo i WHERE LOWER(a.strArtist) = LOWER(i.strArtist) AND i.strAMGBio IS NOT NULL AND TRIM(i.strAMGBio) <> '' AND LOWER(i.strArtist) LIKE '%{0}%';", strArtist); List <Song> songInfo = new List <Song>(); m_db.GetSongsByFilter(strSQL, out songInfo, "artist"); foreach (Song mySong in songInfo) { if (!string.IsNullOrEmpty(mySong.Artist)) { artists.Add(mySong.Artist); } } } else { return(false); } if (artists == null || artists.Count <= 0) { return(false); } foreach (string _artist in artists) { Release r2 = new Release(_artist, string.Empty); releases.Add(r2); } ReportProgress("Done!"); // Now sort and Display the retrived matches releases.Sort(Release.TitleComparison); var resultsDialog = new DetailsPopup(releases); // Get the full info for the selection if (resultsDialog.ShowDialog() == DialogResult.OK) { var mv1 = (DBArtistInfo)mv; mv.ArtUrls.Clear(); string title = resultsDialog.selectedItem.Text; string mbid = resultsDialog.label8.Text; if (title.Trim().Length == 0) { title = null; } if (mbid.Trim().Length == 0) { mbid = null; } setMusicVideoArtist(ref mv1, title, mbid); GetArtistArt((DBArtistInfo)mv); } } // -------------- Get Album Info -------------- if (mv.GetType() == typeof(DBAlbumInfo)) { List <DBTrackInfo> a1 = DBTrackInfo.GetEntriesByAlbum((DBAlbumInfo)mv); if (a1.Count > 0) { string artist = a1[0].ArtistInfo[0].Artist; var albums = new ArrayList();; if (artist != null) { ReportProgress("Getting Albums..."); logger.Debug("GetDetails: Getting Albums: " + artist); albums.Clear(); string strArtist = NormalizeArtist(artist); string strSQL = String.Format("SELECT DISTINCT T.strAlbum, A.strReview FROM albuminfo A, tracks T WHERE A.strReview IS NOT NULL AND TRIM(A.strReview) <> '' AND (A.strArtist LIKE '%{0}%' OR A.strAlbumArtist LIKE '%{1}%') AND T.strAlbum = A.strAlbum COLLATE NOCASE;", strArtist, strArtist); List <Song> songInfo = new List <Song>(); m_db.GetSongsByFilter(strSQL, out songInfo, "album"); logger.Debug("GetDetails: Getting Albums: " + artist + " - " + songInfo.Count); foreach (Song mySong in songInfo) { if (!string.IsNullOrEmpty(mySong.Album)) { albums.Add(mySong.Album); } } } else { return(false); } if (albums == null || albums.Count <= 0) { return(false); } List <Release> artistTopAlbumns = new List <Release>(); foreach (string _album in albums) { logger.Debug("GetDetails: Getting Albums: " + artist + " - " + _album); Release r2 = new Release(_album, string.Empty); artistTopAlbumns.Add(r2); } ReportProgress("Done!"); artistTopAlbumns.Sort(Release.TitleComparison); DetailsPopup d1 = new DetailsPopup(artistTopAlbumns); if (d1.ShowDialog() == DialogResult.OK) { DBAlbumInfo mv1 = (DBAlbumInfo)mv; mv.ArtUrls.Clear(); string title = d1.selectedItem.Text; string mbid = d1.label8.Text; if (title.Trim().Length == 0) { title = null; } if (mbid.Trim().Length == 0) { mbid = null; } setMusicVideoAlbum(ref mv1, artist, title, mbid); GetAlbumArt((DBAlbumInfo)mv); } } } // -------------- Get Track Info -------------- if (mv.GetType() == typeof(DBTrackInfo)) { string artist = ((DBTrackInfo)mv).ArtistInfo[0].Artist; var tracks = new ArrayList();; if (artist != null) { ReportProgress("Getting Tracks..."); logger.Debug("GetDetails: Getting Tracks: " + artist); tracks.Clear(); string strArtist = NormalizeArtist(artist); string strSQL = String.Format("SELECT strTitle FROM tracks WHERE strArtist LIKE '%| {0} |%' OR strAlbumArtist LIKE '%| {1} |%';');", strArtist, strArtist); List <Song> songInfo = new List <Song>(); m_db.GetSongsByFilter(strSQL, out songInfo, "tracks"); logger.Debug("GetDetails: Getting Tracks: " + artist + " - " + songInfo.Count); foreach (Song mySong in songInfo) { if (!string.IsNullOrEmpty(mySong.Title)) { tracks.Add(mySong.Title); } } } else { return(false); } if (tracks == null || tracks.Count <= 0) { return(false); } List <Release> artistTopTracks = new List <Release>(); foreach (string _track in tracks) { logger.Debug("GetDetails: Getting Track: " + artist + " - " + _track); Release r2 = new Release(_track, string.Empty); artistTopTracks.Add(r2); } ReportProgress("Done!"); artistTopTracks.Sort(Release.TitleComparison); DetailsPopup d1 = new DetailsPopup(artistTopTracks); if (d1.ShowDialog() == DialogResult.OK) { DBTrackInfo mv1 = (DBTrackInfo)mv; mv.ArtUrls.Clear(); if (artist.Trim().Length == 0) { artist = null; } string title = d1.selectedItem.Text; string mbid = d1.label8.Text; if (title.Trim().Length == 0) { title = null; } if (mbid.Trim().Length == 0) { mbid = null; } setMusicVideoTrack(ref mv1, artist, title, mbid); GetTrackArt((DBTrackInfo)mv); } } return(true); }