public bool Parse(string html)
        {
            _songs.Clear();
            HTMLUtil util       = new HTMLUtil();
            string   strHtmlLow = html.ToLower();

            int begIndex = 0;
            int endIndex = 0;

            //	Extract Cover URL
            string pattern = @"<!--Begin.*?Album.*?Photo-->\s*?.*?<img.*?src=\""(.*?)\""";

            if (FindPattern(pattern, html))
            {
                _strImageURL = _match.Groups[1].Value;
            }

            //	Extract Review
            pattern = @"<td.*?class=""tab_off""><a.*?href=""(.*?)"">.*?Review.*?</a>";
            if (FindPattern(pattern, html))
            {
                try
                {
                    string contentinfo = AllmusicSiteScraper.GetHTTP(_match.Groups[1].Value);
                    pattern = @"<p.*?class=""author"">.*\s*?.*?<p.*?class=""text"">(.*?)</p>";
                    if (FindPattern(pattern, contentinfo))
                    {
                        string data = _match.Groups[1].Value;
                        util.RemoveTags(ref data);
                        util.ConvertHTMLToAnsi(data, out data);
                        _strReview = data.Trim();
                    }
                }
                catch (Exception) {}
            }

            //	Extract Artist
            pattern = @"<h3.*?artist</h3>\s*?.*?<a.*"">(.*)</a>";
            if (FindPattern(pattern, html))
            {
                _artist = _match.Groups[1].Value;
                util.RemoveTags(ref _artist);
            }

            //	Extract Album
            pattern = @"<h3.*?album</h3>\s*?.*?<p>(.*)</P>";
            if (FindPattern(pattern, html))
            {
                _strTitle = _match.Groups[1].Value;
                util.RemoveTags(ref _strTitle);
            }

            // Extract Rating
            pattern = @"<h3.*?rating</h3>\s*?.*?src=""(.*?)""";
            if (FindPattern(pattern, html))
            {
                string strRating = _match.Groups[1].Value;
                util.RemoveTags(ref strRating);
                strRating = strRating.Substring(26, 1);
                try
                {
                    _iRating = Int32.Parse(strRating);
                }
                catch (Exception) {}
            }

            //	Release Date
            pattern = @"<h3.*?release.*?date</h3>\s*?.*?<p>(.*)</P>";
            if (FindPattern(pattern, html))
            {
                _strDateOfRelease = _match.Groups[1].Value;
                util.RemoveTags(ref _strDateOfRelease);

                //	extract the year out of something like "1998 (release)" or "12 feb 2003"
                int nPos = _strDateOfRelease.IndexOf("19");
                if (nPos > -1)
                {
                    if ((int)_strDateOfRelease.Length >= nPos + 3 && Char.IsDigit(_strDateOfRelease[nPos + 2]) &&
                        Char.IsDigit(_strDateOfRelease[nPos + 3]))
                    {
                        string strYear = _strDateOfRelease.Substring(nPos, 4);
                        _strDateOfRelease = strYear;
                    }
                    else
                    {
                        nPos = _strDateOfRelease.IndexOf("19", nPos + 2);
                        if (nPos > -1)
                        {
                            if ((int)_strDateOfRelease.Length >= nPos + 3 && Char.IsDigit(_strDateOfRelease[nPos + 2]) &&
                                Char.IsDigit(_strDateOfRelease[nPos + 3]))
                            {
                                string strYear = _strDateOfRelease.Substring(nPos, 4);
                                _strDateOfRelease = strYear;
                            }
                        }
                    }
                }

                nPos = _strDateOfRelease.IndexOf("20");
                if (nPos > -1)
                {
                    if ((int)_strDateOfRelease.Length > nPos + 3 && Char.IsDigit(_strDateOfRelease[nPos + 2]) &&
                        Char.IsDigit(_strDateOfRelease[nPos + 3]))
                    {
                        string strYear = _strDateOfRelease.Substring(nPos, 4);
                        _strDateOfRelease = strYear;
                    }
                    else
                    {
                        nPos = _strDateOfRelease.IndexOf("20", nPos + 1);
                        if (nPos > -1)
                        {
                            if ((int)_strDateOfRelease.Length > nPos + 3 && Char.IsDigit(_strDateOfRelease[nPos + 2]) &&
                                Char.IsDigit(_strDateOfRelease[nPos + 3]))
                            {
                                string strYear = _strDateOfRelease.Substring(nPos, 4);
                                _strDateOfRelease = strYear;
                            }
                        }
                    }
                }
            }

            // Extract Genre
            begIndex = strHtmlLow.IndexOf("<h3>genre</h3>");
            endIndex = strHtmlLow.IndexOf("</div>", begIndex + 2);
            if (begIndex != -1 && endIndex != -1)
            {
                string contentInfo = html.Substring(begIndex, endIndex - begIndex);
                pattern = @"(<li>(.*?)</li>)";
                if (FindPattern(pattern, contentInfo))
                {
                    string data = "";
                    while (_match.Success)
                    {
                        data  += string.Format("{0}, ", _match.Groups[2].Value);
                        _match = _match.NextMatch();
                    }
                    util.RemoveTags(ref data);
                    util.ConvertHTMLToAnsi(data, out _strGenre);
                    _strGenre = _strGenre.Trim(new[] { ' ', ',' });
                }
            }

            // Extract Styles
            begIndex = strHtmlLow.IndexOf("<h3>style</h3>");
            endIndex = strHtmlLow.IndexOf("</div>", begIndex + 2);
            if (begIndex != -1 && endIndex != -1)
            {
                string contentInfo = html.Substring(begIndex, endIndex - begIndex);
                pattern = @"(<li>(.*?)</li>)";
                if (FindPattern(pattern, contentInfo))
                {
                    string data = "";
                    while (_match.Success)
                    {
                        data  += string.Format("{0}, ", _match.Groups[2].Value);
                        _match = _match.NextMatch();
                    }
                    util.RemoveTags(ref data);
                    util.ConvertHTMLToAnsi(data, out _strStyles);
                    _strStyles = _strStyles.Trim(new[] { ' ', ',' });
                }
            }

            // Extract Moods
            begIndex = strHtmlLow.IndexOf("<h3>moods</h3>");
            endIndex = strHtmlLow.IndexOf("</div>", begIndex + 2);
            if (begIndex != -1 && endIndex != -1)
            {
                string contentInfo = html.Substring(begIndex, endIndex - begIndex);
                pattern = @"(<li>(.*?)</li>)";
                if (FindPattern(pattern, contentInfo))
                {
                    string data = "";
                    while (_match.Success)
                    {
                        data  += string.Format("{0}, ", _match.Groups[2].Value);
                        _match = _match.NextMatch();
                    }
                    util.RemoveTags(ref data);
                    util.ConvertHTMLToAnsi(data, out _strTones);
                    _strTones = _strTones.Trim(new[] { ' ', ',' });
                }
            }

            // Extract Songs
            begIndex = strHtmlLow.IndexOf("<!-- tracks table -->");
            endIndex = strHtmlLow.IndexOf("<!-- end tracks table -->", begIndex + 2);
            if (begIndex != -1 && endIndex != -1)
            {
                string contentInfo = html.Substring(begIndex, endIndex - begIndex);
                pattern = @"<tr.*class=""visible"".*?\s*?<td.*</td>\s*?.*<td.*</td>\s*?.*<td.*?>(?<track>.*)</td>" +
                          @"\s*?.*<td.*</td>\s*?.*<td.*?>(?<title>.*)</td>\s*?.*?<td.*?>\s*?.*</td>\s*?.*?<td.*?>(?<duration>.*)</td>";

                if (FindPattern(pattern, contentInfo))
                {
                    while (_match.Success)
                    {
                        //	Tracknumber
                        int iTrack = 0;
                        try
                        {
                            iTrack = Int32.Parse(_match.Groups["track"].Value);
                        }
                        catch (Exception) {}

                        // Song Title
                        string strTitle = _match.Groups["title"].Value;
                        util.RemoveTags(ref strTitle);
                        util.ConvertHTMLToAnsi(strTitle, out strTitle);

                        //	Duration
                        int    iDuration   = 0;
                        string strDuration = _match.Groups["duration"].Value;
                        int    iPos        = strDuration.IndexOf(":");
                        if (iPos >= 0)
                        {
                            string strMin, strSec;
                            strMin = strDuration.Substring(0, iPos);
                            iPos++;
                            strSec = strDuration.Substring(iPos);
                            int iMin = 0, iSec = 0;
                            try
                            {
                                iMin = Int32.Parse(strMin);
                                iSec = Int32.Parse(strSec);
                            }
                            catch (Exception) {}
                            iDuration = iMin * 60 + iSec;
                        }

                        //	Create new song object
                        MusicSong newSong = new MusicSong();
                        newSong.Track    = iTrack;
                        newSong.SongName = strTitle;
                        newSong.Duration = iDuration;
                        _songs.Add(newSong);

                        _match = _match.NextMatch();
                    }
                }
            }

            //	Set to "Not available" if no value from web
            if (_artist.Length == 0)
            {
                _artist = GUILocalizeStrings.Get(416);
            }
            if (_strDateOfRelease.Length == 0)
            {
                _strDateOfRelease = GUILocalizeStrings.Get(416);
            }
            if (_strGenre.Length == 0)
            {
                _strGenre = GUILocalizeStrings.Get(416);
            }
            if (_strTones.Length == 0)
            {
                _strTones = GUILocalizeStrings.Get(416);
            }
            if (_strStyles.Length == 0)
            {
                _strStyles = GUILocalizeStrings.Get(416);
            }
            if (_strTitle.Length == 0)
            {
                _strTitle = GUILocalizeStrings.Get(416);
            }

            if (_strTitle2.Length == 0)
            {
                _strTitle2 = _strTitle;
            }

            Loaded = true;
            return(true);
        }
        /// <summary>
        /// Parse the Detail Page returned from the Allmusic Scraper
        /// </summary>
        /// <param name="strHTML"></param>
        /// <returns></returns>
        public bool Parse(string strHTML)
        {
            HTMLUtil util       = new HTMLUtil();
            int      begIndex   = 0;
            int      endIndex   = 0;
            string   strHTMLLow = strHTML.ToLower();

            // Get the Artist Name
            string pattern = @"<h1.*class=""title"">(.*)</h1>";

            if (!FindPattern(pattern, strHTML))
            {
                return(false);
            }

            _strArtistName = _match.Groups[1].Value;

            // Born
            pattern = @"<h3>.*Born.*</h3>\s*?<p>(.*)</p>";
            if (FindPattern(pattern, strHTML))
            {
                string strValue = _match.Groups[1].Value;
                util.RemoveTags(ref strValue);
                util.ConvertHTMLToAnsi(strValue, out _strBorn);
                _strBorn = _strBorn.Trim();
            }

            // Years Active
            pattern = @"(<span.*?class=""active"">(.*?)</span>)";
            if (FindPattern(pattern, strHTML))
            {
                while (_match.Success)
                {
                    _strYearsActive += string.Format("{0}s, ", _match.Groups[2].Value);
                    _match           = _match.NextMatch();
                }
                _strYearsActive = _strYearsActive.Trim(new[] { ' ', ',' });
            }

            // Genre
            pattern = @"<div.*?id=""genre-style"">\s*?.*?\s*?<h3>.*?Genres.*?</h3>\s*?.*?(<p>(.*?)</p>)";
            if (FindPattern(pattern, strHTML))
            {
                string data = "";
                while (_match.Success)
                {
                    data  += string.Format("{0}, ", _match.Groups[2].Value);
                    _match = _match.NextMatch();
                }
                util.RemoveTags(ref data);
                util.ConvertHTMLToAnsi(data, out _strGenres);
                _strGenres = _strGenres.Trim(new[] { ' ', ',' });
            }

            // Style
            begIndex = strHTMLLow.IndexOf("<h3>styles</h3>");
            endIndex = strHTMLLow.IndexOf("<!--end genre/styles-->", begIndex + 2);

            if (begIndex != -1 && endIndex != -1)
            {
                string contentInfo = strHTML.Substring(begIndex, endIndex - begIndex);
                pattern = @"(<li>(.*?)</li>)";
                if (FindPattern(pattern, contentInfo))
                {
                    string data = "";
                    while (_match.Success)
                    {
                        data  += string.Format("{0}, ", _match.Groups[2].Value);
                        _match = _match.NextMatch();
                    }
                    util.RemoveTags(ref data);
                    util.ConvertHTMLToAnsi(data, out _strStyles);
                    _strStyles = _strStyles.Trim(new[] { ' ', ',' });
                }
            }

            // Mood
            begIndex = strHTMLLow.IndexOf("<h3>moods</h3>");
            endIndex = strHTMLLow.IndexOf("</div>", begIndex + 2);
            if (begIndex != -1 && endIndex != -1)
            {
                string contentInfo = strHTML.Substring(begIndex, endIndex - begIndex);
                pattern = @"(<li>(.*?)</li>)";
                if (FindPattern(pattern, contentInfo))
                {
                    string data = "";
                    while (_match.Success)
                    {
                        data  += string.Format("{0}, ", _match.Groups[2].Value);
                        _match = _match.NextMatch();
                    }
                    util.RemoveTags(ref data);
                    util.ConvertHTMLToAnsi(data, out _strTones);
                    _strTones = _strTones.Trim(new[] { ' ', ',' });
                }
            }

            // Instruments
            begIndex = strHTMLLow.IndexOf("<h3>instruments</h3>");
            endIndex = strHTMLLow.IndexOf("</div>", begIndex + 2);
            if (begIndex != -1 && endIndex != -1)
            {
                string contentInfo = strHTML.Substring(begIndex, endIndex - begIndex);
                if (FindPattern(pattern, contentInfo))
                {
                    string data = "";
                    while (_match.Success)
                    {
                        data  += string.Format("{0}, ", _match.Groups[2].Value);
                        _match = _match.NextMatch();
                    }
                    util.RemoveTags(ref data);
                    util.ConvertHTMLToAnsi(data, out _strInstruments);
                    _strInstruments = _strInstruments.Trim(new[] { ' ', ',' });
                }
            }

            // picture URL
            pattern = @"<div.*?class=""image"">\s*?.*<img.*id=""artist_image"".*?src=\""(.*?)\""";
            if (FindPattern(pattern, strHTML))
            {
                _strArtistPictureURL = _match.Groups[1].Value;
            }

            // parse AMG BIOGRAPHY
            pattern = @"<td.*?class=""tab_off""><a.*?href=""(.*?)"">.*?Biography.*?</a>";
            if (FindPattern(pattern, strHTML))
            {
                try
                {
                    string contentinfo = AllmusicSiteScraper.GetHTTP(_match.Groups[1].Value);
                    begIndex = contentinfo.IndexOf("<!--Begin Biography -->");
                    endIndex = contentinfo.IndexOf("</div>", begIndex + 2);
                    if (begIndex != -1 && endIndex != -1)
                    {
                        pattern = @"<p.*?class=""text"">(.*?)</p>";
                        if (FindPattern(pattern, contentinfo))
                        {
                            string data = _match.Groups[1].Value;
                            util.RemoveTags(ref data);
                            util.ConvertHTMLToAnsi(data, out data);
                            _strAMGBiography = data.Trim();
                        }
                    }
                }
                catch (Exception) {}
            }


            string compilationPage = "";
            string singlesPage     = "";
            string dvdPage         = "";
            string miscPage        = "";

            // discography (albums)
            pattern = @"<td.*class=""tab_off""><a.*?href=""(.*?)"">.*Discography.*</a>";
            if (FindPattern(pattern, strHTML))
            {
                // Get Link to other sub pages
                compilationPage = _match.Groups[1].Value + "/compilations";
                singlesPage     = _match.Groups[1].Value + "/singles-eps";
                dvdPage         = _match.Groups[1].Value + "/dvds-videos";
                miscPage        = _match.Groups[1].Value + "/other";

                try
                {
                    string contentinfo = AllmusicSiteScraper.GetHTTP(_match.Groups[1].Value);
                    pattern = @"sorted.*? cell"">(?<year>.*?)</td>\s*?.*?</td>\s*.*?<a.*?"">(?<album>.*?)" +
                              @"</a>.*?</td>\s*.*?</td>\s*.*?"">(?<label>.*?)</td>";

                    if (FindPattern(pattern, contentinfo))
                    {
                        while (_match.Success)
                        {
                            string year       = _match.Groups["year"].Value;
                            string albumTitle = _match.Groups["album"].Value;
                            string label      = _match.Groups["label"].Value;

                            util.RemoveTags(ref year);
                            util.ConvertHTMLToAnsi(year, out year);
                            util.RemoveTags(ref albumTitle);
                            util.ConvertHTMLToAnsi(albumTitle, out albumTitle);
                            util.RemoveTags(ref label);
                            util.ConvertHTMLToAnsi(label, out label);

                            try
                            {
                                string[] dAlbumInfo = { year.Trim(), albumTitle.Trim(), label.Trim() };
                                _discographyAlbum.Add(dAlbumInfo);
                            }
                            catch {}

                            _match = _match.NextMatch();
                        }
                    }
                }
                catch (Exception) {}
            }

            // Compilations
            if (compilationPage != "")
            {
                try
                {
                    string contentinfo = AllmusicSiteScraper.GetHTTP(compilationPage);
                    pattern = @"sorted.*? cell"">(?<year>.*?)</td>\s*?.*?</td>\s*.*?<a.*?"">(?<album>.*?)" +
                              @"</a>.*?</td>\s*.*?</td>\s*.*?"">(?<label>.*?)</td>";

                    if (FindPattern(pattern, contentinfo))
                    {
                        while (_match.Success)
                        {
                            string year       = _match.Groups["year"].Value;
                            string albumTitle = _match.Groups["album"].Value;
                            string label      = _match.Groups["label"].Value;

                            util.RemoveTags(ref year);
                            util.ConvertHTMLToAnsi(year, out year);
                            util.RemoveTags(ref albumTitle);
                            util.ConvertHTMLToAnsi(albumTitle, out albumTitle);
                            util.RemoveTags(ref label);
                            util.ConvertHTMLToAnsi(label, out label);

                            try
                            {
                                string[] dAlbumInfo = { year.Trim(), albumTitle.Trim(), label.Trim() };
                                _discographyCompilations.Add(dAlbumInfo);
                            }
                            catch {}

                            _match = _match.NextMatch();
                        }
                    }
                }
                catch (Exception) {}
            }

            // Singles
            if (singlesPage != "")
            {
                try
                {
                    string contentinfo = AllmusicSiteScraper.GetHTTP(singlesPage);
                    pattern = @"sorted.*? cell"">(?<year>.*?)</td>\s*?.*?</td>\s*.*?<a.*?"">(?<album>.*?)" +
                              @"</a>.*?</td>\s*.*?</td>\s*.*?"">(?<label>.*?)</td>";

                    if (FindPattern(pattern, contentinfo))
                    {
                        while (_match.Success)
                        {
                            string year       = _match.Groups["year"].Value;
                            string albumTitle = _match.Groups["album"].Value;
                            string label      = _match.Groups["label"].Value;

                            util.RemoveTags(ref year);
                            util.ConvertHTMLToAnsi(year, out year);
                            util.RemoveTags(ref albumTitle);
                            util.ConvertHTMLToAnsi(albumTitle, out albumTitle);
                            util.RemoveTags(ref label);
                            util.ConvertHTMLToAnsi(label, out label);

                            try
                            {
                                string[] dAlbumInfo = { year.Trim(), albumTitle.Trim(), label.Trim() };
                                _discographySingles.Add(dAlbumInfo);
                            }
                            catch {}

                            _match = _match.NextMatch();
                        }
                    }
                }
                catch (Exception) {}
            }

            // DVD Videos
            if (dvdPage != "")
            {
                try
                {
                    string contentinfo = AllmusicSiteScraper.GetHTTP(dvdPage);
                    pattern = @"sorted.*? cell"">(?<year>.*?)</td>\s*?.*?</td>\s*.*?<a.*?"">(?<album>.*?)" +
                              @"</a>.*?</td>\s*.*?</td>\s*.*?"">(?<label>.*?)</td>";

                    if (FindPattern(pattern, contentinfo))
                    {
                        while (_match.Success)
                        {
                            string year       = _match.Groups["year"].Value;
                            string albumTitle = _match.Groups["album"].Value;
                            string label      = _match.Groups["label"].Value;

                            util.RemoveTags(ref year);
                            util.ConvertHTMLToAnsi(year, out year);
                            util.RemoveTags(ref albumTitle);
                            util.ConvertHTMLToAnsi(albumTitle, out albumTitle);
                            util.RemoveTags(ref label);
                            util.ConvertHTMLToAnsi(label, out label);

                            try
                            {
                                string[] dAlbumInfo = { year.Trim(), albumTitle.Trim(), label.Trim() };
                                _discographyMisc.Add(dAlbumInfo);
                            }
                            catch {}

                            _match = _match.NextMatch();
                        }
                    }
                }
                catch (Exception) {}
            }

            // Other
            if (miscPage != "")
            {
                try
                {
                    string contentinfo = AllmusicSiteScraper.GetHTTP(miscPage);
                    pattern = @"sorted.*? cell"">(?<year>.*?)</td>\s*?.*?</td>\s*.*?<a.*?"">(?<album>.*?)" +
                              @"</a>.*?</td>\s*.*?</td>\s*.*?"">(?<label>.*?)</td>";

                    if (FindPattern(pattern, contentinfo))
                    {
                        while (_match.Success)
                        {
                            string year       = _match.Groups["year"].Value;
                            string albumTitle = _match.Groups["album"].Value;
                            string label      = _match.Groups["label"].Value;

                            util.RemoveTags(ref year);
                            util.ConvertHTMLToAnsi(year, out year);
                            util.RemoveTags(ref albumTitle);
                            util.ConvertHTMLToAnsi(albumTitle, out albumTitle);
                            util.RemoveTags(ref label);
                            util.ConvertHTMLToAnsi(label, out label);

                            try
                            {
                                string[] dAlbumInfo = { year.Trim(), albumTitle.Trim(), label.Trim() };
                                _discographyMisc.Add(dAlbumInfo);
                            }
                            catch {}

                            _match = _match.NextMatch();
                        }
                    }
                }
                catch (Exception) {}
            }

            _bLoaded = true;
            return(_bLoaded);
        }
        public bool FindAlbuminfo(string strAlbum, string artistName, int releaseYear)
        {
            _albumList.Clear();

//     strAlbum="1999";//escapolygy";

            // make request
            // type is
            // http://www.allmusic.com/cg/amg.dll?P=amg&SQL=escapolygy&OPT1=2

            HTMLUtil util     = new HTMLUtil();
            string   postData = String.Format("P=amg&SQL={0}&OPT1=2", HttpUtility.UrlEncode(strAlbum));

            string html = PostHTTP("http://www.allmusic.com/cg/amg.dll", postData);

            if (html.Length == 0)
            {
                return(false);
            }

            // check if this is an album
            MusicAlbumInfo newAlbum = new MusicAlbumInfo();

            newAlbum.AlbumURL = "http://www.allmusic.com/cg/amg.dll?" + postData;
            if (newAlbum.Parse(html))
            {
                _albumList.Add(newAlbum);
                return(true);
            }

            string htmlLow = html;

            htmlLow = htmlLow.ToLower();
            int startOfTable = htmlLow.IndexOf("id=\"expansiontable1\"");

            if (startOfTable < 0)
            {
                return(false);
            }
            startOfTable = htmlLow.LastIndexOf("<table", startOfTable);
            if (startOfTable < 0)
            {
                return(false);
            }

            HTMLTable table    = new HTMLTable();
            string    strTable = html.Substring(startOfTable);

            table.Parse(strTable);

            for (int i = 1; i < table.Rows; ++i)
            {
                HTMLTable.HTMLRow row          = table.GetRow(i);
                string            albumName    = "";
                string            albumUrl     = "";
                string            nameOfAlbum  = "";
                string            nameOfArtist = "";
                for (int iCol = 0; iCol < row.Columns; ++iCol)
                {
                    string column = row.GetColumValue(iCol);
                    if (iCol == 1 && (column.Length != 0))
                    {
                        albumName = "(" + column + ")";
                    }
                    if (iCol == 2)
                    {
                        nameOfArtist = column;
                        util.RemoveTags(ref nameOfArtist);
                        if (!column.Equals("&nbsp;"))
                        {
                            albumName = String.Format("- {0} {1}", nameOfArtist, albumName);
                        }
                    }
                    if (iCol == 4)
                    {
                        string tempAlbum = column;
                        util.RemoveTags(ref tempAlbum);
                        albumName   = String.Format("{0} {1}", tempAlbum, albumName);
                        nameOfAlbum = tempAlbum;
                    }
                    if (iCol == 4 && column.IndexOf("<a href=\"") >= 0)
                    {
                        int pos1 = column.IndexOf("<a href=\"");
                        pos1 += +"<a href=\"".Length;
                        int iPos2 = column.IndexOf("\">", pos1);
                        if (iPos2 >= 0)
                        {
                            if (nameOfAlbum.Length == 0)
                            {
                                nameOfAlbum = albumName;
                            }

                            // full album url:
                            // http://www.allmusic.com/cg/amg.dll?p=amg&token=&sql=10:66jieal64xs7
                            string url = column.Substring(pos1, iPos2 - pos1);
                            string albumNameStripped;
                            albumUrl = String.Format("http://www.allmusic.com{0}", url);
                            MusicAlbumInfo newAlbumInfo = new MusicAlbumInfo();
                            util.ConvertHTMLToAnsi(albumName, out albumNameStripped);
                            newAlbumInfo.Title2   = albumNameStripped;
                            newAlbumInfo.AlbumURL = util.ConvertHTMLToAnsi(albumUrl);
                            newAlbumInfo.Artist   = util.ConvertHTMLToAnsi(nameOfArtist);
                            newAlbumInfo.Title    = util.ConvertHTMLToAnsi(nameOfAlbum);
                            _albumList.Add(newAlbumInfo);
                        }
                    }
                }
            }

            // now sort
            _albumList.Sort(new AlbumSort(strAlbum, artistName, releaseYear));
            return(true);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Search on Allmusic for the requested string
        /// </summary>
        /// <param name="searchBy"></param>
        /// <param name="searchStr"></param>
        /// <returns></returns>
        public bool FindInfo(SearchBy searchBy, string searchStr)
        {
            _searchby = searchBy;
            HTMLUtil util        = new HTMLUtil();
            string   strPostData = "";

            if (SearchBy.Albums == searchBy)
            {
                strPostData = string.Format(ALBUMSEARCH, HttpUtility.UrlEncode(searchStr));
            }
            else
            {
                searchStr   = SwitchArtist(searchStr);
                strPostData = string.Format(ARTISTSEARCH, HttpUtility.UrlEncode(searchStr));
            }

            string strHTML = PostHTTP(MAINURL + URLPROGRAM, strPostData);

            if (strHTML.Length == 0)
            {
                return(false);
            }

            _htmlCode = strHTML; // save the html content...

            Regex multiples = new Regex(
                @"\sSearch\sResults\sfor:",
                RegexOptions.IgnoreCase
                | RegexOptions.Multiline
                | RegexOptions.IgnorePatternWhitespace
                | RegexOptions.Compiled
                );

            if (multiples.IsMatch(strHTML))
            {
                string pattern = "";
                if (searchBy.ToString().Equals("Artists"))
                {
                    pattern = @"<tr.*?>\s*?.*?<td\s*?class=""relevance\stext-center"">\s*?.*\s*?.*</td>" +
                              @"\s*?.*<td.*\s*?.*</td>\s*?.*<td>.*<a.*href=""(?<code>.*?)"">(?<name>.*)</a>.*</td>" +
                              @"\s*?.*<td>(?<detail>.*)</td>\s*?.*<td>(?<detail2>.*)</td>";
                }
                else if (searchBy.ToString().Equals("Albums"))
                {
                    pattern = @"<tr.*?>\s*?.*?<td\s*?class=""relevance\stext-center"">\s*?.*\s*?.*</td>" +
                              @"\s*?.*<td.*\s*?.*</td>\s*?.*<td>.*<a.*href=""(?<code>.*?)"">(?<name>.*)</a>.*</td>" +
                              @"\s*?.*<td>(?<detail>.*)</td>\s*?.*<td>.*</td>\s*?.*<td>(?<detail2>.*)</td>";
                }


                Match m;
                Regex itemsFoundFromSite = new Regex(
                    pattern,
                    RegexOptions.IgnoreCase
                    | RegexOptions.Multiline
                    | RegexOptions.IgnorePatternWhitespace
                    | RegexOptions.Compiled
                    );


                for (m = itemsFoundFromSite.Match(strHTML); m.Success; m = m.NextMatch())
                {
                    string code    = m.Groups["code"].ToString();
                    string name    = m.Groups["name"].ToString();
                    string detail  = m.Groups["detail"].ToString();
                    string detail2 = m.Groups["detail2"].ToString();

                    util.RemoveTags(ref name);
                    util.ConvertHTMLToAnsi(name, out name);

                    util.RemoveTags(ref detail);
                    util.ConvertHTMLToAnsi(detail, out detail);

                    util.RemoveTags(ref detail2);
                    util.ConvertHTMLToAnsi(detail2, out detail2);

                    if (SearchBy.Artists == searchBy)
                    {
                        detail += " - " + detail2;
                        if (detail.Length > 0)
                        {
                            _codes.Add(code);
                            _values.Add(name + " - " + detail);
                        }
                        else
                        {
                            _codes.Add(code);
                            _values.Add(name);
                        }
                    }
                    else
                    {
                        MusicAlbumInfo albumInfo = new MusicAlbumInfo();
                        albumInfo.AlbumURL      = code;
                        albumInfo.Artist        = detail;
                        albumInfo.Title         = name;
                        albumInfo.DateOfRelease = detail2;
                        _albumList.Add(albumInfo);
                    }
                }
                _multiple = true;
            }
            else // found the right one
            {
            }
            return(true);
        }