Exemplo n.º 1
0
        public string GetSearchURL(ThreePM.MusicPlayer.SongInfo song)
        {
            string artist = song.Artist.Replace(' ', '_');
            string title  = song.Title.Replace(' ', '_');

            return(string.Format(@"http://www.lyricwiki.org/api.php?action=lyrics&artist={0}&song={1}&fmt=xml", System.Web.HttpUtility.UrlEncode(artist), System.Web.HttpUtility.UrlEncode(title)));
        }
Exemplo n.º 2
0
        public static string GetSongTitleRegex(ThreePM.MusicPlayer.SongInfo song)
        {
            /*
             *
             *
             * I'*m Like A Lawyer With The Way I'*m Always Trying To Get You Off \(Me [\+\&(and)]* You\)
             *
             */

            string regex = song.Title.ToLower();

            regex = regex.Replace("*", "\\*");
            regex = regex.Replace("?", "\\?*");
            regex = regex.Replace("'", "'*");
            regex = regex.Replace(".", "\\.*");
            regex = regex.Replace(" + ", " and ");
            regex = regex.Replace(" & ", " and ");
            regex = regex.Replace("\"", "\\\"*");
            regex = regex.Replace("(", "\\(*");
            regex = regex.Replace(")", "\\)*");
            regex = regex.Replace("[", "\\[*");
            regex = regex.Replace("]", "\\]*");
            regex = regex.Replace("{", "\\{*");
            regex = regex.Replace("}", "\\}*");
            regex = regex.Replace("$", "\\$*");
            regex = regex.Replace(" and ", " [\\+\\&(and)]* ");
            return(regex);
        }
Exemplo n.º 3
0
        public string GetSearchURL(ThreePM.MusicPlayer.SongInfo song)
        {
            string artist = song.Artist;

            if (artist.StartsWith("The "))
            {
                artist = artist.Substring(4) + " (The)";
            }
            return(string.Format(@"http://www.lyricsmania.com/search.php?c=artist&k={0}", System.Web.HttpUtility.UrlEncode(artist)));
        }
Exemplo n.º 4
0
 private void LoadLyrics(ThreePM.MusicPlayer.SongInfo songInfo)
 {
     _lastSong = songInfo;
     if (this.Library.GetSong(songInfo.FileName) is ThreePM.MusicLibrary.LibraryEntry entry && !string.IsNullOrEmpty(entry.Lyrics))
     {
         _lyricsHelper.CancelLastRequest();
         SetLyricsTextBox(entry.Lyrics);
         btnGo.Enabled = false;
         txtURL.Text   = "Internal";
     }
Exemplo n.º 5
0
        public static void SaveLyricsFile(ThreePM.MusicPlayer.SongInfo song, string lyrics)
        {
            string file = song.FileName;

            file = System.IO.Path.ChangeExtension(file, ".lyrics");
            try
            {
                File.WriteAllText(file, lyrics);
            }
            catch { }
        }
Exemplo n.º 6
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);
        }
Exemplo n.º 7
0
 public LyricsSearchResults ProcessSearchResults(ThreePM.MusicPlayer.SongInfo song, string htmlPage, out string nextURL)
 {
     nextURL = "";
     if (htmlPage == "Not found")
     {
         return(LyricsSearchResults.NotFound);
     }
     else if (!htmlPage.StartsWith("<!DOCTYPE", StringComparison.OrdinalIgnoreCase))
     {
         nextURL = Regex.Match(htmlPage, "<url>(?<url>.*?)</url>").Groups["url"].Value;
         if (nextURL.Equals("http://lyrics.wikia.com"))
         {
             return(LyricsSearchResults.NotFound);
         }
         return(LyricsSearchResults.SearchAgain);
     }
     else
     {
         return(LyricsSearchResults.FoundOnThisPage);
     }
 }
Exemplo n.º 8
0
        public void LoadLyrics(ThreePM.MusicPlayer.SongInfo song, bool skipTextFile, bool onlyTextFile, bool skipOtherSongsInDatabase)
        {
            if (song.FileName.StartsWith("http://", StringComparison.OrdinalIgnoreCase) && string.IsNullOrEmpty(song.Title) && string.IsNullOrEmpty(song.Artist))
            {
                _lastLyrics = "";

                if (LyricsFound != null)
                {
                    var e = new LyricsFoundEventArgs("");
                    LyricsFound(this, e);
                }
                return;
            }

            _currentLyricsObject = 0;

            _song = song;

            if (onlyTextFile)
            {
                if (!CheckForLyricsTextFile())
                {
                    LyricsNotFound?.Invoke(this, EventArgs.Empty);
                }

                return;
            }

            // check for other songs in the DB
            if (!skipOtherSongsInDatabase && CheckForLyricsFromDatabase())
            {
                return;
            }

            if (skipTextFile || CheckForLyricsTextFile() == false)
            {
                SearchCurrentLyricsSite();
            }
        }
Exemplo n.º 9
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);
        }
Exemplo n.º 10
0
 public void LoadLyrics(ThreePM.MusicPlayer.SongInfo song)
 {
     LoadLyrics(song, false, false, false);
 }
Exemplo n.º 11
0
        public string GetSearchURL(ThreePM.MusicPlayer.SongInfo song)
        {
            string artist = song.Artist.Replace(' ', '-').Replace("!", "").ToLower();

            return(string.Format(@"http://www.lyricsdepot.com/{0}/", artist));
        }
Exemplo n.º 12
0
        //// Have to do the desctructor this way, because static things dont have destructors
        //private class Destructor
        //{
        //    ~Destructor()
        //    {
        //        // This made things crash... is it bad to not dispose bitmaps :)

        //        //string[] keys = new string[cache.Count];
        //        //cache.Keys.CopyTo(keys, 0);
        //        //for (int i = cache.Count - 1; i >= 0; i--)
        //        //{
        //        //    string dir = keys[i];
        //        //    cache[dir].Dispose();
        //        //    cache[dir] = null;
        //        //    cache.Remove(dir);
        //        //}
        //    }
        //}

        //private static Destructor m_destructor = new Destructor();
        //private static Dictionary<string, Bitmap> cache = new Dictionary<string, Bitmap>();

        public static Bitmap GetAlbumArt(string filename, int width, int height)
        {
            if (width == 0 || height == 0)
            {
                return(null);
            }
            if (filename.StartsWith("http://", StringComparison.OrdinalIgnoreCase))
            {
                return(null);
            }

            var info = new ThreePM.MusicPlayer.SongInfo(filename);

            if (info.HasFrontCover)
            {
                return(info.GetFrontCover(width, height));
            }

            //if (CacheContains(filename))
            //{
            //    return GetCachedBitmap(filename, width, height);
            //}

            string imgFile = "";

            if (!string.IsNullOrEmpty(filename))
            {
                string dir   = Path.GetDirectoryName(filename);
                bool   found = false;
                foreach (string fold in MusicLibrary.Library.NonExistantFolders)
                {
                    if (dir.StartsWith(fold))
                    {
                        found = true;
                    }
                }
                if (!found)
                {
                    if (!dir.EndsWith(Path.DirectorySeparatorChar.ToString()))
                    {
                        dir += Path.DirectorySeparatorChar;
                    }

                    if (Directory.Exists(dir))
                    {
                        string[] files = Directory.GetFiles(dir, "AlbumArt_*_Large.jpg", SearchOption.TopDirectoryOnly);
                        if (files.Length > 0)
                        {
                            imgFile = files[0];
                        }
                        else if (File.Exists(dir + "Folder.jpg"))
                        {
                            imgFile = dir + "Folder.jpg";
                        }
                    }
                }
            }
            if (string.IsNullOrEmpty(imgFile))
            {
                //AddCachedBitmap(filename, null);
                //return GetCachedBitmap(filename, width, height);
                return(new Bitmap(Properties.Resources.NoAlbumArt, new Size(width, height)));
            }
            else
            {
                using (Stream s = File.OpenRead(imgFile))
                {
                    using (var img = Image.FromStream(s))
                    {
                        //AddCachedBitmap(filename, new Bitmap(img));
                        //return GetCachedBitmap(filename, width, height);
                        return(new Bitmap(img, new Size(width, height)));
                    }
                }
            }
        }