Esempio n. 1
0
 protected override void InitLibrary()
 {
     _lyricsHelper                    = new ThreePM.Utilities.LyricsHelper(this.Library);
     _lyricsHelper.LyricsFound       += new EventHandler <ThreePM.Utilities.LyricsFoundEventArgs>(LyricsHelper_LyricsFound);
     _lyricsHelper.CurrentURLChanged += new EventHandler(LyricsHelper_CurrentURLChanged);
     _lyricsHelper.StatusChanged     += new EventHandler(LyricsHelper_StatusChanged);
 }
Esempio n. 2
0
        public LyricsSearchResults ProcessSearchResults(ThreePM.MusicPlayer.SongInfo song, string htmlPage, out string nextURL)
        {
            nextURL = "";

            int start = htmlPage.IndexOf(" artists found:");

            if (start != -1)
            {
                // found more than one.
                start = htmlPage.IndexOf("title=\"" + song.Artist + " lyrics\"");
                if (start != -1)
                {
                    start = htmlPage.LastIndexOf("/lyrics", start);
                    int    end = htmlPage.IndexOf("\" title", start);
                    string url = "http://www.lyricsmania.com" + htmlPage.Substring(start, end - start);
                    nextURL = url;
                    return(LyricsSearchResults.SearchAgain);
                }
            }
            else
            {
                string regex = LyricsHelper.GetSongTitleRegex(song);

                regex = "(?<=title=\\\")" + regex;

                start = System.Text.RegularExpressions.Regex.Match(htmlPage, regex, RegexOptions.IgnoreCase).Index;

                // if the regex didnt work, try old fashioned
                if (start <= 0)
                {
                    System.Diagnostics.Debug.WriteLine("Old fashioned!!");
                    start = htmlPage.IndexOf("title=\"" + song.Title + " lyrics\"");
                }

                if (start != -1)
                {
                    start = htmlPage.LastIndexOf("/lyrics", start);
                    int end = htmlPage.IndexOf("\" title", start);
                    if (end != -1)
                    {
                        string url = htmlPage.Substring(start, end - start);
                        nextURL = "http://www.lyricsmania.com" + url;
                        return(LyricsSearchResults.Found);
                    }
                }
            }

            return(LyricsSearchResults.NotFound);
        }
Esempio n. 3
0
        public HttpServer(MusicPlayer.Player player, MusicLibrary.Library library)
        {
            _serverTemplate = Properties.Resources.HttpServerTemplate;

            _player  = player;
            _library = library;

            _helper = new LyricsHelper(library);
            _helper.LyricsNotFound += delegate { _lastLyrics = "Not found."; };
            _helper.LyricsFound    += new EventHandler <LyricsFoundEventArgs>(Helper_LyricsFound);

            // Create a new server socket, set up all the endpoints, bind the socket and then listen
            _listener = new Socket(0, SocketType.Stream, ProtocolType.Tcp);
            var endpoint = new IPEndPoint(IPAddress.Any, 8001);

            _listener.Bind(endpoint);
            _listener.Listen(-1);
            // start listening
            _listener.BeginAccept(AcceptFinished, null);
        }
Esempio n. 4
0
        public LyricsSearchResults ProcessSearchResults(ThreePM.MusicPlayer.SongInfo song, string htmlPage, out string nextURL)
        {
            // Songs:</b><br>.*<a href\=\"(?<url>.*?)\">Rhinestone Cowboy Lyrics</a>
            nextURL = "";

            string regex = LyricsHelper.GetSongTitleRegex(song);

            regex = "Songs:</b><br>.*<a href=\\\"(?<url>.*?)\\\">" + regex + " Lyrics</a>";

            Match m = Regex.Match(htmlPage, regex, RegexOptions.Singleline | RegexOptions.Multiline | RegexOptions.IgnoreCase);

            if (m.Groups["url"].Success)
            {
                string url = m.Groups["url"].Value;

                url = "http://www.lyricsdepot.com" + url;

                nextURL = url;
                return(LyricsSearchResults.Found);
            }
            return(LyricsSearchResults.NotFound);
        }