コード例 #1
0
        /// <summary>
        /// get the artist details and update missing data from this source
        /// </summary>
        /// <param name="mv"></param>
        /// <returns></returns>
        public DBTrackInfo GetAlbumDetail(DBTrackInfo mv)
        {
            string strAlbumHTML;
            string album  = mv.AlbumInfo[0].Album;
            string artist = mv.ArtistInfo[0].Artist;

            if (GetAlbumHTML(artist, album, out strAlbumHTML))
            {
                //var albumInfo = new MusicAlbumInfo();
                //if (albumInfo.Parse(strAlbumHTML))
                var albumInfo = AMGHTMLParser.ParseAlbumHTML(strAlbumHTML, album, artist);
                if (albumInfo != null)
                {
                    albumInfo.Artist = album;
                    DBAlbumInfo mv1 = (DBAlbumInfo)mv.AlbumInfo[0];
                    SetMusicVideoAlbum(ref mv1, albumInfo);
                    getTrackComposers(mv, strAlbumHTML, string.Empty);
                }
            }
            return(mv);
        }
コード例 #2
0
        /// <summary>
        /// Get the details of the track
        /// </summary>
        /// <param name="trackObject"></param>
        private void GetTrackDetails(DBTrackInfo trackObject)
        {
            string    strArtistHTML;
            string    strAlbumHTML;
            string    strArtistURL;
            bool      songFound = false;
            const int trackName = 1;
            const int trackURL  = 3;

            List <DBTrackInfo> results = new List <DBTrackInfo>();

            string strAlbumArtist = trackObject.ArtistInfo[0].Artist;

            if (GetArtistHTML(strAlbumArtist, out strArtistHTML, out strArtistURL))
            {
                var artistInfo = new MusicArtistInfo();
                if (artistInfo.Parse(strArtistHTML))
                {
                    artistInfo.Artist = strAlbumArtist;
                    if (GetAlbumURLList(strArtistURL))
                    {
                        // we have some albums - now check the tracks in each album
                        foreach (string albumURL in _albumUrlList)
                        {
                            // If we found the song then exit...
                            if (songFound)
                            {
                                break;
                            }

                            if (GetPageHTMLOnly(albumURL, out strAlbumHTML))
                            {
                                string strAlbum = Regex.Match(albumURL, "[^/]+-", RegexOptions.Singleline | RegexOptions.IgnoreCase).Value;
                                strAlbum = Regex.Replace(strAlbum, "[-?*]", " ", RegexOptions.Singleline | RegexOptions.IgnoreCase);

                                var albumInfo = AMGHTMLParser.ParseAlbumHTML(strAlbumHTML, strAlbum.Trim(), strAlbumArtist);

                                if (albumInfo != null)
                                {
                                    string[] tracksOnAlbum = albumInfo.Tracks.Split('|');
                                    foreach (string track in tracksOnAlbum)
                                    {
                                        if (!string.IsNullOrEmpty(track.Trim()))
                                        {
                                            string[] trackData = track.Split('@');

                                            if (string.Equals(trackObject.Track, trackData[trackName], StringComparison.CurrentCultureIgnoreCase))
                                            {
                                                Logger.Debug("Get Composers for Track {0} by {1}", trackObject.Track, strAlbumArtist);
                                                songFound = getTrackComposers(trackObject, strAlbumHTML, trackData[trackURL]);
                                                Logger.Debug("Composers for Track {0} by {1} are {2}", trackObject.Track, strAlbumArtist, trackObject.Composers);
                                                break;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// Get the Artist, Album Details
        /// </summary>
        /// <param name="mv"></param>
        /// <returns></returns>
        public bool GetDetails(DBBasicInfo mv)
        {
            string strArtistHTML;
            string strAlbumHTML;
            string strArtistURL;

            ReportProgress(string.Empty);

            // Get details of the artist
            if (mv.GetType() == typeof(DBArtistInfo))
            {
                string artist = ((DBArtistInfo)mv).Artist;
                ReportProgress("Getting Artist...");
                if (GetArtistHTML(artist, out strArtistHTML, out strArtistURL))
                {
                    var artistInfo = AMGHTMLParser.ParseArtistHTML(strArtistHTML, artist);

                    if (artistInfo != null)
                    {
                        artistInfo.Artist = artist;
                        DBArtistInfo mv1 = (DBArtistInfo)mv;
                        SetMusicVideoArtist(ref mv1, artistInfo, strArtistHTML);
                        GetArtistArt((DBArtistInfo)mv);
                        ReportProgress("Done...");
                        return(true);
                    }
                }
                return(false);
            }
            // get details of the album
            if (mv.GetType() == typeof(DBAlbumInfo))
            {
                string             album     = ((DBAlbumInfo)mv).Album;
                List <DBTrackInfo> trackList = DBTrackInfo.GetEntriesByAlbum((DBAlbumInfo)mv);
                DBArtistInfo       artist    = DBArtistInfo.Get(trackList[0]);

                if (GetAlbumHTML(artist.Artist, album, out strAlbumHTML))
                {
                    var albumInfo = AMGHTMLParser.ParseAlbumHTML(strAlbumHTML, album, artist.Artist);
                    if (albumInfo != null)
                    {
                        albumInfo.Artist = album;
                        DBAlbumInfo mv1 = (DBAlbumInfo)mv;
                        SetMusicVideoAlbum(ref mv1, albumInfo);
                    }
                }
                return(false);
            }

            // get details of the track
            if (mv.GetType() == typeof(DBTrackInfo))
            {
                if (((DBTrackInfo)mv).LocalMedia[0].IsDVD)
                {
                    string track = ((DBTrackInfo)mv).Track;
                    GetDVDDetails((DBTrackInfo)mv);
                    return(true);
                }
                else
                {
                    string track = ((DBTrackInfo)mv).Track;
                    GetTrackDetails((DBTrackInfo)mv);
                    return(true);
                }
            }

            return(true);
        }