From: <sa...@us...> - 2010-02-25 15:15:56
|
Revision: 3470 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=3470&view=rev Author: saamand Date: 2010-02-25 15:15:47 +0000 (Thu, 25 Feb 2010) Log Message: ----------- Version 1.4.2.2 Modified Paths: -------------- trunk/plugins/MyLyrics/LyricsEngine/ICommand.cs trunk/plugins/MyLyrics/LyricsEngine/ILyricForm.cs trunk/plugins/MyLyrics/LyricsEngine/LRC/SimpleLRC.cs trunk/plugins/MyLyrics/LyricsEngine/LRC/SimpleLRCFormat.cs trunk/plugins/MyLyrics/LyricsEngine/LRC/SimpleLRCTimeAndLineCollection.cs trunk/plugins/MyLyrics/LyricsEngine/LyricDiagnostics.cs trunk/plugins/MyLyrics/LyricsEngine/LyricSearch.cs trunk/plugins/MyLyrics/LyricsEngine/LyricUtil.cs trunk/plugins/MyLyrics/LyricsEngine/LyricsController.cs trunk/plugins/MyLyrics/LyricsEngine/LyricsDatabase/LyricsDatabase.cs trunk/plugins/MyLyrics/LyricsEngine/LyricsDatabase/LyricsItem.cs trunk/plugins/MyLyrics/LyricsEngine/LyricsEngine.csproj trunk/plugins/MyLyrics/LyricsEngine/LyricsSites/Actionext.cs trunk/plugins/MyLyrics/LyricsEngine/LyricsSites/HotLyrics.cs trunk/plugins/MyLyrics/LyricsEngine/LyricsSites/LrcFinder.cs trunk/plugins/MyLyrics/LyricsEngine/LyricsSites/LyrDB.cs trunk/plugins/MyLyrics/LyricsEngine/LyricsSites/LyricWiki.cs trunk/plugins/MyLyrics/LyricsEngine/LyricsSites/Lyrics007.cs trunk/plugins/MyLyrics/LyricsEngine/LyricsSites/LyricsOnDemand.cs trunk/plugins/MyLyrics/LyricsEngine/LyricsSites/LyricsPluginSite.cs trunk/plugins/MyLyrics/LyricsEngine/LyricsWebClient.cs trunk/plugins/MyLyrics/LyricsEngine/Properties/AssemblyInfo.cs trunk/plugins/MyLyrics/LyricsEngine/Setup.cs trunk/plugins/MyLyrics/LyricsEngine/Web References/lrcfinder/Reference.cs trunk/plugins/MyLyrics/My Lyrics/Convert/ConvertFromXMLtoLyricsDatabase.cs trunk/plugins/MyLyrics/My Lyrics/DatabaseUtil.cs trunk/plugins/MyLyrics/My Lyrics/MediaPortalUtil.cs trunk/plugins/MyLyrics/My Lyrics/MyLyrics Configuration/About.Designer.cs trunk/plugins/MyLyrics/My Lyrics/MyLyrics Configuration/About.cs trunk/plugins/MyLyrics/My Lyrics/MyLyrics Configuration/AddNewSong.cs trunk/plugins/MyLyrics/My Lyrics/MyLyrics Configuration/ExportTags.cs trunk/plugins/MyLyrics/My Lyrics/MyLyrics Configuration/FindLyric.cs trunk/plugins/MyLyrics/My Lyrics/MyLyrics Configuration/ImportTags.cs trunk/plugins/MyLyrics/My Lyrics/MyLyrics Configuration/LyricsLibrary.cs trunk/plugins/MyLyrics/My Lyrics/MyLyrics Configuration/MusicDatabaseBrowse.cs trunk/plugins/MyLyrics/My Lyrics/MyLyrics Configuration/MyLyricsSetup.Designer.cs trunk/plugins/MyLyrics/My Lyrics/MyLyrics Configuration/MyLyricsSetup.cs trunk/plugins/MyLyrics/My Lyrics/MyLyrics Configuration/MyLyricsSetup_test.cs trunk/plugins/MyLyrics/My Lyrics/MyLyrics.cs trunk/plugins/MyLyrics/My Lyrics/MyLyrics.csproj trunk/plugins/MyLyrics/My Lyrics/MyLyricsExternCode.cs trunk/plugins/MyLyrics/My Lyrics/MyLyricsSettings.cs trunk/plugins/MyLyrics/My Lyrics/Properties/AssemblyInfo.cs trunk/plugins/MyLyrics/My Lyrics/TagReaderUtil.cs trunk/plugins/MyLyrics/My Lyrics/change log.txt trunk/plugins/MyLyrics/Skin/Blue3wide/myLyrics.xml trunk/plugins/MyLyrics/TranslateProvider/Properties/AssemblyInfo.cs trunk/plugins/MyLyrics/TranslateProvider/TranslateProvider.cs trunk/plugins/MyLyrics/TranslateProvider/bin/Debug/TranslateProvider.dll trunk/plugins/MyLyrics/TranslateProvider/bin/Debug/TranslateProvider.pdb trunk/plugins/MyLyrics/TranslateProvider/obj/Debug/Refactor/TranslateProvider.dll trunk/plugins/MyLyrics/TranslateProvider/obj/Debug/TranslateProvider.dll trunk/plugins/MyLyrics/TranslateProvider/obj/Debug/TranslateProvider.pdb Modified: trunk/plugins/MyLyrics/LyricsEngine/ICommand.cs =================================================================== --- trunk/plugins/MyLyrics/LyricsEngine/ICommand.cs 2010-02-24 20:19:47 UTC (rev 3469) +++ trunk/plugins/MyLyrics/LyricsEngine/ICommand.cs 2010-02-25 15:15:47 UTC (rev 3470) @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Text; Modified: trunk/plugins/MyLyrics/LyricsEngine/ILyricForm.cs =================================================================== --- trunk/plugins/MyLyrics/LyricsEngine/ILyricForm.cs 2010-02-24 20:19:47 UTC (rev 3469) +++ trunk/plugins/MyLyrics/LyricsEngine/ILyricForm.cs 2010-02-25 15:15:47 UTC (rev 3470) @@ -1,35 +1,14 @@ -using System; -using System.Collections.Generic; -using System.Text; +using System; namespace LyricsEngine { public interface ILyricForm { - Object[] UpdateString - { - set; - } - Object[] UpdateStatus - { - set; - } - Object[] LyricFound - { - set; - } - Object[] LyricNotFound - { - set; - } - Object[] ThreadFinished - { - set; - } - string ThreadException - { - set; - } - + Object[] UpdateString { set; } + Object[] UpdateStatus { set; } + Object[] LyricFound { set; } + Object[] LyricNotFound { set; } + Object[] ThreadFinished { set; } + string ThreadException { set; } } -} +} \ No newline at end of file Modified: trunk/plugins/MyLyrics/LyricsEngine/LRC/SimpleLRC.cs =================================================================== --- trunk/plugins/MyLyrics/LyricsEngine/LRC/SimpleLRC.cs 2010-02-24 20:19:47 UTC (rev 3469) +++ trunk/plugins/MyLyrics/LyricsEngine/LRC/SimpleLRC.cs 2010-02-25 15:15:47 UTC (rev 3470) @@ -1,25 +1,25 @@ using System; -using System.Collections.Generic; -using System.Text; +using System.Collections; using System.IO; -using System.Collections; +using System.Text.RegularExpressions; namespace LyricsEngine.LRC { public class SimpleLRC { - string artist; - string title; - string offset; - string album; - string lyric; - bool isValid; + private string album; + private string artist; + private bool isValid; + private string lyricAsLRC; + private string lyricAsPlainLyric; - ArrayList lyricLines; + private ArrayList lyricLines; + private string offset; private ArrayList simpleLRCTimeAndLineArray; private ArrayList simpleLRCTimeAndLineArrayWithOffset; - SimpleLRCTimeAndLineCollection simpleLRCTimeAndLineCollection; - SimpleLRCTimeAndLineCollection simpleLRCTimeAndLineCollectionWithOffset; + private SimpleLRCTimeAndLineCollection simpleLRCTimeAndLineCollection; + private SimpleLRCTimeAndLineCollection simpleLRCTimeAndLineCollectionWithOffset; + private string title; /// <summary> @@ -32,8 +32,8 @@ TextReader textReader = new StreamReader(file); string line = ""; - lyricLines = new System.Collections.ArrayList(); - simpleLRCTimeAndLineArray = new System.Collections.ArrayList(); + lyricLines = new ArrayList(); + simpleLRCTimeAndLineArray = new ArrayList(); while ((line = textReader.ReadLine()) != null) { @@ -48,10 +48,17 @@ if (simpleLRCTimeAndLineArray.Count > 0) { - simpleLRCTimeAndLineCollection = new SimpleLRCTimeAndLineCollection((SimpleLRCTimeAndLine[])simpleLRCTimeAndLineArray.ToArray(typeof(SimpleLRCTimeAndLine))); + simpleLRCTimeAndLineCollection = + new SimpleLRCTimeAndLineCollection( + (SimpleLRCTimeAndLine[]) simpleLRCTimeAndLineArray.ToArray(typeof (SimpleLRCTimeAndLine))); isValid = true; } + if (!string.IsNullOrEmpty(lyricAsLRC)) + { + lyricAsPlainLyric = SimpleLRCFormat.LineLineRegex.Replace(lyricAsLRC, string.Empty); + } + textReader.Close(); } @@ -61,11 +68,11 @@ this.artist = artist; this.title = title; - string[] separators = new string[1] { "\n" }; + string[] separators = new string[1] {"\n"}; string[] lines = lyric.Split(separators, StringSplitOptions.None); string line = ""; - lyricLines = new System.Collections.ArrayList(); - simpleLRCTimeAndLineArray = new System.Collections.ArrayList(); + lyricLines = new ArrayList(); + simpleLRCTimeAndLineArray = new ArrayList(); for (int i = 0; i < lines.Length; i++) { @@ -81,11 +88,13 @@ if (simpleLRCTimeAndLineArray.Count > 0) { - simpleLRCTimeAndLineCollection = new SimpleLRCTimeAndLineCollection((SimpleLRCTimeAndLine[])simpleLRCTimeAndLineArray.ToArray(typeof(SimpleLRCTimeAndLine))); + simpleLRCTimeAndLineCollection = + new SimpleLRCTimeAndLineCollection( + (SimpleLRCTimeAndLine[]) simpleLRCTimeAndLineArray.ToArray(typeof (SimpleLRCTimeAndLine))); isValid = true; } - simpleLRCTimeAndLineArrayWithOffset = new System.Collections.ArrayList(); + simpleLRCTimeAndLineArrayWithOffset = new ArrayList(); int offsetInt = 0; @@ -93,22 +102,31 @@ { for (int i = 0; i < simpleLRCTimeAndLineArray.Count; i++) { - simpleLRCTimeAndLineArrayWithOffset.Add(((SimpleLRCTimeAndLine)simpleLRCTimeAndLineArray[i]).IncludeOffset(offsetInt)); + simpleLRCTimeAndLineArrayWithOffset.Add( + ((SimpleLRCTimeAndLine) simpleLRCTimeAndLineArray[i]).IncludeOffset(offsetInt)); } - simpleLRCTimeAndLineCollectionWithOffset = new SimpleLRCTimeAndLineCollection((SimpleLRCTimeAndLine[])simpleLRCTimeAndLineArrayWithOffset.ToArray(typeof(SimpleLRCTimeAndLine))); + simpleLRCTimeAndLineCollectionWithOffset = + new SimpleLRCTimeAndLineCollection( + (SimpleLRCTimeAndLine[]) + simpleLRCTimeAndLineArrayWithOffset.ToArray(typeof (SimpleLRCTimeAndLine))); } else { simpleLRCTimeAndLineCollectionWithOffset = simpleLRCTimeAndLineCollection; } + + if (!string.IsNullOrEmpty(lyricAsLRC)) + { + lyricAsPlainLyric = SimpleLRCFormat.LineLineRegex.Replace(lyricAsLRC, string.Empty); + } } private bool getLRCinfoFromFile(ref string line, bool originalLine) { - System.Text.RegularExpressions.Match m; + Match m; - if ((m = LRC.SimpleLRCFormat.LineLineRegex.Match(line)).Success) + if ((m = SimpleLRCFormat.LineLineRegex.Match(line)).Success) { line = line.Trim(); int index; @@ -122,7 +140,7 @@ // if a line with multiple timetags, only add the first which is the complete with all tags. if (originalLine) { - lyric += lineWithTimeAndNewLine; + lyricAsLRC += lineWithTimeAndNewLine; } // we update the line for potential further time-tags. This will natural not be regarded as an original line @@ -161,7 +179,7 @@ string lineTemp = lineWithNewLine; bool done = true; - while ((m = LRC.SimpleLRCFormat.LineLineRegex.Match(lineTemp)).Success) + while ((m = SimpleLRCFormat.LineLineRegex.Match(lineTemp)).Success) { lineTemp = lineTemp.Replace(m.Value, ""); done = false; @@ -172,31 +190,31 @@ return done; } - else if ((m = LRC.SimpleLRCFormat.ArtistLineStartRegex.Match(line)).Success) + else if ((m = SimpleLRCFormat.ArtistLineStartRegex.Match(line)).Success) { artist = line.Substring(m.Index + m.Length); - artist = LyricsEngine.LyricUtil.CapatalizeString(artist.Substring(0, artist.LastIndexOf("]"))); + artist = LyricUtil.CapatalizeString(artist.Substring(0, artist.LastIndexOf("]"))); return true; } - else if ((m = LRC.SimpleLRCFormat.TitleLineStartRegex.Match(line)).Success) + else if ((m = SimpleLRCFormat.TitleLineStartRegex.Match(line)).Success) { title = line.Substring(m.Index + m.Length); - title = LyricsEngine.LyricUtil.CapatalizeString(title.Substring(0, title.LastIndexOf("]"))); + title = LyricUtil.CapatalizeString(title.Substring(0, title.LastIndexOf("]"))); return true; } - else if ((m = LRC.SimpleLRCFormat.AlbumLineStartRegex.Match(line)).Success) + else if ((m = SimpleLRCFormat.AlbumLineStartRegex.Match(line)).Success) { album = line.Substring(m.Index + m.Length); - album = LyricsEngine.LyricUtil.CapatalizeString((album.Substring(0, album.LastIndexOf("]")))); + album = LyricUtil.CapatalizeString((album.Substring(0, album.LastIndexOf("]")))); return true; } - else if ((m = LRC.SimpleLRCFormat.OffsetLineStartRegex.Match(line)).Success) + else if ((m = SimpleLRCFormat.OffsetLineStartRegex.Match(line)).Success) { offset = line.Substring(m.Index + m.Length); - offset = LyricsEngine.LyricUtil.CapatalizeString((offset.Substring(0, offset.LastIndexOf("]")))); + offset = LyricUtil.CapatalizeString((offset.Substring(0, offset.LastIndexOf("]")))); return true; } else @@ -206,6 +224,7 @@ } #region properties + public string Artist { get { return artist; } @@ -226,11 +245,16 @@ get { return offset; } } - public string Lyric + public string LyricAsLRC { - get { return lyric; } + get { return lyricAsLRC; } } + public string LyricAsPlainLyric + { + get { return lyricAsPlainLyric; } + } + public bool IsValid { get { return isValid; } @@ -243,4 +267,4 @@ #endregion } -} +} \ No newline at end of file Modified: trunk/plugins/MyLyrics/LyricsEngine/LRC/SimpleLRCFormat.cs =================================================================== --- trunk/plugins/MyLyrics/LyricsEngine/LRC/SimpleLRCFormat.cs 2010-02-24 20:19:47 UTC (rev 3469) +++ trunk/plugins/MyLyrics/LyricsEngine/LRC/SimpleLRCFormat.cs 2010-02-25 15:15:47 UTC (rev 3470) @@ -1,16 +1,13 @@ -using System; -using System.Collections.Generic; -using System.Windows.Forms; using System.Text.RegularExpressions; namespace LyricsEngine.LRC { public static class SimpleLRCFormat { - public static Regex ArtistLineStartRegex = new Regex(@"\[ar\w*\:", RegexOptions.IgnoreCase); - public static Regex TitleLineStartRegex = new Regex(@"\[ti\w*\:", RegexOptions.IgnoreCase); - public static Regex OffsetLineStartRegex = new Regex(@"\[offset\w*\:", RegexOptions.IgnoreCase); public static Regex AlbumLineStartRegex = new Regex(@"\[al\w*\:", RegexOptions.IgnoreCase); + public static Regex ArtistLineStartRegex = new Regex(@"\[ar\w*\:", RegexOptions.IgnoreCase); public static Regex LineLineRegex = new Regex(@"\[\d+:\d+\.*\d*\]"); + public static Regex OffsetLineStartRegex = new Regex(@"\[offset\w*\:", RegexOptions.IgnoreCase); + public static Regex TitleLineStartRegex = new Regex(@"\[ti\w*\:", RegexOptions.IgnoreCase); } } \ No newline at end of file Modified: trunk/plugins/MyLyrics/LyricsEngine/LRC/SimpleLRCTimeAndLineCollection.cs =================================================================== --- trunk/plugins/MyLyrics/LyricsEngine/LRC/SimpleLRCTimeAndLineCollection.cs 2010-02-24 20:19:47 UTC (rev 3469) +++ trunk/plugins/MyLyrics/LyricsEngine/LRC/SimpleLRCTimeAndLineCollection.cs 2010-02-25 15:15:47 UTC (rev 3470) @@ -1,19 +1,14 @@ using System; using System.Collections; -using System.Text; -using System.IO; -using System.IO.IsolatedStorage; namespace LyricsEngine.LRC { public class SimpleLRCTimeAndLineCollection : IEnumerable, ICollection { - private object[] items; public SimpleLRCTimeAndLineCollection() { - } public SimpleLRCTimeAndLineCollection(object[] array) @@ -22,38 +17,13 @@ Sort(items); } - public int GetSimpleLRCTimeAndLineIndex(long time) - { - if (time <= ((SimpleLRCTimeAndLine)items[0]).Time) - { - return 0; - } - - for (int i = 1; i < items.Length; i++) - { - if (((SimpleLRCTimeAndLine)items[i - 1]).Time < time && time <= ((SimpleLRCTimeAndLine)items[i]).Time) - { - return i; - } - } - - if (time > ((SimpleLRCTimeAndLine)items[items.Length - 1]).Time) - { - return items.Length - 1; - } - else - { - throw (new IndexOutOfRangeException("IndexOutOfRangeException in GetSimpleLRCTimeAndLineIndex")); - } - } - public SimpleLRCTimeAndLine this[int index] { get { if (index < items.Length) { - return (SimpleLRCTimeAndLine)items[index]; + return (SimpleLRCTimeAndLine) items[index]; } else return null; @@ -61,13 +31,16 @@ } #region IEnumerable implementation + public IEnumerator GetEnumerator() { return new Enumerator(items); } + #endregion #region ICollection implementation + public int Count { get { return items.Length; } @@ -83,13 +56,15 @@ get { throw new Exception("The method or operation is not implemented."); } } - public void CopyTo(Array array, int index) + public void CopyTo(Array array, int index) { throw new Exception("The method or operation is not implemented."); } + #endregion #region Enumerator class, IEnumerator implementation + private class Enumerator : IEnumerator { private int cursor; @@ -102,6 +77,8 @@ cursor = -1; } + #region IEnumerator Members + public bool MoveNext() { ++cursor; @@ -132,27 +109,61 @@ return elements[cursor]; } } + + #endregion } + #endregion #region SortAfterTimeClass class, IComparer implementation + private class SortAfterTimeClass : IComparer { // Calls CaseInsensitiveComparer.Compare with the parameters reversed. + + #region IComparer Members + int IComparer.Compare(Object x, Object y) { return ((new CaseInsensitiveComparer()).Compare(y, x)); } + #endregion } + #endregion + public int GetSimpleLRCTimeAndLineIndex(long time) + { + if (time <= ((SimpleLRCTimeAndLine) items[0]).Time) + { + return 0; + } + + for (int i = 1; i < items.Length; i++) + { + if (((SimpleLRCTimeAndLine) items[i - 1]).Time < time && time <= ((SimpleLRCTimeAndLine) items[i]).Time) + { + return i; + } + } + + if (time > ((SimpleLRCTimeAndLine) items[items.Length - 1]).Time) + { + return items.Length - 1; + } + else + { + throw (new IndexOutOfRangeException("IndexOutOfRangeException in GetSimpleLRCTimeAndLineIndex")); + } + } + public string[] Copy() { - string[] array = new string[this.Count]; - for (int i = 0; i < this.Count; i++) + string[] array = new string[Count]; + for (int i = 0; i < Count; i++) { - SimpleLRCTimeAndLine timeLine = (SimpleLRCTimeAndLine)items[i]; + SimpleLRCTimeAndLine timeLine = (SimpleLRCTimeAndLine) items[i]; array.SetValue(timeLine.Line, i); } return array; @@ -164,5 +175,4 @@ Array.Sort(items, myComparer); } } -} - +} \ No newline at end of file Modified: trunk/plugins/MyLyrics/LyricsEngine/LyricDiagnostics.cs =================================================================== --- trunk/plugins/MyLyrics/LyricsEngine/LyricDiagnostics.cs 2010-02-24 20:19:47 UTC (rev 3469) +++ trunk/plugins/MyLyrics/LyricsEngine/LyricDiagnostics.cs 2010-02-25 15:15:47 UTC (rev 3470) @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; using System.Diagnostics; using System.IO; @@ -8,18 +6,30 @@ { public static class LyricDiagnostics { - private static TraceSource ts; - private static Stopwatch stopWatch; private static string logFileName = ""; private static FileStream objStream; private static TextWriterTraceListener objTraceListener; + private static Stopwatch stopWatch; + private static TraceSource ts; + public static TraceSource TraceSource + { + get + { + if (ts != null) + { + ts.Flush(); + return ts; + } + else return null; + } + } + public static void OpenLog(string url) { try { - logFileName = url; if (ts == null) @@ -31,7 +41,10 @@ { file.Delete(); } - catch { }; + catch + { + } + ; } ts = new TraceSource("MyLyrics"); @@ -44,7 +57,9 @@ } } catch (Exception e) - { ;} + { + ; + } } public static void Dispose() @@ -62,9 +77,11 @@ objTraceListener.Close(); objTraceListener.Dispose(); } - catch { } + catch + { + } - if (System.IO.File.Exists(logFileName)) + if (File.Exists(logFileName)) { FileStream file = new FileStream(logFileName, FileMode.OpenOrCreate, FileAccess.Write); file.Close(); @@ -72,18 +89,6 @@ } } - public static TraceSource TraceSource - { - get { - if (ts != null) - { - ts.Flush(); - return ts; - } - else return null; - } - } - private static void StartTimer() { stopWatch = new Stopwatch(); @@ -103,12 +108,12 @@ if (stopWatch != null) { long time = stopWatch.ElapsedMilliseconds; - long sec = time / 1000; - long ms = (time / 100) - (sec * 10); + long sec = time/1000; + long ms = (time/100) - (sec*10); string str = ""; str += (sec < 100) ? "0" : ""; str += (sec < 10) ? "0" : ""; - str += sec.ToString() + "." + ms.ToString(); + str += sec + "." + ms; return str + ": "; } else @@ -117,4 +122,4 @@ } } } -} +} \ No newline at end of file Modified: trunk/plugins/MyLyrics/LyricsEngine/LyricSearch.cs =================================================================== (Binary files differ) Modified: trunk/plugins/MyLyrics/LyricsEngine/LyricUtil.cs =================================================================== --- trunk/plugins/MyLyrics/LyricsEngine/LyricUtil.cs 2010-02-24 20:19:47 UTC (rev 3469) +++ trunk/plugins/MyLyrics/LyricsEngine/LyricUtil.cs 2010-02-25 15:15:47 UTC (rev 3470) @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Text; using System.Text.RegularExpressions; @@ -7,21 +6,28 @@ { public class LyricUtil { - static string[] parenthesesAndAlike = new string[6] { "(album", "(acoustic", "(live", "(radio", "[", "{" }; - static string[] charsToDelete = new string[11] { ".", ",", "&", "'", "!", "\"", "&", "?", "(", ")", "+" /*, "ä", "ö", "ü", "Ä", "Ö", "Ü", "ß" */ }; + private static readonly string[] charsToDelete = new string[11] + { + ".", ",", "&", "'", "!", "\"", "&", "?", "(", ")", "+" + /*, "ä", "ö", "ü", "Ä", "Ö", "Ü", "ß" */ + }; + private static readonly string[] parenthesesAndAlike = new string[6] + {"(album", "(acoustic", "(live", "(radio", "[", "{"}; + // capatalize string and make ready for XML public static string CapatalizeString(string s) { s = s.Replace("\"", ""); - char[] space = new char[1] { ' ' }; + char[] space = new char[1] {' '}; string[] words = s.Split(space, StringSplitOptions.RemoveEmptyEntries); StringBuilder result = new StringBuilder(); for (int i = 0; i < words.Length; i++) { - result.Append(words[i].Substring(0, 1).ToUpper() + (words[i].Length > 1 ? words[i].Substring(1, words[i].Length - 1).ToLower() : "") + " "); + result.Append(words[i].Substring(0, 1).ToUpper() + + (words[i].Length > 1 ? words[i].Substring(1, words[i].Length - 1).ToLower() : "") + " "); } return result.ToString().Trim(); } @@ -96,7 +102,6 @@ foreach (string findValue in find) { - if (findValue != "") { lyrics = lyrics.Replace(findValue, replace[valueIndex]); @@ -108,4 +113,4 @@ return lyrics; } } -} +} \ No newline at end of file Modified: trunk/plugins/MyLyrics/LyricsEngine/LyricsController.cs =================================================================== --- trunk/plugins/MyLyrics/LyricsEngine/LyricsController.cs 2010-02-24 20:19:47 UTC (rev 3469) +++ trunk/plugins/MyLyrics/LyricsEngine/LyricsController.cs 2010-02-25 15:15:47 UTC (rev 3470) @@ -1,45 +1,33 @@ -using System; -using System.Drawing; +using System; using System.Collections; -using System.ComponentModel; -using System.Windows.Forms; -using System.Data; using System.Threading; -using System.IO; -using System.Diagnostics; -using LyricsEngine; [assembly: CLSCompliant(true)] + namespace LyricsEngine { public class LyricsController : IDisposable { - private ILyricForm m_Form; - - // status - private int m_noOfLyricsToSearch; - private int m_noOfLyricsSearched; - private int m_noOfLyricsFound; - private int m_noOfLyricsNotFound; - - private int m_noOfCurrentSearches; - - private bool m_StopSearches; - + private string[] lyricsSites; private bool m_allowAllToComplete; private bool m_automaticUpdate; - ArrayList threadList = new ArrayList(); - // Main thread sets this event to stop LyricController - ManualResetEvent m_EventStop_LyricController; + private ManualResetEvent m_EventStop_LyricController; // The LyricController sets this when all lyricSearch threads have been aborted - ManualResetEvent m_EventStopped_LyricController; + private ManualResetEvent m_EventStopped_LyricController; - private string[] lyricsSites; private string[] m_findArray; + private ILyricForm m_Form; + private int m_noOfCurrentSearches; + private int m_noOfLyricsFound; + private int m_noOfLyricsNotFound; + private int m_noOfLyricsSearched; + private int m_noOfLyricsToSearch; private string[] m_replaceArray; + private bool m_StopSearches; + private ArrayList threadList = new ArrayList(); public LyricsController(ILyricForm mainForm, ManualResetEvent eventStopThread, @@ -47,11 +35,10 @@ bool allowAllToComplete, bool automaticUpdate, string find, string replace) { + m_Form = mainForm; + m_allowAllToComplete = allowAllToComplete; + m_automaticUpdate = automaticUpdate; - this.m_Form = mainForm; - this.m_allowAllToComplete = allowAllToComplete; - this.m_automaticUpdate = automaticUpdate; - m_noOfLyricsToSearch = 1; m_noOfLyricsSearched = 0; m_noOfLyricsFound = 0; @@ -68,7 +55,7 @@ sitesArrayList.Add(site); } } - this.lyricsSites = (string[])sitesArrayList.ToArray(typeof(string)); + lyricsSites = (string[]) sitesArrayList.ToArray(typeof (string)); LyricSearch.LyricsSites = lyricsSites; @@ -86,47 +73,41 @@ } } - - public void Run() + public bool StopSearches { - // check if thread is cancelled - while (true) + get { return m_StopSearches; } + set { - Thread.Sleep(100); - - // check if thread is cancelled - if (m_EventStop_LyricController.WaitOne()) + if (value == true) { - // clean-up operations may be placed here - for (int i=0; i<threadList.Count; i++) - { - ((Thread)threadList[i]).Abort(); - } - - bool stillThreadsAlive = (threadList.Count > 0 ? true : false); - while (stillThreadsAlive) - { - for (int i = 0; i < threadList.Count; i++) - { - stillThreadsAlive = false; ; - if (((Thread)threadList[i]).IsAlive) - stillThreadsAlive = true; - } - } - - m_EventStopped_LyricController.Set(); - break; + m_StopSearches = true; + //StopTheSearchAndAbort.Invoke(this, EventArgs.Empty); } + else + { + m_StopSearches = false; + } } } + public int NoOfLyricsToSearch + { + set { m_noOfLyricsToSearch = value; } + } + public int NoOfCurrentSearches + { + get { return m_noOfCurrentSearches; } + } + + #region IDisposable Members + public void Dispose() { // clean-up operations may be placed here for (int i = 0; i < threadList.Count; i++) { - ((Thread)threadList[i]).Abort(); + ((Thread) threadList[i]).Abort(); } bool stillThreadsAlive = true; @@ -135,7 +116,7 @@ for (int i = 0; i < threadList.Count; i++) { stillThreadsAlive = false; - if (((Thread)threadList[i]).IsAlive) + if (((Thread) threadList[i]).IsAlive) stillThreadsAlive = true; } @@ -147,6 +128,42 @@ FinishThread("", "", "The search has ended.", ""); } + #endregion + + public void Run() + { + // check if thread is cancelled + while (true) + { + Thread.Sleep(100); + + // check if thread is cancelled + if (m_EventStop_LyricController.WaitOne()) + { + // clean-up operations may be placed here + for (int i = 0; i < threadList.Count; i++) + { + ((Thread) threadList[i]).Abort(); + } + + bool stillThreadsAlive = (threadList.Count > 0 ? true : false); + while (stillThreadsAlive) + { + for (int i = 0; i < threadList.Count; i++) + { + stillThreadsAlive = false; + ; + if (((Thread) threadList[i]).IsAlive) + stillThreadsAlive = true; + } + } + + m_EventStopped_LyricController.Set(); + break; + } + } + } + public void AddNewLyricSearch(string artist, string title, string strippedArtistName) { if (lyricsSites.Length > 0 && !string.IsNullOrEmpty(artist) && !string.IsNullOrEmpty(title)) @@ -155,13 +172,16 @@ // create worker thread instance ThreadStart threadInstance = delegate - { - LyricSearch lyricSearch = new LyricSearch(this, artist, title, strippedArtistName, m_allowAllToComplete, m_automaticUpdate); - lyricSearch.Run(); - }; + { + LyricSearch lyricSearch = new LyricSearch(this, artist, title, + strippedArtistName, + m_allowAllToComplete, + m_automaticUpdate); + lyricSearch.Run(); + }; Thread lyricSearchThread = new Thread(threadInstance); - lyricSearchThread.Name = "BasicSearch for " + artist + " - " + title; // looks nice in Output window + lyricSearchThread.Name = "BasicSearch for " + artist + " - " + title; // looks nice in Output window lyricSearchThread.IsBackground = true; lyricSearchThread.Start(); threadList.Add(lyricSearchThread); @@ -173,10 +193,9 @@ } - internal void UpdateString(String message, String site) { - m_Form.UpdateString = new Object[] { message, site }; + m_Form.UpdateString = new Object[] {message, site}; } internal void StatusUpdate(string artist, string title, string site, bool lyricFound) @@ -188,7 +207,11 @@ ++m_noOfLyricsSearched; - m_Form.UpdateStatus = new Object[] { m_noOfLyricsToSearch, m_noOfLyricsSearched, m_noOfLyricsFound, m_noOfLyricsNotFound }; + m_Form.UpdateStatus = new Object[] + { + m_noOfLyricsToSearch, m_noOfLyricsSearched, m_noOfLyricsFound, + m_noOfLyricsNotFound + }; if ((m_noOfLyricsSearched >= m_noOfLyricsToSearch)) { @@ -199,14 +222,13 @@ internal void LyricFound(String lyricStrings, String artist, String title, String site) { - string cleanLyric = LyricUtil.FixLyrics(lyricStrings, m_findArray, m_replaceArray); --m_noOfCurrentSearches; if (m_allowAllToComplete || m_StopSearches == false) { - m_Form.LyricFound = new Object[] { cleanLyric, artist, title, site }; + m_Form.LyricFound = new Object[] {cleanLyric, artist, title, site}; StatusUpdate(artist, title, site, true); } } @@ -217,7 +239,7 @@ if (m_allowAllToComplete || m_StopSearches == false) { - m_Form.LyricNotFound = new Object[] { artist, title, message, site }; + m_Form.LyricNotFound = new Object[] {artist, title, message, site}; StatusUpdate(artist, title, site, false); } } @@ -231,38 +253,12 @@ { Thread.Sleep(50); } - m_Form.ThreadFinished = new Object[] { artist, title, message, site }; + m_Form.ThreadFinished = new Object[] {artist, title, message, site}; } internal void ThreadException(String s) { m_Form.ThreadException = s; } - - public bool StopSearches - { - get { return m_StopSearches; } - set { - if (value == true) - { - m_StopSearches = true; - //StopTheSearchAndAbort.Invoke(this, EventArgs.Empty); - } - else - { - m_StopSearches = false; - } - } - } - - public int NoOfLyricsToSearch - { - set { m_noOfLyricsToSearch = value; } - } - - public int NoOfCurrentSearches - { - get { return m_noOfCurrentSearches; } - } } -} +} \ No newline at end of file Modified: trunk/plugins/MyLyrics/LyricsEngine/LyricsDatabase/LyricsDatabase.cs =================================================================== --- trunk/plugins/MyLyrics/LyricsEngine/LyricsDatabase/LyricsDatabase.cs 2010-02-24 20:19:47 UTC (rev 3469) +++ trunk/plugins/MyLyrics/LyricsEngine/LyricsDatabase/LyricsDatabase.cs 2010-02-25 15:15:47 UTC (rev 3470) @@ -1,6 +1,6 @@ using System; +using System.Collections; using System.Collections.Generic; -using System.Text; using System.Runtime.Serialization; namespace MyLyrics @@ -8,11 +8,11 @@ [Serializable] public class LyricsDatabase : IDictionary<string, LyricsItem>, ISerializable { - private DateTime created; + private readonly DateTime created; + + private readonly Dictionary<string, LyricsItem> db; private DateTime lastModified; - private Dictionary<string, LyricsItem> db; - public LyricsDatabase() { created = DateTime.Now; @@ -21,10 +21,11 @@ } #region Serialization methods + protected LyricsDatabase(SerializationInfo info, StreamingContext context) { Dictionary<string, LyricsItem> dbTemp = new Dictionary<string, LyricsItem>(); - db = (Dictionary<string, LyricsItem>)info.GetValue("db", dbTemp.GetType()); + db = (Dictionary<string, LyricsItem>) info.GetValue("db", dbTemp.GetType()); created = info.GetDateTime("created"); lastModified = info.GetDateTime("lastModified"); } @@ -35,13 +36,9 @@ info.AddValue("created", created); info.AddValue("lastModified", lastModified); } + #endregion - public void SetLastModified() - { - lastModified = DateTime.Now; - } - #region IDictionary<string,LyricsItem> Members public void Add(string key, LyricsItem value) @@ -76,20 +73,10 @@ public LyricsItem this[string key] { - get - { - return db[key]; - } - set - { - db[key] = value; - } + get { return db[key]; } + set { db[key] = value; } } - #endregion - - #region ICollection<KeyValuePair<string,LyricsItem>> Members - public void Add(KeyValuePair<string, LyricsItem> item) { db.Add(item.Key, item.Value); @@ -125,10 +112,6 @@ return db.Remove(item.Key); } - #endregion - - #region IEnumerable<KeyValuePair<string,LyricsItem>> Members - public IEnumerator<KeyValuePair<string, LyricsItem>> GetEnumerator() { foreach (KeyValuePair<string, LyricsItem> kvp in db) @@ -137,11 +120,7 @@ } } - #endregion - - #region IEnumerable Members - - System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() + IEnumerator IEnumerable.GetEnumerator() { foreach (KeyValuePair<string, LyricsItem> kvp in db) { @@ -150,5 +129,10 @@ } #endregion + + public void SetLastModified() + { + lastModified = DateTime.Now; + } } -} +} \ No newline at end of file Modified: trunk/plugins/MyLyrics/LyricsEngine/LyricsDatabase/LyricsItem.cs =================================================================== --- trunk/plugins/MyLyrics/LyricsEngine/LyricsDatabase/LyricsItem.cs 2010-02-24 20:19:47 UTC (rev 3469) +++ trunk/plugins/MyLyrics/LyricsEngine/LyricsDatabase/LyricsItem.cs 2010-02-25 15:15:47 UTC (rev 3470) @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; -using System.Runtime.Serialization; -using System.Text.RegularExpressions; namespace MyLyrics { @@ -10,9 +6,9 @@ public class LyricsItem { private string artist; - private string title; private string lyrics; private string source; + private string title; public LyricsItem(string artist, string title, string lyrics, string source) { @@ -23,6 +19,7 @@ } #region Properties + public string Artist { get { return artist; } @@ -46,6 +43,7 @@ get { return source; } set { source = value; } } + #endregion } } \ No newline at end of file Modified: trunk/plugins/MyLyrics/LyricsEngine/LyricsEngine.csproj =================================================================== --- trunk/plugins/MyLyrics/LyricsEngine/LyricsEngine.csproj 2010-02-24 20:19:47 UTC (rev 3469) +++ trunk/plugins/MyLyrics/LyricsEngine/LyricsEngine.csproj 2010-02-25 15:15:47 UTC (rev 3470) @@ -2,7 +2,7 @@ <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> - <ProductVersion>9.0.21022</ProductVersion> + <ProductVersion>9.0.30729</ProductVersion> <SchemaVersion>2.0</SchemaVersion> <ProjectGuid>{B0760CE8-086F-4301-9091-C9BE54F261FD}</ProjectGuid> <OutputType>Library</OutputType> @@ -110,6 +110,7 @@ <AutoGen>True</AutoGen> <DesignTime>True</DesignTime> <DependentUpon>Reference.map</DependentUpon> + <SubType>Component</SubType> </Compile> <Compile Include="LyricsSites\LyricWiki.cs" /> </ItemGroup> Modified: trunk/plugins/MyLyrics/LyricsEngine/LyricsSites/Actionext.cs =================================================================== --- trunk/plugins/MyLyrics/LyricsEngine/LyricsSites/Actionext.cs 2010-02-24 20:19:47 UTC (rev 3469) +++ trunk/plugins/MyLyrics/LyricsEngine/LyricsSites/Actionext.cs 2010-02-25 15:15:47 UTC (rev 3470) @@ -1,30 +1,24 @@ using System; -using System.Collections.Generic; -using System.Text; using System.IO; -using System.Diagnostics; using System.Net; +using System.Text; using System.Threading; using System.Timers; +using Timer=System.Timers.Timer; namespace LyricsEngine.LyricSites { - class Actionext + internal class Actionext { - string lyric = ""; - bool complete; - System.Timers.Timer timer; - int timeLimit; + private bool complete; + private string lyric = ""; + private int timeLimit; + private Timer timer; - public string Lyric - { - get { return lyric; } - } - public Actionext(string artist, string title, ManualResetEvent m_EventStop_SiteSearches, int timeLimit) { this.timeLimit = timeLimit; - timer = new System.Timers.Timer(); + timer = new Timer(); artist = LyricUtil.RemoveFeatComment(artist); artist = artist.Replace(" ", "_"); @@ -36,7 +30,8 @@ return; } - string urlString = "http://www.actionext.com/names_" + artist[0] + "/" + artist + "_lyrics/" + title + ".html"; + string urlString = "http://www.actionext.com/names_" + artist[0] + "/" + artist + "_lyrics/" + title + + ".html"; urlString = urlString.ToLower(); LyricsWebClient client = new LyricsWebClient(); @@ -47,7 +42,7 @@ timer.Start(); Uri uri = new Uri(urlString); - client.OpenReadCompleted += new System.Net.OpenReadCompletedEventHandler(callbackMethod); + client.OpenReadCompleted += new OpenReadCompletedEventHandler(callbackMethod); client.OpenReadAsync(uri); while (complete == false) @@ -58,23 +53,28 @@ } else { - System.Threading.Thread.Sleep(300); + Thread.Sleep(300); } } } + public string Lyric + { + get { return lyric; } + } + private void callbackMethod(object sender, OpenReadCompletedEventArgs e) { bool thisMayBeTheCorrectLyric = true; StringBuilder lyricTemp = new StringBuilder(); - - LyricsWebClient client = (LyricsWebClient)sender; + + LyricsWebClient client = (LyricsWebClient) sender; Stream reply = null; StreamReader sr = null; try { - reply = (Stream)e.Result; + reply = (Stream) e.Result; sr = new StreamReader(reply, Encoding.Default); string line = ""; @@ -115,6 +115,7 @@ lyricTemp.Replace("<br>", Environment.NewLine); lyricTemp.Replace(",<br />", Environment.NewLine); lyricTemp.Replace("<br />", Environment.NewLine); + lyricTemp.Replace("&", "&"); lyric = lyricTemp.ToString().Trim(); @@ -143,7 +144,7 @@ } } - void timer_Elapsed(object sender, ElapsedEventArgs e) + private void timer_Elapsed(object sender, ElapsedEventArgs e) { timer.Stop(); timer.Close(); @@ -154,4 +155,4 @@ Thread.CurrentThread.Abort(); } } -} +} \ No newline at end of file Modified: trunk/plugins/MyLyrics/LyricsEngine/LyricsSites/HotLyrics.cs =================================================================== --- trunk/plugins/MyLyrics/LyricsEngine/LyricsSites/HotLyrics.cs 2010-02-24 20:19:47 UTC (rev 3469) +++ trunk/plugins/MyLyrics/LyricsEngine/LyricsSites/HotLyrics.cs 2010-02-25 15:15:47 UTC (rev 3470) @@ -1,30 +1,24 @@ using System; -using System.Collections.Generic; -using System.Text; using System.IO; -using System.Diagnostics; using System.Net; +using System.Text; using System.Threading; using System.Timers; +using Timer=System.Timers.Timer; namespace LyricsEngine.LyricSites { - class HotLyrics + internal class HotLyrics { - string lyric = ""; private bool complete; - System.Timers.Timer timer; - int timeLimit; + private string lyric = ""; + private int timeLimit; + private Timer timer; - public string Lyric - { - get { return lyric; } - } - public HotLyrics(string artist, string title, ManualResetEvent m_EventStop_SiteSearches, int timeLimit) { - this.timeLimit = timeLimit / 2; - timer = new System.Timers.Timer(); + this.timeLimit = timeLimit/2; + timer = new Timer(); artist = LyricUtil.RemoveFeatComment(artist); artist = LyricUtil.CapatalizeString(artist); @@ -98,7 +92,7 @@ timer.Start(); Uri uri = new Uri(urlString); - client.OpenReadCompleted += new System.Net.OpenReadCompletedEventHandler(callbackMethod); + client.OpenReadCompleted += new OpenReadCompletedEventHandler(callbackMethod); client.OpenReadAsync(uri); while (complete == false) @@ -109,23 +103,28 @@ } else { - System.Threading.Thread.Sleep(300); + Thread.Sleep(300); } } } + public string Lyric + { + get { return lyric; } + } + private void callbackMethod(object sender, OpenReadCompletedEventArgs e) { bool thisMayBeTheCorrectLyric = true; StringBuilder lyricTemp = new StringBuilder(); - LyricsWebClient client = (LyricsWebClient)sender; + LyricsWebClient client = (LyricsWebClient) sender; Stream reply = null; StreamReader sr = null; try { - reply = (Stream)e.Result; + reply = (Stream) e.Result; sr = new StreamReader(reply, Encoding.Default); string line = ""; @@ -173,6 +172,7 @@ lyricTemp.Replace("</p>", ""); lyricTemp.Replace("<BR>", ""); lyricTemp.Replace("<br/>", "\r\n"); + lyricTemp.Replace("&", "&"); lyric = lyricTemp.ToString().Trim(); @@ -207,7 +207,7 @@ } } - void timer_Elapsed(object sender, ElapsedEventArgs e) + private void timer_Elapsed(object sender, ElapsedEventArgs e) { timer.Stop(); timer.Close(); @@ -218,4 +218,4 @@ Thread.CurrentThread.Abort(); } } -} +} \ No newline at end of file Modified: trunk/plugins/MyLyrics/LyricsEngine/LyricsSites/LrcFinder.cs =================================================================== --- trunk/plugins/MyLyrics/LyricsEngine/LyricsSites/LrcFinder.cs 2010-02-24 20:19:47 UTC (rev 3469) +++ trunk/plugins/MyLyrics/LyricsEngine/LyricsSites/LrcFinder.cs 2010-02-25 15:15:47 UTC (rev 3470) @@ -1,29 +1,22 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Threading; -using LyricsEngine.lrcfinder; -using LyricsEngine; +using System; using System.Data; -using System.Diagnostics; using System.Net; namespace LyricsEngine.LyricSites { public class LrcFinder { - private lrcfinder.LrcFinder lrcFinder; - private string artist = ""; - private string title = ""; public static bool Abort; public static string Domain = null; public static bool WebExceptionOccured = false; + private string artist = ""; + private lrcfinder.LrcFinder lrcFinder; + private string title = ""; public LrcFinder() { - } public string FindLRC(string artist, string title) @@ -123,7 +116,6 @@ try { - string url = GetUrl(); if (url == null) @@ -181,7 +173,6 @@ try { - if (string.IsNullOrEmpty(Domain)) { string[] domains = lrcFinder.NewDomain(); @@ -197,6 +188,5 @@ return null; } } - } -} +} \ No newline at end of file Modified: trunk/plugins/MyLyrics/LyricsEngine/LyricsSites/LyrDB.cs =================================================================== --- trunk/plugins/MyLyrics/LyricsEngine/LyricsSites/LyrDB.cs 2010-02-24 20:19:47 UTC (rev 3469) +++ trunk/plugins/MyLyrics/LyricsEngine/LyricsSites/LyrDB.cs 2010-02-25 15:15:47 UTC (rev 3470) @@ -1,49 +1,45 @@ using System; -using System.Collections.Generic; -using System.Text; using System.IO; -using System.Diagnostics; using System.Net; +using System.Text; using System.Threading; using System.Timers; +using Timer=System.Timers.Timer; namespace LyricsEngine.LyricSites { - class LyrDB + internal class LyrDB { - string lyric = ""; - bool complete; - System.Timers.Timer timer; - int timeLimit; + private bool complete; + private string lyric = ""; private ManualResetEvent m_EventStop_SiteSearches; + private int timeLimit; + private Timer timer; - public string Lyric - { - get { return lyric; } - } - public LyrDB(string artist, string title, ManualResetEvent eventStop_SiteSearches, int timeLimit) { this.timeLimit = timeLimit; - timer = new System.Timers.Timer(); + timer = new Timer(); m_EventStop_SiteSearches = eventStop_SiteSearches; artist = LyricUtil.RemoveFeatComment(artist); title = LyricUtil.TrimForParenthesis(title); //string urlString = string.Format("http://www.lyrdb.com/lookup.php?q={0}|{1}&for=match", artist, title); - string urlString = string.Format("http://webservices.lyrdb.com/lookup.php?q={0}%7c{1}&for=match", artist, title); - + string urlString = + string.Format("http://webservices.lyrdb.com/lookup.php?q={0}%7c{1}&for=match", artist, title); + LyricsWebClient client = new LyricsWebClient(); + timer.Enabled = true; timer.Interval = timeLimit; timer.Elapsed += new ElapsedEventHandler(timer_Elapsed); timer.Start(); Uri uri = new Uri(urlString); - client.OpenReadCompleted += new System.Net.OpenReadCompletedEventHandler(CallbackMethodSearch); + client.OpenReadCompleted += new OpenReadCompletedEventHandler(CallbackMethodSearch); client.OpenReadAsync(uri); while (complete == false) @@ -54,16 +50,21 @@ } else { - System.Threading.Thread.Sleep(300); + Thread.Sleep(300); } } } + public string Lyric + { + get { return lyric; } + } + private void CallbackMethodSearch(object sender, OpenReadCompletedEventArgs e) { StringBuilder lyricTemp = new StringBuilder(); - LyricsWebClient client = (LyricsWebClient)sender; + LyricsWebClient client = (LyricsWebClient) sender; Stream reply = null; StreamReader sr = null; @@ -71,7 +72,7 @@ try { - reply = (Stream)e.Result; + reply = (Stream) e.Result; sr = new StreamReader(reply, Encoding.Default); string result = sr.ReadToEnd(); @@ -89,7 +90,7 @@ LyricsWebClient client2 = new LyricsWebClient(); Uri uri = new Uri(urlString); - client2.OpenReadCompleted += new System.Net.OpenReadCompletedEventHandler(CallbackMethodGetLyric); + client2.OpenReadCompleted += new OpenReadCompletedEventHandler(CallbackMethodGetLyric); client2.OpenReadAsync(uri); while (complete == false) @@ -100,7 +101,7 @@ } else { - System.Threading.Thread.Sleep(300); + Thread.Sleep(300); } } } @@ -127,29 +128,19 @@ { StringBuilder lyricTemp = new StringBuilder(); - LyricsWebClient client = (LyricsWebClient)sender; + LyricsWebClient client = (LyricsWebClient) sender; Stream reply = null; StreamReader sr = null; try { - reply = (Stream)e.Result; + reply = (Stream) e.Result; sr = new StreamReader(reply, Encoding.Default); lyric = sr.ReadToEnd().Trim(); lyric = lyric.Replace("*", ""); - - //lyricTemp.Replace("<br>", Environment.NewLine); - //lyricTemp.Replace(",<br />", Environment.NewLine); - //lyricTemp.Replace("<br />", Environment.NewLine); - - //lyric = lyricTemp.ToString().Trim(); - - //if (lyric.Contains("but we do not have the lyrics")) - //{ - // lyric = "Not found"; - //} + lyric = lyric.Replace("&", "&"); } catch { @@ -171,7 +162,7 @@ } - void timer_Elapsed(object sender, ElapsedEventArgs e) + private void timer_Elapsed(object sender, ElapsedEventArgs e) { timer.Stop(); timer.Close(); @@ -182,4 +173,4 @@ Thread.CurrentThread.Abort(); } } -} +} \ No newline at end of file Modified: trunk/plugins/MyLyrics/LyricsEngine/LyricsSites/LyricWiki.cs =================================================================== --- trunk/plugins/MyLyrics/LyricsEngine/LyricsSites/LyricWiki.cs 2010-02-24 20:19:47 UTC (rev 3469) +++ trunk/plugins/MyLyrics/LyricsEngine/LyricsSites/LyricWiki.cs 2010-02-25 15:15:47 UTC (rev 3470) @@ -1,30 +1,24 @@ using System; -using System.Collections.Generic; -using System.Text; using System.IO; -using System.Diagnostics; using System.Net; +using System.Text; using System.Threading; using System.Timers; +using Timer=System.Timers.Timer; namespace LyricsEngine.LyricSites { - class LyricWiki + internal class LyricWiki { - string lyric = ""; private bool complete; - System.Timers.Timer timer; - int timeLimit; + private string lyric = ""; + private int timeLimit; + private Timer timer; - public string Lyric - { - get { return lyric; } - } - public LyricWiki(string artist, string title, ManualResetEvent m_EventStop_SiteSearches, int timeLimit) { - this.timeLimit = timeLimit / 2; - timer = new System.Timers.Timer(); + this.timeLimit = timeLimit/2; + timer = new Timer(); artist = LyricUtil.RemoveFeatComment(artist); artist = LyricUtil.CapatalizeString(artist); @@ -50,7 +44,7 @@ timer.Start(); Uri uri = new Uri(urlString); - client.OpenReadCompleted += new System.Net.OpenReadCompletedEventHandler(callbackMethod); + client.OpenReadCompleted += new OpenReadCompletedEventHandler(callbackMethod); client.OpenReadAsync(uri); while (complete == false) @@ -61,27 +55,32 @@ } else... [truncated message content] |