Exemple #1
0
def getExtras(artistid):

	types = [m.Release.TYPE_EP, m.Release.TYPE_SINGLE, m.Release.TYPE_LIVE, m.Release.TYPE_REMIX,
			m.Release.TYPE_COMPILATION]
			
	for type in types:
	
		inc = ws.ArtistIncludes(releases=(m.Release.TYPE_OFFICIAL, type), releaseGroups=True)
		artist = q.getArtistById(artistid, inc)
		
		for rg in artist.getReleaseGroups():
		
			rgid = u.extractUuid(rg.id)
			releaseid = getReleaseGroup(rgid)
			
			inc = ws.ReleaseIncludes(artist=True, releaseEvents= True, tracks= True, releaseGroup=True)
			results = ws.Query().getReleaseById(releaseid, inc)
			
			print results.title
			print u.getReleaseTypeName(results.releaseGroup.type)
Exemple #2
0
def getArtist(artistid):

	with mb_lock:
	
		artist_dict = {}
	
		#Get all official release groups
		inc = ws.ArtistIncludes(releases=(m.Release.TYPE_OFFICIAL, m.Release.TYPE_ALBUM), releaseGroups=True)
		
		attempt = 0
		
		while attempt < 5:
		
			try:
				artist = q.getArtistById(artistid, inc)
				break
			except WebServiceError, e:
				logger.warn('Attempt to retrieve information from MusicBrainz failed: %s' % e)
				attempt += 1
				time.sleep(1)
				
		time.sleep(1)
				
		artist_dict['artist_name'] = artist.name
		artist_dict['artist_sortname'] = artist.sortName
		artist_dict['artist_uniquename'] = artist.getUniqueName()
		artist_dict['artist_type'] = u.extractFragment(artist.type)
		artist_dict['artist_begindate'] = artist.beginDate
		artist_dict['artist_endDate'] = artist.endDate
		
		releasegroups = []
		
		for rg in artist.getReleaseGroups():
			
			releasegroups.append({
						'title':		rg.title,
						'id':			u.extractUuid(rg.id),
						'url':			rg.id,
						'type':			u.getReleaseTypeName(rg.type)
				})
				
		artist_dict['releasegroups'] = releasegroups
		
		return artist_dict
Exemple #3
0
def getArtist(artistid, extrasonly=False):

	with mb_lock:
	
		artist_dict = {}
	
		#Get all official release groups
		inc = ws.ArtistIncludes(releases=(m.Release.TYPE_OFFICIAL, m.Release.TYPE_ALBUM), releaseGroups=True)
		artist = None
		attempt = 0
		
		while attempt < 5:
		
			try:
				artist = q.getArtistById(artistid, inc)
				break
			except WebServiceError, e:
				logger.warn('Attempt to retrieve artist information from MusicBrainz failed for artistid: %s. Sleeping 5 seconds' % artistid)
				attempt += 1
				time.sleep(5)
				
		if not artist:
			return False
		
		time.sleep(1)
				
		artist_dict['artist_name'] = artist.name
		artist_dict['artist_sortname'] = artist.sortName
		artist_dict['artist_uniquename'] = artist.getUniqueName()
		artist_dict['artist_type'] = u.extractFragment(artist.type)
		artist_dict['artist_begindate'] = artist.beginDate
		artist_dict['artist_enddate'] = artist.endDate
		
		releasegroups = []
		
		if not extrasonly:
		
			for rg in artist.getReleaseGroups():
				
				releasegroups.append({
							'title':		rg.title,
							'id':			u.extractUuid(rg.id),
							'url':			rg.id,
							'type':			u.getReleaseTypeName(rg.type)
					})
				
		# See if we need to grab extras
		myDB = db.DBConnection()

		try:
			includeExtras = myDB.select('SELECT IncludeExtras from artists WHERE ArtistID=?', [artistid])[0][0]
		except IndexError:
			includeExtras = False
		
		if includeExtras or headphones.INCLUDE_EXTRAS:
			includes = [m.Release.TYPE_COMPILATION, m.Release.TYPE_REMIX, m.Release.TYPE_SINGLE, m.Release.TYPE_LIVE, m.Release.TYPE_EP]
			for include in includes:
				inc = ws.ArtistIncludes(releases=(m.Release.TYPE_OFFICIAL, include), releaseGroups=True)
		
				artist = None
				attempt = 0
			
				while attempt < 5:
		
					try:
						artist = q.getArtistById(artistid, inc)
						break
					except WebServiceError, e:
						logger.warn('Attempt to retrieve artist information from MusicBrainz failed for artistid: %s. Sleeping 5 seconds' % artistid)
						attempt += 1
						time.sleep(5)
						
				if not artist:
					continue
					
				for rg in artist.getReleaseGroups():
			
					releasegroups.append({
							'title':		rg.title,
							'id':			u.extractUuid(rg.id),
							'url':			rg.id,
							'type':			u.getReleaseTypeName(rg.type)
						})
Exemple #4
0
def getArtist(artistid, extrasonly=False):

    with mb_lock:

        artist_dict = {}

        #Get all official release groups
        inc = ws.ArtistIncludes(releases=(m.Release.TYPE_OFFICIAL,
                                          m.Release.TYPE_ALBUM),
                                releaseGroups=True)
        artist = None
        attempt = 0

        while attempt < 5:

            try:
                artist = q.getArtistById(artistid, inc)
                break
            except WebServiceError, e:
                logger.warn(
                    'Attempt to retrieve artist information from MusicBrainz failed for artistid: %s. Sleeping 5 seconds'
                    % artistid)
                attempt += 1
                time.sleep(5)

        if not artist:
            return False

        time.sleep(1)

        artist_dict['artist_name'] = artist.name
        artist_dict['artist_sortname'] = artist.sortName
        artist_dict['artist_uniquename'] = artist.getUniqueName()
        artist_dict['artist_type'] = u.extractFragment(artist.type)
        artist_dict['artist_begindate'] = artist.beginDate
        artist_dict['artist_enddate'] = artist.endDate

        releasegroups = []

        if not extrasonly:

            for rg in artist.getReleaseGroups():

                releasegroups.append({
                    'title': rg.title,
                    'id': u.extractUuid(rg.id),
                    'url': rg.id,
                    'type': u.getReleaseTypeName(rg.type)
                })

        # See if we need to grab extras
        myDB = db.DBConnection()

        try:
            includeExtras = myDB.select(
                'SELECT IncludeExtras from artists WHERE ArtistID=?',
                [artistid])[0][0]
        except IndexError:
            includeExtras = False

        if includeExtras or headphones.INCLUDE_EXTRAS:
            includes = [
                m.Release.TYPE_COMPILATION, m.Release.TYPE_REMIX,
                m.Release.TYPE_SINGLE, m.Release.TYPE_LIVE, m.Release.TYPE_EP,
                m.Release.TYPE_SOUNDTRACK
            ]
            for include in includes:
                inc = ws.ArtistIncludes(releases=(m.Release.TYPE_OFFICIAL,
                                                  include),
                                        releaseGroups=True)

                artist = None
                attempt = 0

                while attempt < 5:

                    try:
                        artist = q.getArtistById(artistid, inc)
                        break
                    except WebServiceError, e:
                        logger.warn(
                            'Attempt to retrieve artist information from MusicBrainz failed for artistid: %s. Sleeping 5 seconds'
                            % artistid)
                        attempt += 1
                        time.sleep(5)

                if not artist:
                    continue

                for rg in artist.getReleaseGroups():

                    releasegroups.append({
                        'title': rg.title,
                        'id': u.extractUuid(rg.id),
                        'url': rg.id,
                        'type': u.getReleaseTypeName(rg.type)
                    })