private void btSave_Click(object sender, EventArgs e) { var capArtist = LyricUtil.CapatalizeString(_mCurrentArtist); var capTitle = LyricUtil.CapatalizeString(_mCurrentTitle); var lyrics = LyricUtil.FixLyrics(tbLyrics.Text); CurrentLyricsDatabase[DatabaseUtil.CorrectKeyFormat(capArtist, capTitle)].Lyrics = lyrics; DatabaseUtil.SerializeDB(CurrentLyricsDatabase); if (SettingManager.GetParamAsBool(SettingManager.AutomaticWriteToMusicTag, true)) { TagReaderUtil.WriteLyrics(capArtist, capTitle, lyrics); } if (CurrentLyricsDatabase.Equals(MyLyricsUtils.LyricsMarkedDB)) { if (SettingManager.GetParamAsBool(SettingManager.MoveLyricFromMarkedDatabase, true)) { MoveLyricToOtherDatabase(); } } var lrc = new SimpleLRC(capArtist, capTitle, lyrics); if (lrc.IsValid && _parentMyLyricsSetup.cbUploadLrcAutomatically.Checked) { LrcFinder.SaveLrcWithGuid(lyrics, _parentMyLyricsSetup.MGuid); } btSave.Enabled = false; treeView.Focus(); }
public void TestLrcFinder() { var site = new LrcFinder("U2", "With Or Without You", new ManualResetEvent(false), 100000); if (site.SiteActive()) { site.FindLyrics(); var lrcLyrics = site.Lyric; const string lrcPattern = @"\[.*?\]"; const string lrcPatternReplacement = ""; var lrcRegex = new Regex(lrcPattern); var lyrics = lrcRegex.Replace(lrcLyrics, lrcPatternReplacement); const string pattern = @"\s+"; const string patternReplacement = " "; var regex = new Regex(pattern); lyrics = regex.Replace(lyrics, patternReplacement); var lyricsSpit = lyrics.Trim().Split(' '); Assert.AreEqual("See", lyricsSpit[0]); Assert.AreEqual("you", lyricsSpit[lyricsSpit.Length - 1]); } }
private bool SearchLrcFinder(string artist, string title) { string lrc = ""; LrcFinder lrcFinder = new LrcFinder(); lrc = lrcFinder.FindLRC(artist, title); bool validLyric = m_allowAllToComplete ? ValidateSearchOutputForAllowAllToComplete(lrc, "LrcFinder") : ValidateSearchOutput(lrc, "LrcFinder"); return(validLyric); }