예제 #1
0
        protected override void FindLyricsWithTimer()
        {
            var artist = LyricUtil.RemoveFeatComment(Artist);

            artist = artist.Replace("#", "");
            var title = LyricUtil.TrimForParenthesis(Title);

            title = title.Replace("#", "");

            // Cannot find lyrics contaning non-English letters!

            var urlString = SiteBaseUrl + "/" + artist + " Lyrics/" + title + " Lyrics.html";

            var uri    = new Uri(urlString);
            var client = new LyricsWebClient();

            client.OpenReadCompleted += CallbackMethod;
            client.OpenReadAsync(uri);

            while (Complete == false)
            {
                if (MEventStopSiteSearches.WaitOne(500, true))
                {
                    Complete = true;
                }
            }
        }
        public Lyrics007(string artist, string title, ManualResetEvent m_EventStop_SiteSearches, int timeLimit)
        {
            this.timeLimit = timeLimit/2;
            timer = new Timer();

            artist = LyricUtil.RemoveFeatComment(artist);
            artist = artist.Replace("#", "");
            title = LyricUtil.TrimForParenthesis(title);
            title = title.Replace("#", "");

            // Cannot find lyrics contaning non-English letters!

            string urlString = "http://www.lyrics007.com/" + artist + " Lyrics/" + title + " Lyrics.html";

            timer.Enabled = true;
            timer.Interval = timeLimit;
            timer.Elapsed += new ElapsedEventHandler(timer_Elapsed);
            timer.Start();

            Uri uri = new Uri(urlString);
            LyricsWebClient client = new LyricsWebClient();
            client.OpenReadCompleted += new OpenReadCompletedEventHandler(callbackMethod);
            client.OpenReadAsync(uri);

            while (complete == false)
            {
                if (m_EventStop_SiteSearches.WaitOne(500, true))
                {
                    complete = true;
                }
            }
        }
예제 #3
0
        public Lyrics007(string artist, string title, ManualResetEvent m_EventStop_SiteSearches, int timeLimit)
        {
            this.timeLimit = timeLimit / 2;
            timer          = new Timer();

            artist = LyricUtil.RemoveFeatComment(artist);
            artist = artist.Replace("#", "");
            title  = LyricUtil.TrimForParenthesis(title);
            title  = title.Replace("#", "");

            // Cannot find lyrics contaning non-English letters!

            string urlString = "http://www.lyrics007.com/" + artist + " Lyrics/" + title + " Lyrics.html";

            timer.Enabled  = true;
            timer.Interval = timeLimit;
            timer.Elapsed += new ElapsedEventHandler(timer_Elapsed);
            timer.Start();

            Uri             uri    = new Uri(urlString);
            LyricsWebClient client = new LyricsWebClient();

            client.OpenReadCompleted += new OpenReadCompletedEventHandler(callbackMethod);
            client.OpenReadAsync(uri);

            while (complete == false)
            {
                if (m_EventStop_SiteSearches.WaitOne(500, true))
                {
                    complete = true;
                }
            }
        }
예제 #4
0
        protected override void FindLyricsWithTimer()
        {
            var artist = FixEscapeCharacters(Artist);

            // 1st step - find lyrics page
            var firstUrlString = BaseUrl + SearchPathQuery + artist;

            var findLyricsPageWebClient = new LyricsWebClient();

            findLyricsPageWebClient.OpenReadCompleted += FirstCallbackMethod;
            findLyricsPageWebClient.OpenReadAsync(new Uri(firstUrlString));

            while (_firstStepComplete == false)
            {
                if (MEventStopSiteSearches.WaitOne(1, true))
                {
                    _firstStepComplete = true;
                }
                else
                {
                    Thread.Sleep(100);
                }
            }

            if (_lyricsIndex == null)
            {
                LyricText = NotFound;
                return;
            }
            // 2nd step - find lyrics
            var secondUrlString = BaseUrl + _lyricsIndex;

            var findLyricsWebClient = new LyricsWebClient(firstUrlString);

            findLyricsWebClient.OpenReadCompleted += SecondCallbackMethod;
            findLyricsWebClient.OpenReadAsync(new Uri(secondUrlString));

            while (Complete == false)
            {
                if (MEventStopSiteSearches.WaitOne(1, true))
                {
                    Complete = true;
                }
                else
                {
                    Thread.Sleep(100);
                }
            }
        }
예제 #5
0
        public LyricWiki(string artist, string title, ManualResetEvent m_EventStop_SiteSearches, int timeLimit)
        {
            this.timeLimit = timeLimit / 2;
            timer          = new Timer();

            artist = LyricUtil.RemoveFeatComment(artist);
            artist = LyricUtil.CapatalizeString(artist);
            artist = artist.Replace(" ", "_");

            title = LyricUtil.TrimForParenthesis(title);
            title = LyricUtil.CapatalizeString(title);
            title = title.Replace(" ", "_");
            title = title.Replace("?", "%3F");

            if (string.IsNullOrEmpty(artist) || string.IsNullOrEmpty(title))
            {
                return;
            }

            string urlString = "http://lyricwiki.org/" + 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 OpenReadCompletedEventHandler(callbackMethod);
            client.OpenReadAsync(uri);

            while (complete == false)
            {
                if (m_EventStop_SiteSearches.WaitOne(1, true))
                {
                    complete = true;
                }
                else
                {
                    Thread.Sleep(300);
                }
            }
        }
예제 #6
0
        public Actionext(string artist, string title, ManualResetEvent m_EventStop_SiteSearches, int timeLimit)
        {
            this.timeLimit = timeLimit;
            timer          = new Timer();

            artist = LyricUtil.RemoveFeatComment(artist);
            artist = artist.Replace(" ", "_");
            title  = LyricUtil.TrimForParenthesis(title);
            title  = title.Replace(" ", "_");

            if (string.IsNullOrEmpty(artist) || string.IsNullOrEmpty(title))
            {
                return;
            }

            string urlString = "http://www.actionext.com/names_" + artist[0] + "/" + artist + "_lyrics/" + title +
                               ".html";

            urlString = urlString.ToLower();

            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 OpenReadCompletedEventHandler(callbackMethod);
            client.OpenReadAsync(uri);

            while (complete == false)
            {
                if (m_EventStop_SiteSearches.WaitOne(1, true))
                {
                    complete = true;
                }
                else
                {
                    Thread.Sleep(300);
                }
            }
        }
        public LyricWiki(string artist, string title, ManualResetEvent m_EventStop_SiteSearches, int timeLimit)
        {
            this.timeLimit = timeLimit/2;
            timer = new Timer();

            artist = LyricUtil.RemoveFeatComment(artist);
            artist = LyricUtil.CapatalizeString(artist);
            artist = artist.Replace(" ", "_");

            title = LyricUtil.TrimForParenthesis(title);
            title = LyricUtil.CapatalizeString(title);
            title = title.Replace(" ", "_");
            title = title.Replace("?", "%3F");

            if (string.IsNullOrEmpty(artist) || string.IsNullOrEmpty(title))
            {
                return;
            }

            string urlString = "http://lyricwiki.org/" + 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 OpenReadCompletedEventHandler(callbackMethod);
            client.OpenReadAsync(uri);

            while (complete == false)
            {
                if (m_EventStop_SiteSearches.WaitOne(1, true))
                {
                    complete = true;
                }
                else
                {
                    Thread.Sleep(300);
                }
            }
        }
        public Actionext(string artist, string title, ManualResetEvent m_EventStop_SiteSearches, int timeLimit)
        {
            this.timeLimit = timeLimit;
            timer = new Timer();

            artist = LyricUtil.RemoveFeatComment(artist);
            artist = artist.Replace(" ", "_");
            title = LyricUtil.TrimForParenthesis(title);
            title = title.Replace(" ", "_");

            if (string.IsNullOrEmpty(artist) || string.IsNullOrEmpty(title))
            {
                return;
            }

            string urlString = "http://www.actionext.com/names_" + artist[0] + "/" + artist + "_lyrics/" + title +
                               ".html";
            urlString = urlString.ToLower();

            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 OpenReadCompletedEventHandler(callbackMethod);
            client.OpenReadAsync(uri);

            while (complete == false)
            {
                if (m_EventStop_SiteSearches.WaitOne(1, true))
                {
                    complete = true;
                }
                else
                {
                    Thread.Sleep(300);
                }
            }
        }
예제 #9
0
        protected override void FindLyricsWithTimer()
        {
            // Clean artist name
            var artist = LyricUtil.RemoveFeatComment(Artist);

            artist = LyricUtil.CapatalizeString(artist);
            artist = artist.Replace(" ", "_");

            // Clean title name
            var title = LyricUtil.TrimForParenthesis(Title);

            title = LyricUtil.CapatalizeString(title);
            title = title.Replace(" ", "_");
            title = title.Replace("?", "%3F");

            // Validate not empty
            if (string.IsNullOrEmpty(artist) || string.IsNullOrEmpty(title))
            {
                return;
            }

            var urlString = SiteBaseUrl + "/" + artist + ":" + title;

            var client = new LyricsWebClient();

            var uri = new Uri(urlString);

            client.OpenReadCompleted += CallbackMethod;
            client.OpenReadAsync(uri);

            while (Complete == false)
            {
                if (MEventStopSiteSearches.WaitOne(1, true))
                {
                    Complete = true;
                }
                else
                {
                    Thread.Sleep(300);
                }
            }
        }
예제 #10
0
        public LyrDB(string artist, string title, ManualResetEvent eventStop_SiteSearches, int timeLimit)
        {
            this.timeLimit = timeLimit;
            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);


            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 OpenReadCompletedEventHandler(CallbackMethodSearch);
            client.OpenReadAsync(uri);

            while (complete == false)
            {
                if (m_EventStop_SiteSearches.WaitOne(1, true))
                {
                    complete = true;
                }
                else
                {
                    Thread.Sleep(300);
                }
            }
        }
예제 #11
0
        protected override void FindLyricsWithTimer()
        {
            var artist = Artist.ToLower();

            artist = ClearName(artist);

            var title = Title.ToLower();

            title = ClearName(title);

            // Validation
            if (string.IsNullOrEmpty(artist) || string.IsNullOrEmpty(title))
            {
                return;
            }

            var firstLetter = artist[0].ToString(CultureInfo.InvariantCulture);

            var urlString = SiteBaseUrl + "/lyrics/" + firstLetter + "/" + artist + "/" + title + ".html";

            var client = new LyricsWebClient();

            var uri = new Uri(urlString);

            client.OpenReadCompleted += CallbackMethod;
            client.OpenReadAsync(uri);

            while (Complete == false)
            {
                if (MEventStopSiteSearches.WaitOne(1, true))
                {
                    Complete = true;
                }
                else
                {
                    Thread.Sleep(300);
                }
            }
        }
예제 #12
0
        private void CallbackMethodGetLyric(object sender, OpenReadCompletedEventArgs e)
        {
            StringBuilder lyricTemp = new StringBuilder();

            LyricsWebClient client = (LyricsWebClient)sender;
            Stream          reply  = null;
            StreamReader    sr     = null;

            try
            {
                reply = (Stream)e.Result;
                sr    = new StreamReader(reply, Encoding.Default);

                lyric = sr.ReadToEnd().Trim();

                lyric = lyric.Replace("*", "");
                lyric = lyric.Replace("&", "&");
            }
            catch
            {
                lyric = "Not found";
            }
            finally
            {
                if (sr != null)
                {
                    sr.Close();
                }

                if (reply != null)
                {
                    reply.Close();
                }
                complete = true;
            }
        }
예제 #13
0
파일: LyrDB.cs 프로젝트: nus-ii/MPTagThat
        protected override void FindLyricsWithTimer()
        {
            var artist = LyricUtil.RemoveFeatComment(Artist);
            var title = LyricUtil.TrimForParenthesis(Title);

            var urlString = string.Format(SiteBaseUrl + "/lookup.php?q={0}%7c{1}&for=match&agant={2}", artist, title, Agent);

            var client = new LyricsWebClient();
            var uri = new Uri(urlString);
            client.OpenReadCompleted += CallbackMethodSearch;
            client.OpenReadAsync(uri);

            while (Complete == false)
            {
                if (MEventStopSiteSearches.WaitOne(1, true))
                {
                    Complete = true;
                }
                else
                {
                    Thread.Sleep(300);
                }
            }
        }
예제 #14
0
        public LyrDB(string artist, string title, ManualResetEvent eventStop_SiteSearches, int timeLimit)
        {
            this.timeLimit = timeLimit;
            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);

            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 OpenReadCompletedEventHandler(CallbackMethodSearch);
            client.OpenReadAsync(uri);

            while (complete == false)
            {
                if (m_EventStop_SiteSearches.WaitOne(1, true))
                {
                    complete = true;
                }
                else
                {
                    Thread.Sleep(300);
                }
            }
        }
        public LyricsOnDemand(string artist, string title, ManualResetEvent m_EventStop_SiteSearches, int timeLimit)
        {
            this.timeLimit = timeLimit;
            timer = new Timer();

            artist = LyricUtil.RemoveFeatComment(artist);
            artist = LyricUtil.DeleteSpecificChars(artist);
            artist = artist.Replace(" ", "");
            artist = artist.Replace("The ", "");
            artist = artist.Replace("the ", "");
            artist = artist.Replace("-", "");

            artist = artist.ToLower();

            // Cannot find lyrics contaning non-English letters!

            title = LyricUtil.TrimForParenthesis(title);
            title = LyricUtil.DeleteSpecificChars(title);
            title = title.Replace(" ", "");
            title = title.Replace("#", "");
            artist = artist.Replace("-", "");

            // Danish letters
            title = title.Replace("æ", "");
            title = title.Replace("ø", "");
            title = title.Replace("å", "");
            title = title.Replace("Æ", "");
            title = title.Replace("Ø", "");
            title = title.Replace("Å", "");
            title = title.Replace("ö", "");
            title = title.Replace("Ö", "");

            title = title.ToLower();

            if (string.IsNullOrEmpty(artist) || string.IsNullOrEmpty(title))
            {
                return;
            }

            string firstLetter = artist[0].ToString();

            int firstNumber = 0;
            if (int.TryParse(firstLetter, out firstNumber))
            {
                firstLetter = "0";
            }

            string urlString = "http://www.lyricsondemand.com/" + firstLetter + "/" + artist + "lyrics/" + title +
                               "lyrics.html";

            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 OpenReadCompletedEventHandler(callbackMethod);
            client.OpenReadAsync(uri);

            while (complete == false)
            {
                if (m_EventStop_SiteSearches.WaitOne(1, true))
                {
                    complete = true;
                }
                else
                {
                    Thread.Sleep(100);
                }
            }
        }
예제 #16
0
파일: LyrDB.cs 프로젝트: nus-ii/MPTagThat
        private void CallbackMethodSearch(object sender, OpenReadCompletedEventArgs e)
        {
            Stream reply = null;
            StreamReader reader = null;

            try
            {
                reply = e.Result;
                reader = new StreamReader(reply, Encoding.Default);

                var result = reader.ReadToEnd();

                if (result.Equals(""))
                {
                    LyricText = NotFound;
                    return;
                }

                var id = result.Substring(0, result.IndexOf(@"\", StringComparison.Ordinal));

                var urlString = string.Format(BaseUrl + "/getlyr.php?q={0}", id);

                var client2 = new LyricsWebClient();

                var uri = new Uri(urlString);
                client2.OpenReadCompleted += CallbackMethodGetLyric;
                client2.OpenReadAsync(uri);

                while (Complete == false)
                {
                    if (MEventStopSiteSearches.WaitOne(1, true))
                    {
                        Complete = true;
                    }
                    else
                    {
                        Thread.Sleep(300);
                    }
                }
            }
            catch
            {
                LyricText = NotFound;
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }

                if (reply != null)
                {
                    reply.Close();
                }
            }
        }
예제 #17
0
        protected override void FindLyricsWithTimer()
        {
            var artist = LyricUtil.RemoveFeatComment(Artist);
            artist = artist.Replace("#", "");
            var title = LyricUtil.TrimForParenthesis(Title);
            title = title.Replace("#", "");

            // Cannot find lyrics contaning non-English letters!

            var urlString = SiteBaseUrl + "/" + artist + " Lyrics/" + title + " Lyrics.html";

            var uri = new Uri(urlString);
            var client = new LyricsWebClient();
            client.OpenReadCompleted += CallbackMethod;
            client.OpenReadAsync(uri);

            while (Complete == false)
            {
                if (MEventStopSiteSearches.WaitOne(500, true))
                {
                    Complete = true;
                }
            }
        }
예제 #18
0
        private void callbackMethod(object sender, OpenReadCompletedEventArgs e)
        {
            bool          thisMayBeTheCorrectLyric = true;
            StringBuilder lyricTemp = new StringBuilder();

            LyricsWebClient client = (LyricsWebClient)sender;
            Stream          reply  = null;
            StreamReader    sr     = null;

            try
            {
                reply = (Stream)e.Result;
                sr    = new StreamReader(reply, Encoding.Default);

                string line           = "";
                int    noOfLinesCount = 0;

                while (line.IndexOf(@"<font size=""2"" face=""Verdana"">") == -1)
                {
                    if (sr.EndOfStream || ++noOfLinesCount > 300)
                    {
                        thisMayBeTheCorrectLyric = false;
                        break;
                    }
                    else
                    {
                        line = sr.ReadLine();
                    }
                }

                if (thisMayBeTheCorrectLyric)
                {
                    lyricTemp = new StringBuilder();
                    line      = sr.ReadLine().Trim();

                    while (line.Contains("<p>") == false)
                    {
                        lyricTemp.Append(line);
                        if (sr.EndOfStream || ++noOfLinesCount > 300)
                        {
                            thisMayBeTheCorrectLyric = false;
                            break;
                        }
                        else
                        {
                            line = sr.ReadLine().Trim();
                        }
                    }

                    lyricTemp.Replace("<br>", " \r\n");
                    lyricTemp.Replace("</font></p>", " \r\n");
                    lyricTemp.Replace("<p><font size=\"2\" face=\"Verdana\">", " \r\n");
                    lyricTemp.Replace("<i>", "");
                    lyricTemp.Replace("</i>", "");
                    lyricTemp.Replace("*", "");
                    lyricTemp.Replace("?s", "'s");
                    lyricTemp.Replace("?t", "'t");
                    lyricTemp.Replace("?m", "'m");
                    lyricTemp.Replace("?l", "'l");
                    lyricTemp.Replace("?v", "'v");
                    lyricTemp.Replace("<p>", " \r\n");
                    lyricTemp.Replace("<BR>", " \r\n");
                    lyricTemp.Replace("<br />", " \r\n");
                    lyricTemp.Replace("&#039;", "'");
                    lyricTemp.Replace("&amp;", "&");

                    lyric = lyricTemp.ToString().Trim();

                    if (lyric.Contains("<td") || lyric.Contains("<IFRAME"))
                    {
                        lyric = "Not found";
                    }
                }
            }
            catch
            {
                lyric = "Not found";
            }
            finally
            {
                if (sr != null)
                {
                    sr.Close();
                }

                if (reply != null)
                {
                    reply.Close();
                }
                complete = true;
            }
        }
예제 #19
0
        public LyricsOnDemand(string artist, string title, ManualResetEvent m_EventStop_SiteSearches, int timeLimit)
        {
            this.timeLimit = timeLimit;
            timer          = new Timer();

            artist = LyricUtil.RemoveFeatComment(artist);
            artist = LyricUtil.DeleteSpecificChars(artist);
            artist = artist.Replace(" ", "");
            artist = artist.Replace("The ", "");
            artist = artist.Replace("the ", "");
            artist = artist.Replace("-", "");

            artist = artist.ToLower();

            // Cannot find lyrics contaning non-English letters!

            title  = LyricUtil.TrimForParenthesis(title);
            title  = LyricUtil.DeleteSpecificChars(title);
            title  = title.Replace(" ", "");
            title  = title.Replace("#", "");
            artist = artist.Replace("-", "");

            // Danish letters
            title = title.Replace("æ", "");
            title = title.Replace("ø", "");
            title = title.Replace("å", "");
            title = title.Replace("Æ", "");
            title = title.Replace("Ø", "");
            title = title.Replace("Å", "");
            title = title.Replace("ö", "");
            title = title.Replace("Ö", "");

            title = title.ToLower();

            if (string.IsNullOrEmpty(artist) || string.IsNullOrEmpty(title))
            {
                return;
            }

            string firstLetter = artist[0].ToString();

            int firstNumber = 0;

            if (int.TryParse(firstLetter, out firstNumber))
            {
                firstLetter = "0";
            }

            string urlString = "http://www.lyricsondemand.com/" + firstLetter + "/" + artist + "lyrics/" + title +
                               "lyrics.html";

            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 OpenReadCompletedEventHandler(callbackMethod);
            client.OpenReadAsync(uri);

            while (complete == false)
            {
                if (m_EventStop_SiteSearches.WaitOne(1, true))
                {
                    complete = true;
                }
                else
                {
                    Thread.Sleep(100);
                }
            }
        }
예제 #20
0
        private void callbackMethod(object sender, OpenReadCompletedEventArgs e)
        {
            bool            thisMayBeTheCorrectLyric = true;
            StringBuilder   lyricTemp = new StringBuilder();
            LyricsWebClient client    = (LyricsWebClient)sender;
            Stream          reply     = null;
            StreamReader    sr        = null;

            try
            {
                reply = (Stream)e.Result;
                sr    = new StreamReader(reply, Encoding.Default);

                //string line = sr.ReadToEnd();
                string line = sr.ReadLine();

                // Replace the new line stuff in the result, as the regex might have problems
                //line = line.Replace("\n", "");
                //line = line.Replace("\r", "");
                //line = line.Replace("\t", "");

                //string pat = @"<script\s*type=""text/javascript""\s*src=""http://www2\.ringtonematcher\.com/jsstatic/lyrics007\.js""></script>.*?</div>(.*?)<div.*";
                //string pat = @"src=""/images/phone2.gif""><br><br><br></div>(.*?)<div align=center>";
                //string pat = @"<br><br><br></div>(.*?)<div.*";

                string pat = @"rtm.js""></scr' + 'ipt>');";

                while (line.IndexOf(pat) == -1)
                {
                    if (sr.EndOfStream)
                    {
                        thisMayBeTheCorrectLyric = false;
                        break;
                    }
                    else
                    {
                        line = sr.ReadLine();
                    }
                }

                if (thisMayBeTheCorrectLyric)
                {
                    line = sr.ReadLine();
                    line = line.Replace("</script><br><br><br>", string.Empty);

                    while (line.IndexOf("<script") == -1)
                    {
                        lyricTemp.Append(line);
                        if (sr.EndOfStream)
                        {
                            thisMayBeTheCorrectLyric = false;
                            break;
                        }
                        else
                        {
                            line = sr.ReadLine();
                        }
                    }
                }

                lyric = lyricTemp.ToString();

                if (lyric.Length > 0)
                {
                    lyric = lyric.Replace("??s", "'s");
                    lyric = lyric.Replace("??t", "'t");
                    lyric = lyric.Replace("??m", "'m");
                    lyric = lyric.Replace("??l", "'l");
                    lyric = lyric.Replace("??v", "'v");
                    lyric = lyric.Replace("?s", "'s");
                    lyric = lyric.Replace("?t", "'t");
                    lyric = lyric.Replace("?m", "'m");
                    lyric = lyric.Replace("?l", "'l");
                    lyric = lyric.Replace("?v", "'v");
                    lyric = lyric.Replace("<br>", "\r\n");
                    lyric = lyric.Replace("<br />", "\r\n");
                    lyric = lyric.Replace("<BR>", "\r\n");
                    lyric = lyric.Replace("&amp;", "&");
                    lyric = lyric.Trim();
                }
                else
                {
                    lyric = "Not found";
                }
            }
            catch
            {
                lyric = "Not found";
            }
            finally
            {
                if (sr != null)
                {
                    sr.Close();
                }

                if (reply != null)
                {
                    reply.Close();
                }
                complete = true;
            }
        }
예제 #21
0
        private void CallbackMethodSearch(object sender, OpenReadCompletedEventArgs e)
        {
            StringBuilder lyricTemp = new StringBuilder();

            LyricsWebClient client = (LyricsWebClient)sender;
            Stream          reply  = null;
            StreamReader    sr     = null;

            string id = string.Empty;

            try
            {
                reply = (Stream)e.Result;
                sr    = new StreamReader(reply, Encoding.Default);

                string result = sr.ReadToEnd();

                if (result.Equals(""))
                {
                    lyric = "Not found";
                    return;
                }

                id = result.Substring(0, result.IndexOf(@"\"));

                string urlString = string.Format("http://www.lyrdb.com/getlyr.php?q={0}", id);

                LyricsWebClient client2 = new LyricsWebClient();

                Uri uri = new Uri(urlString);
                client2.OpenReadCompleted += new OpenReadCompletedEventHandler(CallbackMethodGetLyric);
                client2.OpenReadAsync(uri);

                while (complete == false)
                {
                    if (m_EventStop_SiteSearches.WaitOne(1, true))
                    {
                        complete = true;
                    }
                    else
                    {
                        Thread.Sleep(300);
                    }
                }
            }
            catch
            {
                lyric = "Not found";
            }
            finally
            {
                if (sr != null)
                {
                    sr.Close();
                }

                if (reply != null)
                {
                    reply.Close();
                }
            }
        }
예제 #22
0
        public LyricsPluginSite(string artist, string title, ManualResetEvent m_EventStop_SiteSearches, int timeLimit)
        {
            this.timeLimit = timeLimit;
            timer          = new Timer();

            artist = LyricUtil.RemoveFeatComment(artist);
            title  = LyricUtil.TrimForParenthesis(title);

            // Escape characters
            artist = fixEscapeCharacters(artist);
            title  = fixEscapeCharacters(title);

            // Hebrew letters
            artist = fixHebrew(artist);
            title  = fixHebrew(title);

            // timer
            timer.Enabled  = true;
            timer.Interval = timeLimit;
            timer.Elapsed += new ElapsedEventHandler(timer_Elapsed);
            timer.Start();

            // LyricsPlugin.com changed their API to need 2 calls. The first is to get a timer & code

            // 1st step
            string firstUrlString = "http://www.lyricsplugin.com/winamp03/plugin/?" + "artist=" + artist + "&title=" + title;

            Uri             uri1    = new Uri(firstUrlString);
            LyricsWebClient client1 = new LyricsWebClient();

            client1.OpenReadCompleted += new OpenReadCompletedEventHandler(firstCallbackMethod);
            client1.OpenReadAsync(uri1);

            while (firstStepComplete == false)
            {
                if (m_EventStop_SiteSearches.WaitOne(1, true))
                {
                    firstStepComplete = true;
                }
                else
                {
                    Thread.Sleep(100);
                }
            }

            // assertion: !timestamp.Equals("") & !checkCode.Equals("");

            // 2nd step
            string secondUrlString = "http://www.lyricsplugin.com/winamp03/plugin/content.php?" + "artist=" + artist + "&title=" + title + "&time=" + timestamp + "&check=" + checkCode;

            Uri             uri2    = new Uri(secondUrlString);
            LyricsWebClient client2 = new LyricsWebClient(firstUrlString);

            client2.OpenReadCompleted += new OpenReadCompletedEventHandler(secondCallbackMethod);
            client2.OpenReadAsync(uri2);

            while (complete == false)
            {
                if (m_EventStop_SiteSearches.WaitOne(1, true))
                {
                    complete = true;
                }
                else
                {
                    Thread.Sleep(100);
                }
            }
        }
예제 #23
0
        private void callbackMethod(object sender, OpenReadCompletedEventArgs e)
        {
            bool          thisMayBeTheCorrectLyric = true;
            StringBuilder lyricTemp = new StringBuilder();

            LyricsWebClient client = (LyricsWebClient)sender;
            Stream          reply  = null;
            StreamReader    sr     = null;

            try
            {
                reply = (Stream)e.Result;
                sr    = new StreamReader(reply, Encoding.Default);

                string line           = "";
                int    noOfLinesCount = 0;

                while (line.IndexOf(@"<div class=""lyrics-text"">") == -1)
                {
                    if (sr.EndOfStream || ++noOfLinesCount > 300)
                    {
                        thisMayBeTheCorrectLyric = false;
                        break;
                    }
                    else
                    {
                        line = sr.ReadLine();
                    }
                }

                if (thisMayBeTheCorrectLyric)
                {
                    lyricTemp = new StringBuilder();
                    line      = sr.ReadLine();

                    while (line.IndexOf("</div>") == -1)
                    {
                        lyricTemp.Append(line);
                        if (sr.EndOfStream)
                        {
                            thisMayBeTheCorrectLyric = false;
                            break;
                        }
                        else
                        {
                            line = sr.ReadLine();
                        }
                    }

                    lyricTemp.Replace("<br>", Environment.NewLine);
                    lyricTemp.Replace(",<br />", Environment.NewLine);
                    lyricTemp.Replace("<br />", Environment.NewLine);
                    lyricTemp.Replace("&amp;", "&");

                    lyric = lyricTemp.ToString().Trim();

                    if (lyric.Contains("but we do not have the lyrics"))
                    {
                        lyric = "Not found";
                    }
                }
            }
            catch
            {
                lyric = "Not found";
            }
            finally
            {
                if (sr != null)
                {
                    sr.Close();
                }

                if (reply != null)
                {
                    reply.Close();
                }
                complete = true;
            }
        }
예제 #24
0
        public HotLyrics(string artist, string title, ManualResetEvent m_EventStop_SiteSearches, int timeLimit)
        {
            this.timeLimit = timeLimit / 2;
            timer          = new Timer();

            artist = LyricUtil.RemoveFeatComment(artist);
            artist = LyricUtil.CapatalizeString(artist);

            artist = artist.Replace(" ", "_");
            artist = artist.Replace(",", "_");
            artist = artist.Replace(".", "_");
            artist = artist.Replace("'", "_");
            artist = artist.Replace("(", "%28");
            artist = artist.Replace(")", "%29");
            artist = artist.Replace(",", "");
            artist = artist.Replace("#", "");
            artist = artist.Replace("%", "");
            artist = artist.Replace("+", "%2B");
            artist = artist.Replace("=", "%3D");
            artist = artist.Replace("-", "_");

            // French letters
            artist = artist.Replace("é", "%E9");

            title = LyricUtil.TrimForParenthesis(title);
            title = LyricUtil.CapatalizeString(title);

            title = title.Replace(" ", "_");
            title = title.Replace(",", "_");
            title = title.Replace(".", "_");
            title = title.Replace("'", "_");
            title = title.Replace("(", "%28");
            title = title.Replace(")", "%29");
            title = title.Replace(",", "_");
            title = title.Replace("#", "_");
            title = title.Replace("%", "_");
            title = title.Replace("?", "_");
            title = title.Replace("+", "%2B");
            title = title.Replace("=", "%3D");
            title = title.Replace("-", "_");
            title = title.Replace(":", "_");

            // German letters
            artist = artist.Replace("ü", "%FC");
            artist = artist.Replace("Ü", "%DC");
            artist = artist.Replace("ä", "%E4");
            artist = artist.Replace("Ä", "%C4");
            artist = artist.Replace("ö", "%F6");
            artist = artist.Replace("Ö", "%D6");
            artist = artist.Replace("ß", "%DF");

            // Danish letters
            title = title.Replace("å", "%E5");
            title = title.Replace("Å", "%C5");
            title = title.Replace("æ", "%E6");
            title = title.Replace("ø", "%F8");

            // French letters
            title = title.Replace("é", "%E9");

            if (string.IsNullOrEmpty(artist) || string.IsNullOrEmpty(title))
            {
                return;
            }

            string firstLetter = artist[0].ToString();

            string urlString = "http://www.hotlyrics.net/lyrics/" + firstLetter + "/" + artist + "/" + title + ".html";

            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 OpenReadCompletedEventHandler(callbackMethod);
            client.OpenReadAsync(uri);

            while (complete == false)
            {
                if (m_EventStop_SiteSearches.WaitOne(1, true))
                {
                    complete = true;
                }
                else
                {
                    Thread.Sleep(300);
                }
            }
        }
예제 #25
0
        protected override void FindLyricsWithTimer()
        {
            var artist = LyricUtil.RemoveFeatComment(Artist);
            artist = LyricUtil.DeleteSpecificChars(artist);
            artist = artist.Replace(" ", "");
            artist = artist.Replace("The ", "");
            artist = artist.Replace("the ", "");
            artist = artist.Replace("-", "");

            artist = artist.ToLower();

            // Cannot find lyrics contaning non-English letters!

            var title = LyricUtil.TrimForParenthesis(Title);
            title = LyricUtil.DeleteSpecificChars(title);
            title = title.Replace(" ", "");
            title = title.Replace("#", "");
            artist = artist.Replace("-", "");

            // Danish letters
            title = title.Replace("æ", "");
            title = title.Replace("ø", "");
            title = title.Replace("å", "");
            title = title.Replace("Æ", "");
            title = title.Replace("Ø", "");
            title = title.Replace("Å", "");
            title = title.Replace("ö", "");
            title = title.Replace("Ö", "");

            title = title.ToLower();

            // Validation
            if (string.IsNullOrEmpty(artist) || string.IsNullOrEmpty(title))
            {
                return;
            }

            var firstLetter = artist[0].ToString(CultureInfo.InvariantCulture);

            int firstNumber;
            if (int.TryParse(firstLetter, out firstNumber))
            {
                firstLetter = "0";
            }

            var urlString = SiteBaseUrl + "/" + firstLetter + "/" + artist + "lyrics/" + title + "lyrics.html";

            var client = new LyricsWebClient();

            var uri = new Uri(urlString);
            client.OpenReadCompleted += CallbackMethod;
            client.OpenReadAsync(uri);

            while (Complete == false)
            {
                if (MEventStopSiteSearches.WaitOne(1, true))
                {
                    Complete = true;
                }
                else
                {
                    Thread.Sleep(100);
                }
            }
        }
예제 #26
0
        protected override void FindLyricsWithTimer()
        {
            var artist = LyricUtil.RemoveFeatComment(Artist);
            artist = LyricUtil.CapatalizeString(artist);

            artist = artist.Replace(" ", "_");
            artist = artist.Replace(",", "_");
            artist = artist.Replace(".", "_");
            artist = artist.Replace("'", "_");
            artist = artist.Replace("(", "%28");
            artist = artist.Replace(")", "%29");
            artist = artist.Replace(",", "");
            artist = artist.Replace("#", "");
            artist = artist.Replace("%", "");
            artist = artist.Replace("+", "%2B");
            artist = artist.Replace("=", "%3D");
            artist = artist.Replace("-", "_");

            // French letters
            artist = artist.Replace("é", "%E9");

            var title = LyricUtil.TrimForParenthesis(Title);
            title = LyricUtil.CapatalizeString(title);

            title = title.Replace(" ", "_");
            title = title.Replace(",", "_");
            title = title.Replace(".", "_");
            title = title.Replace("'", "_");
            title = title.Replace("(", "%28");
            title = title.Replace(")", "%29");
            title = title.Replace(",", "_");
            title = title.Replace("#", "_");
            title = title.Replace("%", "_");
            title = title.Replace("?", "_");
            title = title.Replace("+", "%2B");
            title = title.Replace("=", "%3D");
            title = title.Replace("-", "_");
            title = title.Replace(":", "_");

            // German letters
            artist = artist.Replace("ü", "%FC");
            artist = artist.Replace("Ü", "%DC");
            artist = artist.Replace("ä", "%E4");
            artist = artist.Replace("Ä", "%C4");
            artist = artist.Replace("ö", "%F6");
            artist = artist.Replace("Ö", "%D6");
            artist = artist.Replace("ß", "%DF");

            // Danish letters
            title = title.Replace("å", "%E5");
            title = title.Replace("Å", "%C5");
            title = title.Replace("æ", "%E6");
            title = title.Replace("ø", "%F8");

            // French letters
            title = title.Replace("é", "%E9");

            // Validation
            if (string.IsNullOrEmpty(artist) || string.IsNullOrEmpty(title))
            {
                return;
            }

            var firstLetter = artist[0].ToString(CultureInfo.InvariantCulture);

            var urlString = SiteBaseUrl + "/lyrics/" + firstLetter + "/" + artist + "/" + title + ".html";

            var client = new LyricsWebClient();

            var uri = new Uri(urlString);
            client.OpenReadCompleted += CallbackMethod;
            client.OpenReadAsync(uri);

            while (Complete == false)
            {
                if (MEventStopSiteSearches.WaitOne(1, true))
                {
                    Complete = true;
                }
                else
                {
                    Thread.Sleep(300);
                }
            }
        }
예제 #27
0
        private void callbackMethod(object sender, OpenReadCompletedEventArgs e)
        {
            bool          thisMayBeTheCorrectLyric = true;
            StringBuilder lyricTemp = new StringBuilder();

            LyricsWebClient client = (LyricsWebClient)sender;
            Stream          reply  = null;
            StreamReader    sr     = null;

            try
            {
                reply = (Stream)e.Result;
                sr    = new StreamReader(reply, Encoding.Default);

                string line = "";

                while (line.IndexOf("GOOGLE END") == -1)
                {
                    if (sr.EndOfStream)
                    {
                        thisMayBeTheCorrectLyric = false;
                        break;
                    }
                    else
                    {
                        line = sr.ReadLine();
                    }
                }

                if (thisMayBeTheCorrectLyric)
                {
                    lyricTemp = new StringBuilder();
                    line      = sr.ReadLine();

                    while (line.IndexOf("<script type") == -1)
                    {
                        lyricTemp.Append(line);
                        if (sr.EndOfStream)
                        {
                            thisMayBeTheCorrectLyric = false;
                            break;
                        }
                        else
                        {
                            line = sr.ReadLine();
                        }
                    }

                    lyricTemp.Replace("?s", "'s");
                    lyricTemp.Replace("?t", "'t");
                    lyricTemp.Replace("?m", "'m");
                    lyricTemp.Replace("?l", "'l");
                    lyricTemp.Replace("?v", "'v");
                    lyricTemp.Replace("<br>", "\r\n");
                    lyricTemp.Replace("<br />", "\r\n");
                    lyricTemp.Replace("&quot;", "\"");
                    lyricTemp.Replace("</p>", "");
                    lyricTemp.Replace("<BR>", "");
                    lyricTemp.Replace("<br/>", "\r\n");
                    lyricTemp.Replace("&amp;", "&");

                    lyric = lyricTemp.ToString().Trim();

                    if (lyric.Contains("<td"))
                    {
                        lyric = "Not found";
                    }
                }
            }
            catch
            {
                lyric = "Not found";
            }
            finally
            {
                if (sr != null)
                {
                    sr.Close();
                }

                if (reply != null)
                {
                    reply.Close();
                }

                if (timer != null)
                {
                    timer.Stop();
                    timer.Close();
                }
                complete = true;
            }
        }
예제 #28
0
        protected override void FindLyricsWithTimer()
        {
            var fixHebrewArtist = FixHebrewName(Artist);
            var fixedHebrewTitle = FixHebrewName(Title);

            // Check there's at least one Hebrew letter in either artist or title. We skip test if not
            if (!IsHebrew(fixHebrewArtist) && !IsHebrew(fixedHebrewTitle))
            {
                LyricText = NotFound;
                return;
            }

            // 1st step - find lyrics page
            var firstUrlString = BaseUrl + SearchPathQuery + fixHebrewArtist + Space + fixedHebrewTitle;

            var findLyricsPageWebClient = new LyricsWebClient();
            findLyricsPageWebClient.OpenReadCompleted += FirstCallbackMethod;
            findLyricsPageWebClient.OpenReadAsync(new Uri(firstUrlString));

            while (_firstStepComplete == false)
            {
                if (MEventStopSiteSearches.WaitOne(1, true))
                {
                    _firstStepComplete = true;
                }
                else
                {
                    Thread.Sleep(100);
                }
            }

            if (_prfid == null || _wrkid == null)
            {
                LyricText = NotFound;
                return;
            }
            // 2nd step - find lyrics
            var secondUrlString = BaseUrl + LyricsPath + Prfid + _prfid + Wrkid + _wrkid;

            var findLyricsWebClient = new LyricsWebClient(firstUrlString);
            findLyricsWebClient.OpenReadCompleted += SecondCallbackMethod;
            findLyricsWebClient.OpenReadAsync(new Uri(secondUrlString));

            while (Complete == false)
            {
                if (MEventStopSiteSearches.WaitOne(1, true))
                {
                    Complete = true;
                }
                else
                {
                    Thread.Sleep(100);
                }
            }
        }
예제 #29
0
        private void callbackMethod(object sender, OpenReadCompletedEventArgs e)
        {
            bool thisMayBeTheCorrectLyric = true;

            LyricsWebClient client = (LyricsWebClient)sender;
            Stream          reply  = null;
            StreamReader    sr     = null;

            try
            {
                reply = (Stream)e.Result;
                sr    = new StreamReader(reply, Encoding.Default);

                string line = "";

                while (line.IndexOf("class='lyricbox' >") == -1)
                {
                    if (sr.EndOfStream)
                    {
                        thisMayBeTheCorrectLyric = false;
                        break;
                    }
                    else
                    {
                        line = sr.ReadLine();
                    }
                }

                if (thisMayBeTheCorrectLyric)
                {
                    string cutString = "class='lyricbox' >";

                    int cutIndex = line.IndexOf(cutString);

                    if (cutIndex != -1)
                    {
                        lyric = line.Substring(cutIndex + cutString.Length);
                    }

                    Encoding iso8859 = Encoding.GetEncoding("ISO-8859-1");
                    lyric = Encoding.UTF8.GetString(iso8859.GetBytes(lyric));

                    lyric = lyric.Replace("<br />", "\r\n");
                    lyric = lyric.Replace("<i>", "");
                    lyric = lyric.Replace("</i>", "");
                    lyric = lyric.Replace("<b>", "");
                    lyric = lyric.Replace("</b>", "");
                    lyric = lyric.Replace("&amp;", "&");

                    lyric = lyric.Trim();

                    if (lyric.Contains("<"))
                    {
                        lyric = "Not found";
                    }
                }
            }
            catch
            {
                lyric = "Not found";
            }
            finally
            {
                if (sr != null)
                {
                    sr.Close();
                }

                if (reply != null)
                {
                    reply.Close();
                }

                if (timer != null)
                {
                    timer.Stop();
                    timer.Close();
                }
                complete = true;
            }
        }
예제 #30
0
        protected override void FindLyricsWithTimer()
        {
            // Clean artist name
            var artist = LyricUtil.RemoveFeatComment(Artist);
            artist = LyricUtil.CapatalizeString(artist);
            artist = artist.Replace(" ", "_");

            // Clean title name
            var title = LyricUtil.TrimForParenthesis(Title);
            title = LyricUtil.CapatalizeString(title);
            title = title.Replace(" ", "_");
            title = title.Replace("?", "%3F");

            // Validate not empty
            if (string.IsNullOrEmpty(artist) || string.IsNullOrEmpty(title))
            {
                return;
            }

            var urlString = SiteBaseUrl + "/" + artist + ":" + title;

            var client = new LyricsWebClient();

            var uri = new Uri(urlString);
            client.OpenReadCompleted += CallbackMethod;
            client.OpenReadAsync(uri);

            while (Complete == false)
            {
                if (MEventStopSiteSearches.WaitOne(1, true))
                {
                    Complete = true;
                }
                else
                {
                    Thread.Sleep(300);
                }
            }
        }
예제 #31
0
        protected override void FindLyricsWithTimer()
        {
            var artist = LyricUtil.RemoveFeatComment(Artist);

            artist = LyricUtil.DeleteSpecificChars(artist);
            artist = artist.Replace(" ", "");
            artist = artist.Replace("The ", "");
            artist = artist.Replace("the ", "");
            artist = artist.Replace("-", "");

            artist = artist.ToLower();

            // Cannot find lyrics containing non-English letters!

            var title = LyricUtil.TrimForParenthesis(Title);

            title  = LyricUtil.DeleteSpecificChars(title);
            title  = title.Replace(" ", "");
            title  = title.Replace("#", "");
            artist = artist.Replace("-", "");

            // Danish letters
            title = title.Replace("æ", "");
            title = title.Replace("ø", "");
            title = title.Replace("å", "");
            title = title.Replace("Æ", "");
            title = title.Replace("Ø", "");
            title = title.Replace("Å", "");
            title = title.Replace("ö", "");
            title = title.Replace("Ö", "");

            title = title.ToLower();

            // Validation
            if (string.IsNullOrEmpty(artist) || string.IsNullOrEmpty(title))
            {
                return;
            }

            var firstLetter = artist[0].ToString(CultureInfo.InvariantCulture);

            int firstNumber;

            if (int.TryParse(firstLetter, out firstNumber))
            {
                firstLetter = "0";
            }

            var urlString = SiteBaseUrl + "/" + firstLetter + "/" + artist + "lyrics/" + title + "lyrics.html";

            var client = new LyricsWebClient();

            var uri = new Uri(urlString);

            client.OpenReadCompleted += CallbackMethod;
            client.OpenReadAsync(uri);

            while (Complete == false)
            {
                if (MEventStopSiteSearches.WaitOne(1, true))
                {
                    Complete = true;
                }
                else
                {
                    Thread.Sleep(100);
                }
            }
        }
예제 #32
0
파일: Lyrster.cs 프로젝트: nus-ii/MPTagThat
        protected override void FindLyricsWithTimer()
        {
            var artist = Artist.ToLower();
            artist = ClearName(artist);

            var title = Title.ToLower();
            title = ClearName(title);

            // Validation
            if (string.IsNullOrEmpty(artist) || string.IsNullOrEmpty(title))
            {
                LyricText = NotFound;
                return;
            }

            var urlString = SiteBaseUrl + "/lyrics/" + title + "-lyrics-" + artist + ".html";

            var client = new LyricsWebClient();

            var uri = new Uri(urlString);
            client.OpenReadCompleted += CallbackMethod;
            client.OpenReadAsync(uri);

            while (Complete == false)
            {
                if (MEventStopSiteSearches.WaitOne(1, true))
                {
                    Complete = true;
                }
                else
                {
                    Thread.Sleep(300);
                }
            }
        }
        public LyricsPluginSite(string artist, string title, ManualResetEvent m_EventStop_SiteSearches, int timeLimit)
        {
            this.timeLimit = timeLimit;
            timer = new Timer();

            artist = LyricUtil.RemoveFeatComment(artist);
            title = LyricUtil.TrimForParenthesis(title);

            // Escape characters
            artist = fixEscapeCharacters(artist);
            title = fixEscapeCharacters(title);

            // Hebrew letters
            artist = fixHebrew(artist);
            title = fixHebrew(title);

            // timer
            timer.Enabled = true;
            timer.Interval = timeLimit;
            timer.Elapsed += new ElapsedEventHandler(timer_Elapsed);
            timer.Start();

            // LyricsPlugin.com changed their API to need 2 calls. The first is to get a timer & code

            // 1st step
            string firstUrlString = "http://www.lyricsplugin.com/winamp03/plugin/?" + "artist=" + artist + "&title=" + title;

            Uri uri1 = new Uri(firstUrlString);
            LyricsWebClient client1 = new LyricsWebClient();
            client1.OpenReadCompleted += new OpenReadCompletedEventHandler(firstCallbackMethod);
            client1.OpenReadAsync(uri1);

            while (firstStepComplete == false)
            {
                if (m_EventStop_SiteSearches.WaitOne(1, true))
                {
                    firstStepComplete = true;
                }
                else
                {
                    Thread.Sleep(100);
                }
            }

            // assertion: !timestamp.Equals("") & !checkCode.Equals("");

            // 2nd step
            string secondUrlString = "http://www.lyricsplugin.com/winamp03/plugin/content.php?" + "artist=" + artist + "&title=" + title + "&time=" + timestamp + "&check=" + checkCode;

            Uri uri2 = new Uri(secondUrlString);
            LyricsWebClient client2 = new LyricsWebClient(firstUrlString);
            client2.OpenReadCompleted += new OpenReadCompletedEventHandler(secondCallbackMethod);
            client2.OpenReadAsync(uri2);

            while (complete == false)
            {
                if (m_EventStop_SiteSearches.WaitOne(1, true))
                {
                    complete = true;
                }
                else
                {
                    Thread.Sleep(100);
                }
            }
        }
예제 #34
0
        public SeekLyrics(string artist, string title, ManualResetEvent m_EventStop_SiteSearches, int timeLimit)
        {
            this.timeLimit = timeLimit;
            timer = new System.Timers.Timer();

            artist = LyricUtil.RemoveFeatComment(artist);
            artist = artist.Replace(" ", "-");
            artist = artist.Replace("'", "-");
            artist = artist.Replace("(", "");
            artist = artist.Replace(")", "");
            artist = artist.Replace(",", "");
            artist = artist.Replace("#", "");

            // German letters
            artist = artist.Replace("ü", "%FC");
            artist = artist.Replace("Ü", "");
            artist = artist.Replace("ä", "%E4");
            artist = artist.Replace("Ä", "");
            artist = artist.Replace("ö", "%E4");  // Not correct!!!
            artist = artist.Replace("Ö", "");
            artist = artist.Replace("ß", "%DF");

            // French letters
            artist = artist.Replace("é", "%E9");

            title = LyricUtil.TrimForParenthesis(title);
            title = title.Replace(" ", "-");
            title = title.Replace("'", "-");
            title = title.Replace("(", "");
            title = title.Replace(")", "");
            title = title.Replace(",", "");
            title = title.Replace("#", "");
            title = title.Replace("?", "");

            // German letters
            title = title.Replace("ü", "%FC");
            title = title.Replace("Ü", "%FC");
            title = title.Replace("ä", "%E4");
            title = title.Replace("Ä", "%C4");
            title = title.Replace("ö", "%F6");
            title = title.Replace("Ö", "%D6");
            title = title.Replace("ß", "%DF");

            // French letters
            title = title.Replace("é", "%E9");

            string urlString = "http://www.seeklyrics.com/lyrics/" + artist + "/" + title + ".html";

            timer.Enabled = true;
            timer.Interval = timeLimit;
            timer.Elapsed += new ElapsedEventHandler(timer_Elapsed);
            timer.Start();

            Uri uri = new Uri(urlString);
            LyricsWebClient client = new LyricsWebClient();
            client.OpenReadCompleted += new System.Net.OpenReadCompletedEventHandler(callbackMethod);
            client.OpenReadAsync(uri);

            while (complete == false)
            {
                if (m_EventStop_SiteSearches.WaitOne(1, true))
                {
                    complete = true;
                }
                else
                {
                    System.Threading.Thread.Sleep(100);
                }
            }
        }
예제 #35
0
        public SeekLyrics(string artist, string title, ManualResetEvent m_EventStop_SiteSearches, int timeLimit)
        {
            this.timeLimit = timeLimit;
            timer          = new System.Timers.Timer();

            artist = LyricUtil.RemoveFeatComment(artist);
            artist = artist.Replace(" ", "-");
            artist = artist.Replace("'", "-");
            artist = artist.Replace("(", "");
            artist = artist.Replace(")", "");
            artist = artist.Replace(",", "");
            artist = artist.Replace("#", "");

            // German letters
            artist = artist.Replace("ü", "%FC");
            artist = artist.Replace("Ü", "");
            artist = artist.Replace("ä", "%E4");
            artist = artist.Replace("Ä", "");
            artist = artist.Replace("ö", "%E4");  // Not correct!!!
            artist = artist.Replace("Ö", "");
            artist = artist.Replace("ß", "%DF");

            // French letters
            artist = artist.Replace("é", "%E9");

            title = LyricUtil.TrimForParenthesis(title);
            title = title.Replace(" ", "-");
            title = title.Replace("'", "-");
            title = title.Replace("(", "");
            title = title.Replace(")", "");
            title = title.Replace(",", "");
            title = title.Replace("#", "");
            title = title.Replace("?", "");

            // German letters
            title = title.Replace("ü", "%FC");
            title = title.Replace("Ü", "%FC");
            title = title.Replace("ä", "%E4");
            title = title.Replace("Ä", "%C4");
            title = title.Replace("ö", "%F6");
            title = title.Replace("Ö", "%D6");
            title = title.Replace("ß", "%DF");

            // French letters
            title = title.Replace("é", "%E9");


            string urlString = "http://www.seeklyrics.com/lyrics/" + artist + "/" + title + ".html";

            timer.Enabled  = true;
            timer.Interval = timeLimit;
            timer.Elapsed += new ElapsedEventHandler(timer_Elapsed);
            timer.Start();

            Uri             uri    = new Uri(urlString);
            LyricsWebClient client = new LyricsWebClient();

            client.OpenReadCompleted += new System.Net.OpenReadCompletedEventHandler(callbackMethod);
            client.OpenReadAsync(uri);

            while (complete == false)
            {
                if (m_EventStop_SiteSearches.WaitOne(1, true))
                {
                    complete = true;
                }
                else
                {
                    System.Threading.Thread.Sleep(100);
                }
            }
        }
예제 #36
0
        private void CallbackMethodSearch(object sender, OpenReadCompletedEventArgs e)
        {
            StringBuilder lyricTemp = new StringBuilder();

            LyricsWebClient client = (LyricsWebClient) sender;
            Stream reply = null;
            StreamReader sr = null;

            string id = string.Empty;

            try
            {
                reply = (Stream) e.Result;
                sr = new StreamReader(reply, Encoding.Default);

                string result = sr.ReadToEnd();

                if (result.Equals(""))
                {
                    lyric = "Not found";
                    return;
                }

                id = result.Substring(0, result.IndexOf(@"\"));

                string urlString = string.Format("http://www.lyrdb.com/getlyr.php?q={0}", id);

                LyricsWebClient client2 = new LyricsWebClient();

                Uri uri = new Uri(urlString);
                client2.OpenReadCompleted += new OpenReadCompletedEventHandler(CallbackMethodGetLyric);
                client2.OpenReadAsync(uri);

                while (complete == false)
                {
                    if (m_EventStop_SiteSearches.WaitOne(1, true))
                    {
                        complete = true;
                    }
                    else
                    {
                        Thread.Sleep(300);
                    }
                }
            }
            catch
            {
                lyric = "Not found";
            }
            finally
            {
                if (sr != null)
                {
                    sr.Close();
                }

                if (reply != null)
                {
                    reply.Close();
                }
            }
        }
예제 #37
0
        private void callbackMethod(object sender, OpenReadCompletedEventArgs e)
        {
            LyricsWebClient client = (LyricsWebClient)sender;
            Stream          reply  = null;
            StreamReader    sr     = null;

            try
            {
                reply = (Stream)e.Result;
                sr    = new StreamReader(reply, Encoding.Default);

                string line = sr.ReadToEnd();

                // Replace the new line stuff in the result, as the regex might have problems
                line = line.Replace("\n", "");
                line = line.Replace("\r", "");
                line = line.Replace("\t", "");

                string pat = @"<a href=""http://www\.ringtonematcher\.com/.*?</a>(.*?)<a href";

                // Compile the regular expression.
                Regex r = new Regex(pat, RegexOptions.IgnoreCase);
                // Match the regular expression pattern against a text string.
                Match m = r.Match(line);
                if (m.Success)
                {
                    Group g1 = m.Groups[1];
                    foreach (Capture c1 in g1.Captures)
                    {
                        lyric = c1.Value;
                    }
                }

                if (lyric.Length > 0)
                {
                    lyric = lyric.Replace("?s", "'s");
                    lyric = lyric.Replace("?t", "'t");
                    lyric = lyric.Replace("?m", "'m");
                    lyric = lyric.Replace("?l", "'l");
                    lyric = lyric.Replace("?v", "'v");
                    lyric = lyric.Replace("<br>", "\r\n");
                    lyric = lyric.Replace("<br />", "\r\n");
                    lyric = lyric.Replace("&#039;", "'");
                    lyric = lyric.Replace("</p>", "");
                    lyric = lyric.Replace("<BR>", "");
                    lyric = lyric.Replace("<br/>", "\r\n");
                    lyric = lyric.Trim();
                }
                else
                {
                    lyric = "Not found";
                }
            }
            catch
            {
                lyric = "Not found";
            }
            finally
            {
                if (sr != null)
                {
                    sr.Close();
                }

                if (reply != null)
                {
                    reply.Close();
                }
                complete = true;
            }
        }
예제 #38
0
        private void secondCallbackMethod(object sender, OpenReadCompletedEventArgs e)
        {
            bool          thisMayBeTheCorrectLyric = true;
            StringBuilder lyricTemp = new StringBuilder();

            LyricsWebClient client = (LyricsWebClient)sender;
            Stream          reply  = null;
            StreamReader    sr     = null;

            try
            {
                reply = (Stream)e.Result;
                sr    = new StreamReader(reply, Encoding.UTF8);

                string line           = "";
                int    noOfLinesCount = 0;

                while (line.IndexOf(@"<div id=""lyrics"">") == -1)
                {
                    if (sr.EndOfStream || ++noOfLinesCount > 300)
                    {
                        thisMayBeTheCorrectLyric = false;
                        break;
                    }
                    else
                    {
                        line = sr.ReadLine();
                    }
                }


                if (thisMayBeTheCorrectLyric)
                {
                    lyricTemp = new StringBuilder();
                    line      = sr.ReadLine();

                    while (line.IndexOf("</div>") == -1)
                    {
                        lyricTemp.Append(line);

                        if (sr.EndOfStream)
                        {
                            thisMayBeTheCorrectLyric = false;
                            break;
                        }
                        else
                        {
                            line = sr.ReadLine();
                        }
                    }

                    // Clean lyrics
                    lyric = cleanLyrics(lyricTemp);

                    if (lyric.Length == 0 || (lyric.Contains("<") || lyric.Contains(">") || lyric.Contains("a href") || lyric.ToLower().Contains("www")))
                    {
                        lyric = "Not found";
                    }
                }
            }
            catch
            {
                lyric = "Not found";
            }
            finally
            {
                if (sr != null)
                {
                    sr.Close();
                }

                if (reply != null)
                {
                    reply.Close();
                }
                complete = true;
            }
        }
        public HotLyrics(string artist, string title, ManualResetEvent m_EventStop_SiteSearches, int timeLimit)
        {
            this.timeLimit = timeLimit/2;
            timer = new Timer();

            artist = LyricUtil.RemoveFeatComment(artist);
            artist = LyricUtil.CapatalizeString(artist);

            artist = artist.Replace(" ", "_");
            artist = artist.Replace(",", "_");
            artist = artist.Replace(".", "_");
            artist = artist.Replace("'", "_");
            artist = artist.Replace("(", "%28");
            artist = artist.Replace(")", "%29");
            artist = artist.Replace(",", "");
            artist = artist.Replace("#", "");
            artist = artist.Replace("%", "");
            artist = artist.Replace("+", "%2B");
            artist = artist.Replace("=", "%3D");
            artist = artist.Replace("-", "_");

            // French letters
            artist = artist.Replace("é", "%E9");

            title = LyricUtil.TrimForParenthesis(title);
            title = LyricUtil.CapatalizeString(title);

            title = title.Replace(" ", "_");
            title = title.Replace(",", "_");
            title = title.Replace(".", "_");
            title = title.Replace("'", "_");
            title = title.Replace("(", "%28");
            title = title.Replace(")", "%29");
            title = title.Replace(",", "_");
            title = title.Replace("#", "_");
            title = title.Replace("%", "_");
            title = title.Replace("?", "_");
            title = title.Replace("+", "%2B");
            title = title.Replace("=", "%3D");
            title = title.Replace("-", "_");
            title = title.Replace(":", "_");

            // German letters
            artist = artist.Replace("ü", "%FC");
            artist = artist.Replace("Ü", "%DC");
            artist = artist.Replace("ä", "%E4");
            artist = artist.Replace("Ä", "%C4");
            artist = artist.Replace("ö", "%F6");
            artist = artist.Replace("Ö", "%D6");
            artist = artist.Replace("ß", "%DF");

            // Danish letters
            title = title.Replace("å", "%E5");
            title = title.Replace("Å", "%C5");
            title = title.Replace("æ", "%E6");
            title = title.Replace("ø", "%F8");

            // French letters
            title = title.Replace("é", "%E9");

            if (string.IsNullOrEmpty(artist) || string.IsNullOrEmpty(title))
            {
                return;
            }

            string firstLetter = artist[0].ToString();

            string urlString = "http://www.hotlyrics.net/lyrics/" + firstLetter + "/" + artist + "/" + title + ".html";

            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 OpenReadCompletedEventHandler(callbackMethod);
            client.OpenReadAsync(uri);

            while (complete == false)
            {
                if (m_EventStop_SiteSearches.WaitOne(1, true))
                {
                    complete = true;
                }
                else
                {
                    Thread.Sleep(300);
                }
            }
        }
예제 #40
0
        private void firstCallbackMethod(object sender, OpenReadCompletedEventArgs e)
        {
            bool          thisMayBeTheCorrectPage = true;
            StringBuilder lyricsCommand           = new StringBuilder();

            LyricsWebClient client = (LyricsWebClient)sender;
            Stream          reply  = null;
            StreamReader    sr     = null;

            try
            {
                reply = (Stream)e.Result;
                sr    = new StreamReader(reply, Encoding.UTF8);

                string line           = "";
                int    noOfLinesCount = 0;

                while (line.IndexOf(@"getContent(") == -1)
                {
                    if (sr.EndOfStream || ++noOfLinesCount > 300)
                    {
                        thisMayBeTheCorrectPage = false;
                        break;
                    }
                    else
                    {
                        line = sr.ReadLine();
                    }
                }

                if (thisMayBeTheCorrectPage)
                {
                    lyricsCommand.Append(line);

                    string[] parameters = line.Split('\'');

                    // todo - Find a better check here
                    if (parameters.Length == 9)
                    {
                        timestamp = parameters[5];
                        checkCode = parameters[7];
                    }
                }
            }
            catch
            {
                lyric = "Not found";
            }
            finally
            {
                if (sr != null)
                {
                    sr.Close();
                }

                if (reply != null)
                {
                    reply.Close();
                }
                firstStepComplete = true;
            }
        }
예제 #41
0
        protected override void FindLyricsWithTimer()
        {
            var artist = FixEscapeCharacters(Artist);

            // 1st step - find lyrics page
            var firstUrlString = BaseUrl + SearchPathQuery + artist;

            var findLyricsPageWebClient = new LyricsWebClient();
            findLyricsPageWebClient.OpenReadCompleted += FirstCallbackMethod;
            findLyricsPageWebClient.OpenReadAsync(new Uri(firstUrlString));

            while (_firstStepComplete == false)
            {
                if (MEventStopSiteSearches.WaitOne(1, true))
                {
                    _firstStepComplete = true;
                }
                else
                {
                    Thread.Sleep(100);
                }
            }

            if (_lyricsIndex == null)
            {
                LyricText = NotFound;
                return;
            }
            // 2nd step - find lyrics
            var secondUrlString = BaseUrl + LyricsPath + _lyricsIndex;

            var findLyricsWebClient = new LyricsWebClient(firstUrlString);
            findLyricsWebClient.OpenReadCompleted += SecondCallbackMethod;
            findLyricsWebClient.OpenReadAsync(new Uri(secondUrlString));

            while (Complete == false)
            {
                if (MEventStopSiteSearches.WaitOne(1, true))
                {
                    Complete = true;
                }
                else
                {
                    Thread.Sleep(100);
                }
            }
        }