Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="query"></param>
        /// <param name="artist"></param>
        /// <param name="album"></param>
        /// <param name="artistmbid"></param>
        /// <param name="albummbid"></param>
        /// <returns></returns>
        public List <MBSong> GetSongs(String query, String artist, String album, String artistmbid, String albumbid, int offset, int limit)
        {
            List <MBSong> songList = new List <MBSong>();
            String        append   = String.Empty;

            if (!String.IsNullOrEmpty(query))
            {
                append += String.Format("&title={0}", query);
            }

            if (!String.IsNullOrEmpty(artist))
            {
                append += String.Format("&artist={0}", artist);
            }

            if (!String.IsNullOrEmpty(artistmbid))
            {
                append += String.Format("&artistid={0}", artistmbid);
            }

            if (!String.IsNullOrEmpty(album))
            {
                append += String.Format("&release={0}", album);
            }

            if (!String.IsNullOrEmpty(artistmbid))
            {
                append += String.Format("&releaseid={0}", albumbid);
            }

            String endpoint = String.Format("http://musicbrainz.org/ws/1/track/?type=xml&releasetypes=Album&offset={0}&limit={1}{2}", offset, limit, append);

            Object obj = this.ProcessSearchQuery(endpoint, typeof(SongNS.metadata));

            if (obj == null)
            {
                return(null);
            }

            SongNS.metadata mData = obj as SongNS.metadata;
            if (mData == null)
            {
                return(null);
            }

            if (mData.tracklist == null || mData.tracklist.track == null || mData.tracklist.track.Length == 0)
            {
                return(null);
            }

            foreach (SongNS.metadataTracklistTrack xsdTrack in mData.tracklist.track)
            {
                MBSong mbSong = new MBSong()
                {
                    Title      = xsdTrack.title,
                    MBID       = xsdTrack.id,
                    ArtistName = xsdTrack.artist.name,
                    ArtistMBID = xsdTrack.artist.id,
                    AlbumName  = xsdTrack.releaselist.release.title,
                    AlbumMBID  = xsdTrack.releaselist.release.id
                };
                songList.Add(mbSong);
            }

            return(songList);
        }
Esempio n. 2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="query"></param>
        /// <param name="artist"></param>
        /// <param name="album"></param>
        /// <param name="artistmbid"></param>
        /// <param name="albummbid"></param>
        /// <returns></returns>
        public List<MBSong> GetSongs(String query, String artist, String album, String artistmbid, String albumbid, int offset, int limit)
        {
            List<MBSong> songList = new List<MBSong>();
            String append = String.Empty;
            if (!String.IsNullOrEmpty(query))
                append += String.Format("&title={0}", query);

            if (!String.IsNullOrEmpty(artist))
                append += String.Format("&artist={0}", artist);

            if (!String.IsNullOrEmpty(artistmbid))
                append += String.Format("&artistid={0}", artistmbid);

            if (!String.IsNullOrEmpty(album))
                append += String.Format("&release={0}", album);

            if (!String.IsNullOrEmpty(artistmbid))
                append += String.Format("&releaseid={0}", albumbid);

            String endpoint = String.Format("http://musicbrainz.org/ws/1/track/?type=xml&releasetypes=Album&offset={0}&limit={1}{2}", offset, limit, append);

            Object obj = this.ProcessSearchQuery(endpoint, typeof(SongNS.metadata));
            if (obj == null)
                return null;

            SongNS.metadata mData = obj as SongNS.metadata;
            if (mData == null)
                return null;

            if (mData.tracklist == null || mData.tracklist.track == null || mData.tracklist.track.Length == 0)
                return null;

            foreach (SongNS.metadataTracklistTrack xsdTrack in mData.tracklist.track)
            {
                MBSong mbSong = new MBSong()
                {
                    Title = xsdTrack.title,
                    MBID = xsdTrack.id,
                    ArtistName = xsdTrack.artist.name,
                    ArtistMBID = xsdTrack.artist.id,
                    AlbumName = xsdTrack.releaselist.release.title,
                    AlbumMBID = xsdTrack.releaselist.release.id
                };
                songList.Add(mbSong);
            }

            return songList;
        }