/// <summary> /// /// </summary> public void FormContext() { if (this.Category.Equals("music")) { MusicBrainz mb = new MusicBrainz(); String artist = String.Empty; String song = String.Empty; string mbid = String.Empty; int wStrength = Int32.MaxValue; int artistIndex = 0; String[] kWArr = this.KeyWords.ToArray(); this.keyWords.Clear(); for (int index = 0; index < kWArr.Length; index++) { String txt = kWArr[index].ToLower(); List<MBArtist> artists = mb.GetArtists(txt, 0, 2); if (artists != null) { foreach (MBArtist mbartist in artists) { String largeTxttmp = mbartist.Name.ToLower(); int weight = this.MapReplace(txt, largeTxttmp); if (weight <= 3 && weight <= wStrength) { wStrength = weight; artist = mbartist.Name; mbid = mbartist.MBID; artistIndex = index; } } } } artistIndex = artistIndex == 0 ? 1 : 0; if (!String.IsNullOrEmpty(artist) && artistIndex < kWArr.Length) { List<MBSong> songs = mb.GetSongs(kWArr[artistIndex], artist, String.Empty, String.Empty, String.Empty, 0, 3); if (songs != null && songs.Count > 0) song = songs[0].Title; else { org.lyricwiki.www.service.LyricWiki lw = new org.lyricwiki.www.service.LyricWiki(); org.lyricwiki.www.service.LyricsResult lyrics = lw.getSong(artist, kWArr[artistIndex]); if (lyrics != null) { song = lyrics.song; } } } this.keyWords.Add("artist:" + artist); this.keyWords.Add("album:" + String.Empty); this.keyWords.Add("song:" + song); this.keyWords.Add("mbid:" + mbid); } return; }