private void setMusicVideoArtist(ref DBArtistInfo mv, string artistName, string artistmbid) { if (string.IsNullOrEmpty(artistName)) { return; } logger.Debug("In Method: setMusicVideoArtist(ref DBArtistInfo mv, Artist: " + artistName + " MBID: " + artistmbid + ")"); MusicDatabase m_db = null; try { m_db = MusicDatabase.Instance; } catch (Exception e) { logger.Error("setMusicVideoArtist: Music database init failed " + e.ToString()); return; } var artistInfo = new MediaPortal.Music.Database.ArtistInfo(); if (!m_db.GetArtistInfo(artistName, ref artistInfo)) { return; } // Name mv.Artist = artistName; // MBID // mv.MdID = // Tags char[] delimiters = new char[] { ',' }; string[] tags = artistInfo.Genres.Split(delimiters, StringSplitOptions.RemoveEmptyEntries); foreach (string tag in tags) { mv.Tag.Add(tag.Trim()); } tags = artistInfo.Styles.Split(delimiters, StringSplitOptions.RemoveEmptyEntries); foreach (string tag in tags) { mv.Tag.Add(tag.Trim()); } // Bio mv.bioSummary = artistInfo.AMGBio; mv.bioContent = artistInfo.AMGBio; // Additional mv.Born = artistInfo.Born; mv.Genre = artistInfo.Genres; mv.Styles = artistInfo.Styles; mv.YearsActive = artistInfo.YearsActive; // Image URL if (!string.IsNullOrEmpty(artistInfo.Image) && !mv.ArtUrls.Contains(artistInfo.Image)) { mv.ArtUrls.Add(artistInfo.Image); } }
/// <summary> /// Set the ArtistInfo /// </summary> /// <param name="artist"></param> public void Set(ArtistInfo artist) { Artist = artist.Artist; Born = artist.Born; YearsActive = artist.YearsActive; Genres = artist.Genres; Tones = artist.Tones; Styles = artist.Styles; Instruments = artist.Instruments; AMGBiography = artist.AMGBio; ImageURL = artist.Image; Albums = artist.Albums; Compilations = artist.Compilations; Singles = artist.Singles; Misc = artist.Misc; _bLoaded = true; }
public ArtistInfo Clone() { ArtistInfo newartist = new ArtistInfo(); newartist.Artist = Artist; newartist.Born = Born; newartist.YearsActive = YearsActive; newartist.Genres = Genres; newartist.Tones = Tones; newartist.Styles = Styles; newartist.Image = Image; newartist.Instruments = Instruments; newartist.AMGBio = AMGBio; newartist.Albums = Albums; newartist.Compilations = Compilations; newartist.Singles = Singles; newartist.Misc = Misc; return newartist; }
public ArtistInfo Clone() { ArtistInfo newartist = new ArtistInfo(); newartist.Artist = Artist; newartist.Born = Born; newartist.YearsActive = YearsActive; newartist.Genres = Genres; newartist.Tones = Tones; newartist.Styles = Styles; newartist.Image = Image; newartist.Instruments = Instruments; newartist.AMGBio = AMGBio; newartist.Albums = Albums; newartist.Compilations = Compilations; newartist.Singles = Singles; newartist.Misc = Misc; return(newartist); }
public ArtistInfo Clone() { var newartist = new ArtistInfo { Artist = Artist, Born = Born, YearsActive = YearsActive, Genres = Genres, Tones = Tones, Styles = Styles, Image = Image, Instruments = Instruments, AMGBio = AMGBio, Albums = Albums, Compilations = Compilations, Singles = Singles, Misc = Misc }; return newartist; }
public ArtistInfo Clone() { var newartist = new ArtistInfo { Artist = Artist, Born = Born, YearsActive = YearsActive, Genres = Genres, Tones = Tones, Styles = Styles, Image = Image, Instruments = Instruments, AMGBio = AMGBio, Albums = Albums, Compilations = Compilations, Singles = Singles, Misc = Misc }; return(newartist); }
/// <summary> /// Return the Artist Info /// </summary> /// <returns></returns> public ArtistInfo Get() { ArtistInfo artist = new ArtistInfo(); if (_bLoaded) { artist.Artist = Artist; artist.Born = Born; artist.YearsActive = YearsActive; artist.Genres = Genres; artist.Tones = Tones; artist.Styles = Styles; artist.Instruments = Instruments; artist.AMGBio = AMGBiography; artist.Image = ImageURL; artist.Albums = Albums; artist.Compilations = Compilations; artist.Singles = Singles; artist.Misc = Misc; } return(artist); }
/// <summary> /// Parse the Detail Page returned from the Allmusic Scraper /// </summary> /// <param name="strHTML"></param> /// <returns></returns> public bool Parse(string strHTML) { var match = ArtistDetailsRegEx.Match(strHTML); if (!match.Success) { Log.Debug("Artist HTML does not match expected format, unable to parse"); return false; } var artistDetails = match.Value; var strArtist = string.Empty; var artistMatch = ArtistRegEx.Match(strHTML); if (artistMatch.Success) { strArtist = artistMatch.Groups["artist"].Value.Trim(); } strArtist = System.Web.HttpUtility.HtmlDecode(strArtist); Log.Debug("Trying to parse html for artist: {0}", strArtist); // build up genres into one string var strGenres = string.Empty; var genreMatch = GenreRegEx.Match(artistDetails); if (genreMatch.Success) { var genres = HTMLListRegEx.Matches(genreMatch.Groups["genres"].Value.Trim()); foreach (var genre in genres) { var cleanGenre = HTMLRegEx.Replace(genre.ToString(), ""); strGenres += cleanGenre + ", "; } strGenres = strGenres.TrimEnd(new[] { ' ', ',' }); } // build up styles into one string var strStyles = string.Empty; var styleMatch = StyleRegEx.Match(artistDetails); if (styleMatch.Success) { var styles = HTMLListRegEx.Matches(styleMatch.Groups["styles"].Value.Trim()); foreach (var style in styles) { var cleanStyle = HTMLRegEx.Replace(style.ToString(), ""); strStyles += cleanStyle + ", "; } strStyles = strStyles.TrimEnd(new[] { ' ', ',' }); } // years active var strActive = string.Empty; var activeMatch = ActiveRegEx.Match(artistDetails); if (activeMatch.Success) { strActive = activeMatch.Groups["active"].Value.Trim(); } // born / formed var strBorn = string.Empty; var bornMatch = BornRegEx.Match(artistDetails); if (bornMatch.Success) { strBorn = bornMatch.Groups["born"].Value.Trim(); strBorn = strBorn.Replace("\n", ""); strBorn = SpaceRegex.Replace(strBorn, " "); } // build up tones into one string var strTones = string.Empty; var tonesMatch = TonesRegEx.Match(strHTML); if (tonesMatch.Success) { var tones = HTMLListRegEx.Matches(tonesMatch.Groups["tones"].Value.Trim()); foreach (var tone in tones) { var cleanTone = HTMLRegEx.Replace(tone.ToString(), ""); strTones += cleanTone + ", "; } strTones = strTones.TrimEnd(new[] { ' ', ',' }); } // Biography var AMGBIO = string.Empty; var AMGBioMatch = BIORegEx.Match(strHTML); if (AMGBioMatch.Success) { AMGBIO = AMGBioMatch.Groups["BIO"].Value.Trim(); AMGBIO = HTMLRegEx.Replace(AMGBIO, ""); } // artist image URL var strImg = string.Empty; var imgMatch = ImgRegEx.Match(strHTML); if (imgMatch.Success) { strImg = imgMatch.Groups["imgURL"].Value; } // list albums var albumRows = AlbumRowRegEx.Matches(strHTML); var albumList = string.Empty; foreach (Match albumRow in albumRows) { var albumNameMatch = ArtistAlbumNameRegEx.Match(albumRow.Value); if (!albumNameMatch.Success) { continue; } var albumName = albumNameMatch.Groups["albumName"].Value.Trim(); var albumYear = ArtistAlbumYearRegEx.Match(albumRow.Value).Groups["year"].Value.Trim(); var albumLabel = ArtistAlbumLabelRegEx.Match(albumRow.Value).Groups["label"].Value.Trim(); albumList += string.Format("{0} - {1} ({2})", albumYear, albumName, albumLabel) + Environment.NewLine; } var artistInfo = new ArtistInfo { AMGBio = AMGBIO, Albums = albumList, Artist = strArtist, Born = strBorn, Compilations = string.Empty, Genres = strGenres, Image = strImg, Instruments = string.Empty, Misc = string.Empty, Singles = string.Empty, Styles = strStyles, Tones = strTones, YearsActive = strActive }; Set(artistInfo); _bLoaded = true; return _bLoaded; }
/// <summary> /// Parse the Detail Page returned from the Allmusic Scraper /// </summary> /// <param name="strUrl">URL of artist details page</param> /// <returns>True is scrape was sucessful</returns> public bool Parse(string strUrl) { var mainPage = new HtmlWeb().Load(strUrl); // moods var moods = string.Empty; var moodNodes = mainPage.DocumentNode.SelectNodes(@"//section[@class=""moods""]/ul/*"); if (moodNodes != null) { moods = moodNodes.Aggregate(moods, (current, mood) => current + (AllmusicSiteScraper.CleanInnerText(mood) + ", ")); moods = moods.TrimEnd(new[] { ',', ' ' }); } // artist name var artistName = AllmusicSiteScraper.CleanInnerText(mainPage.DocumentNode.SelectSingleNode(@"//h2[@clas=""artist-name""]")); // artist image URL var artistImg = AllmusicSiteScraper.CleanAttribute(mainPage.DocumentNode.SelectSingleNode(@"//div[@class=""artist-image""]/img"), "src"); //years active var yearsActive = AllmusicSiteScraper.CleanInnerText(mainPage.DocumentNode.SelectSingleNode(@"//section[@class=""basic-info""]/div[@class=""active-dates""]/div")); //genre var genres = string.Empty; var genreNodes = mainPage.DocumentNode.SelectNodes(@"//section[@class=""basic-info""]/div[@class=""genre""]/div/a"); if (genreNodes != null) { genres = genreNodes.Aggregate(genres, (current, genre) => current + (AllmusicSiteScraper.CleanInnerText(genre) + ", ")); genres = genres.TrimEnd(new[] { ',', ' ' }); // remove trailing ", " } // born / formed var born = AllmusicSiteScraper.CleanInnerText(mainPage.DocumentNode.SelectSingleNode(@"//section[@class=""basic-info""]/div[@class=""birth""]/div")); // styles var styles = string.Empty; var styleNodes = mainPage.DocumentNode.SelectNodes(@"//section[@class=""basic-info""]/div[@class=""styles""]/div/a"); if (styleNodes != null) { styles = styleNodes.Aggregate(styles, (current, style) => current + (AllmusicSiteScraper.CleanInnerText(style) + ", ")); styles = styles.TrimEnd(new[] { ',', ' ' }); // remove trailing ", " } // bio var bio = string.Empty; var bioURL = "http://www.allmusic.com/" + AllmusicSiteScraper.CleanAttribute(mainPage.DocumentNode.SelectSingleNode(@"//ul[@class=""tabs overview""]/li[@class=""tab biography""]/a"), "href"); if (!string.IsNullOrEmpty(bioURL)) { var bioPage = new HtmlWeb().Load(bioURL); bio = AllmusicSiteScraper.CleanInnerText(bioPage.DocumentNode.SelectSingleNode(@"//section[@class=""biography""]/div[@class=""text""]")); } // albums var albumList = string.Empty; var albumPageURL = "http://www.allmusic.com/" + AllmusicSiteScraper.CleanAttribute(mainPage.DocumentNode.SelectSingleNode(@"//ul[@class=""tabs overview""]/li[@class=""tab discography""]/a"), "href"); if (!string.IsNullOrEmpty(albumPageURL)) { var albumPage = new HtmlWeb().Load(albumPageURL); var albums = albumPage.DocumentNode.SelectNodes(@"//section[@class=""discography""]/table/tbody/tr"); if (albums != null) { foreach (var album in albums) { var year = AllmusicSiteScraper.CleanInnerText(album.SelectSingleNode(@"td[@class=""year""]")); var title = AllmusicSiteScraper.CleanInnerText(album.SelectSingleNode(@"td[@class=""title""]/a")); var label = AllmusicSiteScraper.CleanInnerText(album.SelectSingleNode(@"td[@class=""label""]")); albumList += year + " - " + title + " (" + label + ")" + Environment.NewLine; } } } var artistInfo = new ArtistInfo { AMGBio = bio, Albums = albumList, Artist = artistName, Born = born, Compilations = string.Empty, Genres = genres, Image = artistImg, Instruments = string.Empty, Misc = string.Empty, Singles = string.Empty, Styles = styles, Tones = moods, YearsActive = yearsActive }; Set(artistInfo); _bLoaded = true; return(_bLoaded); }
protected virtual void item_OnItemSelected(GUIListItem item, GUIControl parent) { MusicTag tag = (MusicTag)item.MusicTag; if (tag != null) { // none text values default to 0 and datetime.minvalue so // set the appropriate properties to string.empty // Duration string strDuration = tag.Duration <= 0 ? string.Empty : MediaPortal.Util.Utils.SecondsToHMSString(tag.Duration); // Track string strTrack = tag.Track <= 0 ? string.Empty : tag.Track.ToString(); // Year string strYear = tag.Year <= 1900 ? string.Empty : tag.Year.ToString(); // Rating string strRating = (Convert.ToDecimal(2 * tag.Rating + 1)).ToString(); // Bitrate string strBitrate = tag.BitRate <= 0 ? string.Empty : tag.BitRate.ToString(); // Disc ID string strDiscID = tag.DiscID <= 0 ? string.Empty : tag.DiscID.ToString(); // Disc Total string strDiscTotal = tag.DiscTotal <= 0 ? string.Empty : tag.DiscTotal.ToString(); // Times played string strTimesPlayed = tag.TimesPlayed <= 0 ? string.Empty : tag.TimesPlayed.ToString(); // track total string strTrackTotal = tag.TrackTotal <= 0 ? string.Empty : tag.TrackTotal.ToString(); // BPM string strBPM = tag.BPM <= 0 ? string.Empty : tag.BPM.ToString(); // Channels string strChannels = tag.Channels <= 0 ? string.Empty : tag.Channels.ToString(); // Sample Rate string strSampleRate = tag.SampleRate <= 0 ? string.Empty : tag.SampleRate.ToString(); // Date Last Played string strDateLastPlayed = tag.DateTimePlayed == DateTime.MinValue ? string.Empty : tag.DateTimePlayed.ToShortDateString(); // Date Added string strDateAdded = tag.DateTimeModified == DateTime.MinValue ? string.Empty : tag.DateTimeModified.ToShortDateString(); if (item.IsFolder || item.Label == "..") { GUIPropertyManager.SetProperty("#music.title", string.Empty); GUIPropertyManager.SetProperty("#music.track", string.Empty); GUIPropertyManager.SetProperty("#music.rating", string.Empty); GUIPropertyManager.SetProperty("#music.duration", string.Empty); GUIPropertyManager.SetProperty("#music.artist", string.Empty); GUIPropertyManager.SetProperty("#music.bitRate", string.Empty); GUIPropertyManager.SetProperty("#music.comment", string.Empty); GUIPropertyManager.SetProperty("#music.composer", string.Empty); GUIPropertyManager.SetProperty("#music.conductor", string.Empty); GUIPropertyManager.SetProperty("#music.lyrics", string.Empty); GUIPropertyManager.SetProperty("#music.timesplayed", string.Empty); GUIPropertyManager.SetProperty("#music.filetype", string.Empty); GUIPropertyManager.SetProperty("#music.codec", string.Empty); GUIPropertyManager.SetProperty("#music.bitratemode", string.Empty); GUIPropertyManager.SetProperty("#music.bpm", string.Empty); GUIPropertyManager.SetProperty("#music.channels", string.Empty); GUIPropertyManager.SetProperty("#music.samplerate", string.Empty); } else { GUIPropertyManager.SetProperty("#music.title", tag.Title); GUIPropertyManager.SetProperty("#music.track", strTrack); GUIPropertyManager.SetProperty("#music.rating", strRating); GUIPropertyManager.SetProperty("#music.duration", strDuration); GUIPropertyManager.SetProperty("#music.artist", tag.Artist); GUIPropertyManager.SetProperty("#music.bitRate", strBitrate); GUIPropertyManager.SetProperty("#music.comment", tag.Comment); GUIPropertyManager.SetProperty("#music.composer", tag.Composer); GUIPropertyManager.SetProperty("#music.conductor", tag.Conductor); GUIPropertyManager.SetProperty("#music.lyrics", tag.Lyrics); GUIPropertyManager.SetProperty("#music.timesplayed", strTimesPlayed); GUIPropertyManager.SetProperty("#music.filetype", tag.FileType); GUIPropertyManager.SetProperty("#music.codec", tag.Codec); GUIPropertyManager.SetProperty("#music.bitratemode", tag.BitRateMode); GUIPropertyManager.SetProperty("#music.bpm", strBPM); GUIPropertyManager.SetProperty("#music.channels", strChannels); GUIPropertyManager.SetProperty("#music.samplerate", strSampleRate); } GUIPropertyManager.SetProperty("#music.album", tag.Album); GUIPropertyManager.SetProperty("#music.genre", tag.Genre); GUIPropertyManager.SetProperty("#music.year", strYear); GUIPropertyManager.SetProperty("#music.albumArtist", tag.AlbumArtist); GUIPropertyManager.SetProperty("#music.discid", strDiscID); GUIPropertyManager.SetProperty("#music.disctotal", strDiscTotal); GUIPropertyManager.SetProperty("#music.trackTotal", strTrackTotal); GUIPropertyManager.SetProperty("#music.datelastplayed", strDateLastPlayed); GUIPropertyManager.SetProperty("#music.dateadded", strDateAdded); // see if we have album info AlbumInfo _albumInfo = new AlbumInfo(); if (MusicDatabase.Instance.GetAlbumInfo(tag.Album, tag.AlbumArtist, ref _albumInfo)) { GUIPropertyManager.SetProperty("#AlbumInfo.Review", _albumInfo.Review); GUIPropertyManager.SetProperty("#AlbumInfo.Rating", _albumInfo.Rating.ToString()); GUIPropertyManager.SetProperty("#AlbumInfo.Genre", _albumInfo.Genre); GUIPropertyManager.SetProperty("#AlbumInfo.Styles", _albumInfo.Styles); GUIPropertyManager.SetProperty("#AlbumInfo.Tones", _albumInfo.Tones); GUIPropertyManager.SetProperty("#AlbumInfo.Year", _albumInfo.Year.ToString()); } else { GUIPropertyManager.SetProperty("#AlbumInfo.Review", string.Empty); GUIPropertyManager.SetProperty("#AlbumInfo.Rating", string.Empty); GUIPropertyManager.SetProperty("#AlbumInfo.Genre", string.Empty); GUIPropertyManager.SetProperty("#AlbumInfo.Styles", string.Empty); GUIPropertyManager.SetProperty("#AlbumInfo.Tones", string.Empty); GUIPropertyManager.SetProperty("#AlbumInfo.Year", string.Empty); } // see if we have artist info ArtistInfo _artistInfo = new ArtistInfo(); String strArtist; if (string.IsNullOrEmpty(tag.Artist)) { strArtist = tag.AlbumArtist; } else { strArtist = tag.Artist; } if (MusicDatabase.Instance.GetArtistInfo(strArtist, ref _artistInfo)) { GUIPropertyManager.SetProperty("#ArtistInfo.Bio", _artistInfo.AMGBio); GUIPropertyManager.SetProperty("#ArtistInfo.Born", _artistInfo.Born); GUIPropertyManager.SetProperty("#ArtistInfo.Genres", _artistInfo.Genres); GUIPropertyManager.SetProperty("#ArtistInfo.Instruments", _artistInfo.Instruments); GUIPropertyManager.SetProperty("#ArtistInfo.Styles", _artistInfo.Styles); GUIPropertyManager.SetProperty("#ArtistInfo.Tones", _artistInfo.Tones); GUIPropertyManager.SetProperty("#ArtistInfo.YearsActive", _artistInfo.YearsActive); } else { GUIPropertyManager.SetProperty("#ArtistInfo.Bio", string.Empty); GUIPropertyManager.SetProperty("#ArtistInfo.Born", string.Empty); GUIPropertyManager.SetProperty("#ArtistInfo.Genres", string.Empty); GUIPropertyManager.SetProperty("#ArtistInfo.Instruments", string.Empty); GUIPropertyManager.SetProperty("#ArtistInfo.Styles", string.Empty); GUIPropertyManager.SetProperty("#ArtistInfo.Tones", string.Empty); GUIPropertyManager.SetProperty("#ArtistInfo.YearsActive", string.Empty); } } else { GUIPropertyManager.SetProperty("#music.title", string.Empty); GUIPropertyManager.SetProperty("#music.track", string.Empty); GUIPropertyManager.SetProperty("#music.album", string.Empty); GUIPropertyManager.SetProperty("#music.artist", string.Empty); GUIPropertyManager.SetProperty("#music.genre", string.Empty); GUIPropertyManager.SetProperty("#music.year", string.Empty); GUIPropertyManager.SetProperty("#music.rating", string.Empty); GUIPropertyManager.SetProperty("#music.duration", string.Empty); GUIPropertyManager.SetProperty("#music.albumArtist", string.Empty); GUIPropertyManager.SetProperty("#music.bitRate", string.Empty); GUIPropertyManager.SetProperty("#music.comment", string.Empty); GUIPropertyManager.SetProperty("#music.composer", string.Empty); GUIPropertyManager.SetProperty("#music.conductor", string.Empty); GUIPropertyManager.SetProperty("#music.discid", string.Empty); GUIPropertyManager.SetProperty("#music.disctotal", string.Empty); GUIPropertyManager.SetProperty("#music.lyrics", string.Empty); GUIPropertyManager.SetProperty("#music.timesplayed", string.Empty); GUIPropertyManager.SetProperty("#music.trackTotal", string.Empty); GUIPropertyManager.SetProperty("#music.filetype", string.Empty); GUIPropertyManager.SetProperty("#music.codec", string.Empty); GUIPropertyManager.SetProperty("#music.bitratemode", string.Empty); GUIPropertyManager.SetProperty("#music.bpm", string.Empty); GUIPropertyManager.SetProperty("#music.channels", string.Empty); GUIPropertyManager.SetProperty("#music.samplerate", string.Empty); GUIPropertyManager.SetProperty("#music.datelastplayed", string.Empty); GUIPropertyManager.SetProperty("#music.dateadded", string.Empty); } GUIFilmstripControl filmstrip = parent as GUIFilmstripControl; if (filmstrip == null) { return; } if (item.Label == "..") { filmstrip.InfoImageFileName = string.Empty; return; } else { filmstrip.InfoImageFileName = item.ThumbnailImage; } }
public bool GetArtistInfo(string aArtist, ref ArtistInfo aArtistInfo) { try { string strArtist = aArtist; DatabaseUtility.RemoveInvalidChars(ref strArtist); string strSQL; strSQL = String.Format("select * from artistinfo where strArtist like '{0}%'", strArtist); SQLiteResultSet results; results = MusicDbClient.Execute(strSQL); if (results.Rows.Count != 0) { aArtistInfo.Artist = DatabaseUtility.Get(results, 0, "artistinfo.strArtist"); aArtistInfo.Born = DatabaseUtility.Get(results, 0, "artistinfo.strBorn"); aArtistInfo.YearsActive = DatabaseUtility.Get(results, 0, "artistinfo.strYearsActive"); aArtistInfo.Genres = DatabaseUtility.Get(results, 0, "artistinfo.strGenres"); aArtistInfo.Styles = DatabaseUtility.Get(results, 0, "artistinfo.strStyles"); aArtistInfo.Tones = DatabaseUtility.Get(results, 0, "artistinfo.strTones"); aArtistInfo.Instruments = DatabaseUtility.Get(results, 0, "artistinfo.strInstruments"); aArtistInfo.Image = DatabaseUtility.Get(results, 0, "artistinfo.strImage"); aArtistInfo.AMGBio = DatabaseUtility.Get(results, 0, "artistinfo.strAMGBio"); aArtistInfo.Albums = DatabaseUtility.Get(results, 0, "artistinfo.strAlbums"); aArtistInfo.Compilations = DatabaseUtility.Get(results, 0, "artistinfo.strCompilations"); aArtistInfo.Singles = DatabaseUtility.Get(results, 0, "artistinfo.strSingles"); aArtistInfo.Misc = DatabaseUtility.Get(results, 0, "artistinfo.strMisc"); return true; } return false; } catch (Exception ex) { Log.Error("musicdatabase exception err:{0} stack:{1}", ex.Message, ex.StackTrace); Open(); } return false; }
/// <summary> /// Parse the Detail Page returned from the Allmusic Scraper /// </summary> /// <param name="strUrl">URL of artist details page</param> /// <returns>True is scrape was sucessful</returns> public bool Parse(string strUrl) { var mainPage = new HtmlWeb().Load(strUrl); // moods var moods = string.Empty; var moodNodes = mainPage.DocumentNode.SelectNodes(@"//section[@class=""moods""]/ul/*"); if (moodNodes != null) { moods = moodNodes.Aggregate(moods, (current, mood) => current + (AllmusicSiteScraper.CleanInnerText(mood) + ", ")); moods = moods.TrimEnd(new[] {',', ' '}); } // artist name var artistName = AllmusicSiteScraper.CleanInnerText(mainPage.DocumentNode.SelectSingleNode(@"//h2[@clas=""artist-name""]")); // artist image URL var artistImg = AllmusicSiteScraper.CleanAttribute(mainPage.DocumentNode.SelectSingleNode(@"//div[@class=""artist-image""]/img"), "src"); //years active var yearsActive = AllmusicSiteScraper.CleanInnerText(mainPage.DocumentNode.SelectSingleNode(@"//section[@class=""basic-info""]/div[@class=""active-dates""]/div")); //genre var genres = string.Empty; var genreNodes = mainPage.DocumentNode.SelectNodes(@"//section[@class=""basic-info""]/div[@class=""genre""]/div/a"); if (genreNodes != null) { genres = genreNodes.Aggregate(genres, (current, genre) => current + (AllmusicSiteScraper.CleanInnerText(genre) + ", ")); genres = genres.TrimEnd(new[] { ',', ' ' }); // remove trailing ", " } // born / formed var born = AllmusicSiteScraper.CleanInnerText(mainPage.DocumentNode.SelectSingleNode(@"//section[@class=""basic-info""]/div[@class=""birth""]/div")); // styles var styles = string.Empty; var styleNodes = mainPage.DocumentNode.SelectNodes(@"//section[@class=""basic-info""]/div[@class=""styles""]/div/a"); if (styleNodes != null) { styles = styleNodes.Aggregate(styles, (current, style) => current + (AllmusicSiteScraper.CleanInnerText(style) + ", ")); styles = styles.TrimEnd(new[] { ',', ' ' }); // remove trailing ", " } // bio var bio = string.Empty; var bioURL = "http://www.allmusic.com/" + AllmusicSiteScraper.CleanAttribute(mainPage.DocumentNode.SelectSingleNode(@"//ul[@class=""tabs overview""]/li[@class=""tab biography""]/a"), "href"); if (!string.IsNullOrEmpty(bioURL)) { var bioPage = new HtmlWeb().Load(bioURL); bio = AllmusicSiteScraper.CleanInnerText(bioPage.DocumentNode.SelectSingleNode(@"//section[@class=""biography""]/div[@class=""text""]")); } // albums var albumList = string.Empty; var albumPageURL = "http://www.allmusic.com/" + AllmusicSiteScraper.CleanAttribute(mainPage.DocumentNode.SelectSingleNode(@"//ul[@class=""tabs overview""]/li[@class=""tab discography""]/a"), "href"); if (!string.IsNullOrEmpty(albumPageURL)) { var albumPage = new HtmlWeb().Load(albumPageURL); var albums = albumPage.DocumentNode.SelectNodes(@"//section[@class=""discography""]/table/tbody/tr"); if (albums != null) { foreach (var album in albums) { var year = AllmusicSiteScraper.CleanInnerText(album.SelectSingleNode(@"td[@class=""year""]")); var title = AllmusicSiteScraper.CleanInnerText(album.SelectSingleNode(@"td[@class=""title""]/a")); var label = AllmusicSiteScraper.CleanInnerText(album.SelectSingleNode(@"td[@class=""label""]")); albumList += year + " - " + title + " (" + label + ")" + Environment.NewLine; } } } var artistInfo = new ArtistInfo { AMGBio = bio, Albums = albumList, Artist = artistName, Born = born, Compilations = string.Empty, Genres = genres, Image = artistImg, Instruments = string.Empty, Misc = string.Empty, Singles = string.Empty, Styles = styles, Tones = moods, YearsActive = yearsActive }; Set(artistInfo); _bLoaded = true; return _bLoaded; }
protected virtual void ShowArtistInfo(string artistName, string albumName) { GUIDialogOK pDlgOK = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK); GUIDialogProgress dlgProgress = (GUIDialogProgress)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_PROGRESS); bool bSaveDb = true; bool bDisplayErr = false; ArtistInfo artist = new ArtistInfo(); MusicArtistInfo artistInfo = new MusicArtistInfo(); if (m_database.GetArtistInfo(artistName, ref artist)) { artistInfo.Set(artist); } else { if (null != pDlgOK && !Win32API.IsConnectedToInternet()) { pDlgOK.SetHeading(703); pDlgOK.SetLine(1, 703); pDlgOK.SetLine(2, string.Empty); pDlgOK.DoModal(GetID); return; } // show dialog box indicating we're searching the artist if (dlgProgress != null) { dlgProgress.Reset(); dlgProgress.SetHeading(320); dlgProgress.SetLine(1, artistName); dlgProgress.SetLine(2, string.Empty); dlgProgress.SetPercentage(0); dlgProgress.StartModal(GetID); dlgProgress.Progress(); dlgProgress.ShowProgressBar(true); } // find artist info AllmusicSiteScraper scraper = new AllmusicSiteScraper(); if (scraper.FindInfo(AllmusicSiteScraper.SearchBy.Artists, artistName)) { // did we find at least 1 artist? if (scraper.IsMultiple()) { // let user choose one int iSelectedArtist = 0; string szText = GUILocalizeStrings.Get(181); GUIDialogSelect pDlg = (GUIDialogSelect)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_SELECT); if (null != pDlg) { pDlg.Reset(); pDlg.SetHeading(szText); foreach (string selectedArtist in scraper.GetItemsFound()) { pDlg.Add(selectedArtist); } pDlg.DoModal(GetID); // and wait till user selects one iSelectedArtist = pDlg.SelectedLabel; if (iSelectedArtist < 0) { return; } } // ok, now show dialog we're downloading the artist info if (null != dlgProgress) { dlgProgress.Reset(); dlgProgress.SetHeading(320); dlgProgress.SetLine(1, artistName); dlgProgress.SetLine(2, string.Empty); dlgProgress.SetPercentage(40); dlgProgress.StartModal(GetID); dlgProgress.ShowProgressBar(true); dlgProgress.Progress(); } // download the artist info if (!scraper.FindInfoByIndex(iSelectedArtist)) { if (null != dlgProgress) { dlgProgress.Close(); } return; } } if (null != dlgProgress) { dlgProgress.SetPercentage(60); dlgProgress.Progress(); } // Now we have either a Single hit or a selected Artist // Parse it if (artistInfo.Parse(scraper.GetHtmlContent())) { // if the artist selected from allmusic.com does not match // the one from the file, override the one from the allmusic // with the one from the file so the info is correct in the // database... if (!artistInfo.Artist.Equals(artistName)) { artistInfo.Artist = artistName; } if (bSaveDb) { // save to database m_database.AddArtistInfo(artistInfo.Get()); } if (null != dlgProgress) { dlgProgress.SetPercentage(100); dlgProgress.Progress(); dlgProgress.Close(); dlgProgress = null; } } else { bDisplayErr = true; } } else { bDisplayErr = true; } } if (null != dlgProgress) { dlgProgress.Close(); } if (!bDisplayErr) { // ok, show Artist info GUIMusicArtistInfo pDlgArtistInfo = (GUIMusicArtistInfo)GUIWindowManager.GetWindow((int)Window.WINDOW_ARTIST_INFO); if (null != pDlgArtistInfo) { pDlgArtistInfo.Artist = artistInfo; pDlgArtistInfo.DoModal(GetID); if (pDlgArtistInfo.NeedsRefresh) { m_database.DeleteArtistInfo(artistInfo.Artist); ShowArtistInfo(artistName, albumName); return; } } } else { if (null != dlgProgress) { dlgProgress.Close(); } if (null != pDlgOK) { pDlgOK.SetHeading(702); pDlgOK.SetLine(1, 702); pDlgOK.SetLine(2, string.Empty); pDlgOK.DoModal(GetID); } } }
/// <summary> /// Parse the Detail Page returned from the Allmusic Scraper /// </summary> /// <param name="strHTML"></param> /// <returns></returns> public bool Parse(string strHTML) { var match = ArtistDetailsRegEx.Match(strHTML); if (!match.Success) { Log.Debug("Artist HTML does not match expected format, unable to parse"); return(false); } var artistDetails = match.Value; var strArtist = string.Empty; var artistMatch = ArtistRegEx.Match(strHTML); if (artistMatch.Success) { strArtist = artistMatch.Groups["artist"].Value.Trim(); } strArtist = System.Web.HttpUtility.HtmlDecode(strArtist); Log.Debug("Trying to parse html for artist: {0}", strArtist); // build up genres into one string var strGenres = string.Empty; var genreMatch = GenreRegEx.Match(artistDetails); if (genreMatch.Success) { var genres = HTMLListRegEx.Matches(genreMatch.Groups["genres"].Value.Trim()); foreach (var genre in genres) { var cleanGenre = HTMLRegEx.Replace(genre.ToString(), ""); strGenres += cleanGenre + ", "; } strGenres = strGenres.TrimEnd(new[] { ' ', ',' }); } // build up styles into one string var strStyles = string.Empty; var styleMatch = StyleRegEx.Match(artistDetails); if (styleMatch.Success) { var styles = HTMLListRegEx.Matches(styleMatch.Groups["styles"].Value.Trim()); foreach (var style in styles) { var cleanStyle = HTMLRegEx.Replace(style.ToString(), ""); strStyles += cleanStyle + ", "; } strStyles = strStyles.TrimEnd(new[] { ' ', ',' }); } // years active var strActive = string.Empty; var activeMatch = ActiveRegEx.Match(artistDetails); if (activeMatch.Success) { strActive = activeMatch.Groups["active"].Value.Trim(); } // born / formed var strBorn = string.Empty; var bornMatch = BornRegEx.Match(artistDetails); if (bornMatch.Success) { strBorn = bornMatch.Groups["born"].Value.Trim(); strBorn = strBorn.Replace("\n", ""); strBorn = SpaceRegex.Replace(strBorn, " "); } // build up tones into one string var strTones = string.Empty; var tonesMatch = TonesRegEx.Match(strHTML); if (tonesMatch.Success) { var tones = HTMLListRegEx.Matches(tonesMatch.Groups["tones"].Value.Trim()); foreach (var tone in tones) { var cleanTone = HTMLRegEx.Replace(tone.ToString(), ""); strTones += cleanTone + ", "; } strTones = strTones.TrimEnd(new[] { ' ', ',' }); } // Biography var AMGBIO = string.Empty; var AMGBioMatch = BIORegEx.Match(strHTML); if (AMGBioMatch.Success) { AMGBIO = AMGBioMatch.Groups["BIO"].Value.Trim(); AMGBIO = HTMLRegEx.Replace(AMGBIO, ""); } // artist image URL var strImg = string.Empty; var imgMatch = ImgRegEx.Match(strHTML); if (imgMatch.Success) { strImg = imgMatch.Groups["imgURL"].Value; } // list albums var albumRows = AlbumRowRegEx.Matches(strHTML); var albumList = string.Empty; foreach (Match albumRow in albumRows) { var albumNameMatch = ArtistAlbumNameRegEx.Match(albumRow.Value); if (!albumNameMatch.Success) { continue; } var albumName = albumNameMatch.Groups["albumName"].Value.Trim(); var albumYear = ArtistAlbumYearRegEx.Match(albumRow.Value).Groups["year"].Value.Trim(); var albumLabel = ArtistAlbumLabelRegEx.Match(albumRow.Value).Groups["label"].Value.Trim(); albumList += string.Format("{0} - {1} ({2})", albumYear, albumName, albumLabel) + Environment.NewLine; } var artistInfo = new ArtistInfo { AMGBio = AMGBIO, Albums = albumList, Artist = strArtist, Born = strBorn, Compilations = string.Empty, Genres = strGenres, Image = strImg, Instruments = string.Empty, Misc = string.Empty, Singles = string.Empty, Styles = strStyles, Tones = strTones, YearsActive = strActive }; Set(artistInfo); _bLoaded = true; return(_bLoaded); }
/// <summary> /// Return the Artist Info /// </summary> /// <returns></returns> public ArtistInfo Get() { ArtistInfo artist = new ArtistInfo(); if (_bLoaded) { artist.Artist = Artist; artist.Born = Born; artist.YearsActive = YearsActive; artist.Genres = Genres; artist.Tones = Tones; artist.Styles = Styles; artist.Instruments = Instruments; artist.AMGBio = AMGBiography; artist.Image = ImageURL; artist.Albums = Albums; artist.Compilations = Compilations; artist.Singles = Singles; artist.Misc = Misc; } return artist; }
protected virtual void ShowArtistInfo(string artistName, string albumName) { Log.Debug("Looking up Artist: {0}", albumName); var dlgProgress = (GUIDialogProgress)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_PROGRESS); var pDlgOK = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK); var errorEncountered = true; var artist = new ArtistInfo(); var artistInfo = new MusicArtistInfo(); if (m_database.GetArtistInfo(artistName, ref artist)) { // we already have artist info in database so just use that artistInfo.Set(artist); errorEncountered = false; } else { // lookup artist details if (null != pDlgOK && !Win32API.IsConnectedToInternet()) { pDlgOK.SetHeading(703); pDlgOK.SetLine(1, 703); pDlgOK.SetLine(2, string.Empty); pDlgOK.DoModal(GetID); return; } // show dialog box indicating we're searching the artist if (dlgProgress != null) { dlgProgress.Reset(); dlgProgress.SetHeading(320); dlgProgress.SetLine(1, artistName); dlgProgress.SetLine(2, string.Empty); dlgProgress.SetPercentage(0); dlgProgress.StartModal(GetID); dlgProgress.Progress(); dlgProgress.ShowProgressBar(true); } var scraper = new AllmusicSiteScraper(); List<AllMusicArtistMatch> artists; if(scraper.GetArtists(artistName, out artists)) { var selectedMatch = new AllMusicArtistMatch(); if (artists.Count == 1) { // only have single match so no need to ask user Log.Debug("Single Artist Match Found"); selectedMatch = artists[0]; errorEncountered = false; } else { // need to get user to choose which one to use Log.Debug("Muliple Artist Match Found ({0}) prompting user", artists.Count); var pDlg = (GUIDialogSelect2) GUIWindowManager.GetWindow((int) Window.WINDOW_DIALOG_SELECT2); if (null != pDlg) { pDlg.Reset(); pDlg.SetHeading(GUILocalizeStrings.Get(1303)); foreach (var i in artists.Select(artistMatch => new GUIListItem { Label = artistMatch.Artist + " - " + artistMatch.Genre, Label2 = artistMatch.YearsActive, Path = artistMatch.ArtistUrl, IconImage = artistMatch.ImageUrl })) { pDlg.Add(i); } pDlg.DoModal(GetID); // and wait till user selects one var iSelectedMatch = pDlg.SelectedLabel; if (iSelectedMatch < 0) { return; } selectedMatch = artists[iSelectedMatch]; } if (null != dlgProgress) { dlgProgress.Reset(); dlgProgress.SetHeading(320); dlgProgress.SetLine(1, artistName); dlgProgress.SetLine(2, string.Empty); dlgProgress.SetPercentage(40); dlgProgress.StartModal(GetID); dlgProgress.ShowProgressBar(true); dlgProgress.Progress(); } } string strHtml; if (scraper.GetArtistHtml(selectedMatch, out strHtml)) { if (null != dlgProgress) { dlgProgress.SetPercentage(60); dlgProgress.Progress(); } if (artistInfo.Parse(strHtml)) { if (null != dlgProgress) { dlgProgress.SetPercentage(80); dlgProgress.Progress(); } m_database.AddArtistInfo(artistInfo.Get()); errorEncountered = false; } } } } if (null != dlgProgress) { dlgProgress.SetPercentage(100); dlgProgress.Progress(); dlgProgress.Close(); dlgProgress = null; } if (!errorEncountered) { var pDlgArtistInfo = (GUIMusicArtistInfo)GUIWindowManager.GetWindow((int)Window.WINDOW_ARTIST_INFO); if (null != pDlgArtistInfo) { pDlgArtistInfo.Artist = artistInfo; pDlgArtistInfo.DoModal(GetID); if (pDlgArtistInfo.NeedsRefresh) { m_database.DeleteArtistInfo(artistInfo.Artist); ShowArtistInfo(artistName, albumName); } } } else { Log.Debug("Unable to get artist details"); if (null != pDlgOK) { pDlgOK.SetHeading(702); pDlgOK.SetLine(1, 702); pDlgOK.SetLine(2, string.Empty); pDlgOK.DoModal(GetID); } } }
private static void SetCurrentSkinProperties(MusicTag tag, String fileName) { var thumb = string.Empty; if (tag != null) { string strThumb = Util.Utils.GetAlbumThumbName(tag.Artist, tag.Album); if (Util.Utils.FileExistsInCache(strThumb)) { thumb = strThumb; } // no succes with album cover try folder cache if (string.IsNullOrEmpty(thumb)) { thumb = Util.Utils.TryEverythingToGetFolderThumbByFilename(fileName, false); } // let us test if there is a larger cover art image string strLarge = Util.Utils.ConvertToLargeCoverArt(thumb); if (Util.Utils.FileExistsInCache(strLarge)) { thumb = strLarge; } GUIPropertyManager.SetProperty("#Play.Current.Thumb", thumb); // non-text values default to 0 and datetime.minvalue so // set the appropriate properties to string.empty // Duration string strDuration = tag.Duration <= 0 ? string.Empty : MediaPortal.Util.Utils.SecondsToHMSString(tag.Duration); // Track string strTrack = tag.Track <= 0 ? string.Empty : tag.Track.ToString(); // Year string strYear = tag.Year <= 1900 ? string.Empty : tag.Year.ToString(); // Rating string strRating = (Convert.ToDecimal(2 * tag.Rating + 1)).ToString(); // Bitrate string strBitrate = tag.BitRate <= 0 ? string.Empty : tag.BitRate.ToString(); // Disc ID string strDiscID = tag.DiscID <= 0 ? string.Empty : tag.DiscID.ToString(); // Disc Total string strDiscTotal = tag.DiscTotal <= 0 ? string.Empty : tag.DiscTotal.ToString(); // Times played string strTimesPlayed = tag.TimesPlayed <= 0 ? string.Empty : tag.TimesPlayed.ToString(); // track total string strTrackTotal = tag.TrackTotal <= 0 ? string.Empty : tag.TrackTotal.ToString(); // BPM string strBPM = tag.BPM <= 0 ? string.Empty : tag.BPM.ToString(); // Channels string strChannels = tag.Channels <= 0 ? string.Empty : tag.Channels.ToString(); // Sample Rate string strSampleRate = tag.SampleRate <= 0 ? string.Empty : tag.SampleRate.ToString(); // Date Last Played string strDateLastPlayed = tag.DateTimePlayed == DateTime.MinValue ? string.Empty : tag.DateTimePlayed.ToShortDateString(); // Date Added string strDateAdded = tag.DateTimeModified == DateTime.MinValue ? string.Empty : tag.DateTimeModified.ToShortDateString(); GUIPropertyManager.SetProperty("#Play.Current.Title", tag.Title); GUIPropertyManager.SetProperty("#Play.Current.Track", strTrack); GUIPropertyManager.SetProperty("#Play.Current.Album", tag.Album); GUIPropertyManager.SetProperty("#Play.Current.Artist", tag.Artist); GUIPropertyManager.SetProperty("#Play.Current.Genre", tag.Genre); GUIPropertyManager.SetProperty("#Play.Current.Year", strYear); GUIPropertyManager.SetProperty("#Play.Current.Rating", strRating); GUIPropertyManager.SetProperty("#Play.Current.Duration", strDuration); GUIPropertyManager.SetProperty("#duration", strDuration); GUIPropertyManager.SetProperty("#Play.Current.AlbumArtist", tag.AlbumArtist); GUIPropertyManager.SetProperty("#Play.Current.BitRate", strBitrate); GUIPropertyManager.SetProperty("#Play.Current.Comment", tag.Comment); GUIPropertyManager.SetProperty("#Play.Current.Composer", tag.Composer); GUIPropertyManager.SetProperty("#Play.Current.Conductor", tag.Conductor); GUIPropertyManager.SetProperty("#Play.Current.DiscID", strDiscID); GUIPropertyManager.SetProperty("#Play.Current.DiscTotal", strDiscTotal); GUIPropertyManager.SetProperty("#Play.Current.Lyrics", tag.Lyrics); GUIPropertyManager.SetProperty("#Play.Current.TimesPlayed", strTimesPlayed); GUIPropertyManager.SetProperty("#Play.Current.TrackTotal", strTrackTotal); GUIPropertyManager.SetProperty("#Play.Current.FileType", tag.FileType); GUIPropertyManager.SetProperty("#Play.Current.Codec", tag.Codec); GUIPropertyManager.SetProperty("#Play.Current.BitRateMode", tag.BitRateMode); GUIPropertyManager.SetProperty("#Play.Current.BPM", strBPM); GUIPropertyManager.SetProperty("#Play.Current.Channels", strChannels); GUIPropertyManager.SetProperty("#Play.Current.SampleRate", strSampleRate); GUIPropertyManager.SetProperty("#Play.Current.DateLastPlayed", strDateLastPlayed); GUIPropertyManager.SetProperty("#Play.Current.DateAdded", strDateAdded); var albumInfo = new AlbumInfo(); if (MusicDatabase.Instance.GetAlbumInfo(tag.Album, tag.AlbumArtist, ref albumInfo)) { GUIPropertyManager.SetProperty("#Play.AlbumInfo.Review", albumInfo.Review); GUIPropertyManager.SetProperty("#Play.AlbumInfo.Rating", albumInfo.Rating.ToString()); GUIPropertyManager.SetProperty("#Play.AlbumInfo.Genre", albumInfo.Genre); GUIPropertyManager.SetProperty("#Play.AlbumInfo.Styles", albumInfo.Styles); GUIPropertyManager.SetProperty("#Play.AlbumInfo.Tones", albumInfo.Tones); GUIPropertyManager.SetProperty("#Play.AlbumInfo.Year", albumInfo.Year.ToString()); } else { GUIPropertyManager.SetProperty("#Play.AlbumInfo.Review", String.Empty); GUIPropertyManager.SetProperty("#Play.AlbumInfo.Rating", String.Empty); GUIPropertyManager.SetProperty("#Play.AlbumInfo.Genre", String.Empty); GUIPropertyManager.SetProperty("#Play.AlbumInfo.Styles", String.Empty); GUIPropertyManager.SetProperty("#Play.AlbumInfo.Tones", String.Empty); GUIPropertyManager.SetProperty("#Play.AlbumInfo.Year", String.Empty); } var artistInfo = new ArtistInfo(); if (MusicDatabase.Instance.GetArtistInfo(tag.Artist, ref artistInfo)) { GUIPropertyManager.SetProperty("#Play.ArtistInfo.Bio", artistInfo.AMGBio); GUIPropertyManager.SetProperty("#Play.ArtistInfo.Born", artistInfo.Born); GUIPropertyManager.SetProperty("#Play.ArtistInfo.Genres", artistInfo.Genres); GUIPropertyManager.SetProperty("#Play.ArtistInfo.Instruments", artistInfo.Instruments); GUIPropertyManager.SetProperty("#Play.ArtistInfo.Styles", artistInfo.Styles); GUIPropertyManager.SetProperty("#Play.ArtistInfo.Tones", artistInfo.Tones); GUIPropertyManager.SetProperty("#Play.ArtistInfo.YearsActive", artistInfo.YearsActive); } else { GUIPropertyManager.SetProperty("#Play.ArtistInfo.Bio", String.Empty); GUIPropertyManager.SetProperty("#Play.ArtistInfo.Born", String.Empty); GUIPropertyManager.SetProperty("#Play.ArtistInfo.Genres", String.Empty); GUIPropertyManager.SetProperty("#Play.ArtistInfo.Instruments", String.Empty); GUIPropertyManager.SetProperty("#Play.ArtistInfo.Styles", String.Empty); GUIPropertyManager.SetProperty("#Play.ArtistInfo.Tones", String.Empty); GUIPropertyManager.SetProperty("#Play.ArtistInfo.YearsActive", String.Empty); } } else { // there is no current track so blank all properties GUIPropertyManager.RemovePlayerProperties(); GUIPropertyManager.SetProperty("#Play.Current.Title", GUILocalizeStrings.Get(4543)); } }
public void AddArtistInfo(ArtistInfo aArtistInfo) { string strSQL; try { ArtistInfo artist = aArtistInfo.Clone(); string strTmp; strTmp = artist.Artist; DatabaseUtility.RemoveInvalidChars(ref strTmp); artist.Artist = strTmp; strTmp = artist.Born; DatabaseUtility.RemoveInvalidChars(ref strTmp); artist.Born = strTmp == "unknown" ? "" : strTmp; strTmp = artist.YearsActive; DatabaseUtility.RemoveInvalidChars(ref strTmp); artist.YearsActive = strTmp == "unknown" ? "" : strTmp; strTmp = artist.Genres; DatabaseUtility.RemoveInvalidChars(ref strTmp); artist.Genres = strTmp == "unknown" ? "" : strTmp; strTmp = artist.Instruments; DatabaseUtility.RemoveInvalidChars(ref strTmp); artist.Instruments = strTmp == "unknown" ? "" : strTmp; strTmp = artist.Tones; DatabaseUtility.RemoveInvalidChars(ref strTmp); artist.Tones = strTmp == "unknown" ? "" : strTmp; strTmp = artist.Styles; DatabaseUtility.RemoveInvalidChars(ref strTmp); artist.Styles = strTmp == "unknown" ? "" : strTmp; strTmp = artist.AMGBio; DatabaseUtility.RemoveInvalidChars(ref strTmp); artist.AMGBio = strTmp == "unknown" ? "" : strTmp; strTmp = artist.Image; DatabaseUtility.RemoveInvalidChars(ref strTmp); artist.Image = strTmp == "unknown" ? "" : strTmp; strTmp = artist.Albums; DatabaseUtility.RemoveInvalidChars(ref strTmp); artist.Albums = strTmp == "unknown" ? "" : strTmp; strTmp = artist.Compilations; DatabaseUtility.RemoveInvalidChars(ref strTmp); artist.Compilations = strTmp == "unknown" ? "" : strTmp; strTmp = artist.Singles; DatabaseUtility.RemoveInvalidChars(ref strTmp); artist.Singles = strTmp == "unknown" ? "" : strTmp; strTmp = artist.Misc; DatabaseUtility.RemoveInvalidChars(ref strTmp); artist.Misc = strTmp == "unknown" ? "" : strTmp; if (null == MusicDbClient) { return; } strSQL = String.Format("delete from artistinfo where strArtist like '{0}%'", artist.Artist); SQLiteResultSet results; results = MusicDbClient.Execute(strSQL); strSQL = String.Format( "insert into artistinfo (strArtist,strBorn,strYearsActive,strGenres,strTones,strStyles,strInstruments,strImage,strAMGBio, strAlbums,strCompilations,strSingles,strMisc) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}' )", artist.Artist, artist.Born, artist.YearsActive, artist.Genres, artist.Tones, artist.Styles, artist.Instruments, artist.Image, artist.AMGBio, artist.Albums, artist.Compilations, artist.Singles, artist.Misc); MusicDbClient.Execute(strSQL); return; } catch (Exception ex) { Log.Error("musicdatabase exception err:{0} stack:{1}", ex.Message, ex.StackTrace); Open(); } return; }
private void setMusicVideoArtist(ref DBArtistInfo mv, string artistName, string artistmbid) { if (string.IsNullOrEmpty(artistName)) return; logger.Debug("In Method: setMusicVideoArtist(ref DBArtistInfo mv, Artist: " + artistName + " MBID: " + artistmbid + ")"); MusicDatabase m_db = null; try { m_db = MusicDatabase.Instance; } catch (Exception e) { logger.Error("setMusicVideoArtist: Music database init failed " + e.ToString()); return; } var artistInfo = new MediaPortal.Music.Database.ArtistInfo(); if (!m_db.GetArtistInfo(artistName, ref artistInfo)) return; // Name mv.Artist = artistName; // MBID // mv.MdID = // Tags char[] delimiters = new char[] { ',' }; string[] tags = artistInfo.Genres.Split(delimiters, StringSplitOptions.RemoveEmptyEntries); foreach (string tag in tags) { mv.Tag.Add(tag.Trim()); } tags = artistInfo.Styles.Split(delimiters, StringSplitOptions.RemoveEmptyEntries); foreach (string tag in tags) { mv.Tag.Add(tag.Trim()); } // Bio mv.bioSummary = artistInfo.AMGBio; mv.bioContent = artistInfo.AMGBio; // Additional mv.Born = artistInfo.Born; mv.Genre = artistInfo.Genres; mv.Styles = artistInfo.Styles; mv.YearsActive = artistInfo.YearsActive; // Image URL if (!string.IsNullOrEmpty(artistInfo.Image) && !mv.ArtUrls.Contains(artistInfo.Image)) mv.ArtUrls.Add(artistInfo.Image); }