示例#1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="query"></param>
        /// <param name="offset"></param>
        /// <param name="limit"></param>
        /// <returns></returns>
        public List <MBArtist> GetArtists(String query, int offset, int limit)
        {
            List <MBArtist> artistList = new List <MBArtist>();
            String          endpoint   = String.Format("http://musicbrainz.org/ws/1/artist/?type=xml&name={0}&offset={1}&limit={2}", query, offset, limit);

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

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

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

            if (mData.artistlist == null || mData.artistlist.artist == null || mData.artistlist.artist.Length == 0)
            {
                return(null);
            }

            foreach (ArtistNS.metadataArtistlistArtist xsdArtist in mData.artistlist.artist)
            {
                MBArtist mbAartist = new MBArtist()
                {
                    Name = xsdArtist.name,
                    MBID = xsdArtist.id,
                    //StartDate = xsdArtist.lifespan.begin,
                    TType = xsdArtist.type
                };
                artistList.Add(mbAartist);
            }

            return(artistList);
        }
示例#2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="query"></param>
        /// <param name="mbAartist"></param>
        /// <returns></returns>
        public Boolean IsArtist(String query, out MBArtist mbAartist)
        {
            mbAartist = null;
            String endpoint = String.Format("http://musicbrainz.org/ws/1/artist/?type=xml&name={0}&offset=0&limit=2", query);
            Object obj      = this.ProcessSearchQuery(endpoint, typeof(ArtistNS.metadata));

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

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

            if (mData.artistlist == null || mData.artistlist.artist == null || mData.artistlist.artist.Length == 0)
            {
                return(false);
            }

            if (!query.Equals(mData.artistlist.artist[0].name, StringComparison.InvariantCultureIgnoreCase))
            {
                return(false);
            }

            mbAartist = new MBArtist()
            {
                Name      = mData.artistlist.artist[0].name,
                MBID      = mData.artistlist.artist[0].id,
                StartDate = mData.artistlist.artist[0].lifespan != null ? mData.artistlist.artist[0].lifespan.begin : default(DateTime),
                TType     = mData.artistlist.artist[0].type
            };
            return(true);
        }
示例#3
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="query"></param>
        /// <param name="mbAartist"></param>
        /// <returns></returns>
        public Boolean IsArtist(String query, out MBArtist mbAartist)
        {
            mbAartist = null;
            String endpoint = String.Format("http://musicbrainz.org/ws/1/artist/?type=xml&name={0}&offset=0&limit=2", query);
            Object obj = this.ProcessSearchQuery(endpoint, typeof(ArtistNS.metadata));
            if (obj == null)
                return false;

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

            if (mData.artistlist == null || mData.artistlist.artist == null || mData.artistlist.artist.Length == 0)
                return false;

            if (!query.Equals(mData.artistlist.artist[0].name, StringComparison.InvariantCultureIgnoreCase))
                return false;

            mbAartist = new MBArtist()
            {
                Name = mData.artistlist.artist[0].name,
                MBID = mData.artistlist.artist[0].id,
                StartDate = mData.artistlist.artist[0].lifespan != null ? mData.artistlist.artist[0].lifespan.begin : default(DateTime),
                TType = mData.artistlist.artist[0].type
            };
            return true;
        }
示例#4
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="query"></param>
        /// <param name="offset"></param>
        /// <param name="limit"></param>
        /// <returns></returns>
        public List<MBArtist> GetArtists(String query, int offset, int limit)
        {
            List<MBArtist> artistList = new List<MBArtist>();
            String endpoint = String.Format("http://musicbrainz.org/ws/1/artist/?type=xml&name={0}&offset={1}&limit={2}", query, offset, limit);

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

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

            if (mData.artistlist == null || mData.artistlist.artist == null || mData.artistlist.artist.Length == 0)
                return null;

            foreach (ArtistNS.metadataArtistlistArtist xsdArtist in mData.artistlist.artist)
            {
                MBArtist mbAartist = new MBArtist()
                {
                    Name = xsdArtist.name,
                    MBID = xsdArtist.id,
                    //StartDate = xsdArtist.lifespan.begin,
                    TType = xsdArtist.type
                };
                artistList.Add(mbAartist);
            }

            return artistList;
        }