def getReleaseGroup(rgid): """ Returns a list of releases in a release group """ with mb_lock: releaselist = [] releaseGroup = None try: releaseGroup = musicbrainzngs.get_release_group_by_id( rgid, [ "artists", "releases", "media", "discids", ])['release-group'] except WebServiceError, e: logger.warn( 'Attempt to retrieve information from MusicBrainz for release group "%s" failed (%s)' % (rgid, str(e))) time.sleep(5) if not releaseGroup: return False else: return releaseGroup['release-list']
def getReleaseGroup(rgid): """ Returns a list of releases in a release group """ with mb_lock: releaselist = [] releaseGroup = None try: releaseGroup = musicbrainzngs.get_release_group_by_id(rgid,["artists","releases","media","discids",])['release-group'] except WebServiceError, e: logger.warn('Attempt to retrieve information from MusicBrainz for release group "%s" failed (%s)' % (rgid, str(e))) time.sleep(5) if not releaseGroup: return False else: return releaseGroup['release-list']
def getReleaseGroup(rgid): """ Returns a dictionary of the best stuff from a release group """ with mb_lock: releaselist = [] releaseGroup = None q, sleepytime = startmb() try: releaseGroup = musicbrainzngs.get_release_group_by_id(rgid,["artists","releases","media","discids",])['release-group'] except WebServiceError, e: logger.warn('Attempt to retrieve information from MusicBrainz for release group "%s" failed (%s)' % (rgid, str(e))) time.sleep(5) if not releaseGroup: return False time.sleep(sleepytime) # I think for now we have to make separate queries for each release, in order # to get more detailed release info (ASIN, track count, etc.) for release in releaseGroup['release-list']: releaseResult = None try: releaseResult = musicbrainzngs.get_release_by_id(release['id'],["recordings","media"])['release'] except WebServiceError, e: logger.warn('Attempt to retrieve release information for %s from MusicBrainz failed (%s)' % (releaseResult.title, str(e))) time.sleep(5) if not releaseResult: continue if releaseGroup['type'] == 'live' and releaseResult['status'] != 'Official': logger.debug('%s is not an official live album. Skipping' % releaseResult.name) continue time.sleep(sleepytime) formats = { '2xVinyl': '2', 'Vinyl': '2', 'CD': '0', 'Cassette': '3', '2xCD': '1', 'Digital Media': '0' } countries = { 'US': '0', 'GB': '1', 'JP': '2', } try: format = int(formats[releaseResult['medium-list'][0]['format']]) except: format = 3 try: country = int(countries[releaseResult['country']]) except: country = 3 totalTracks = 0 tracks = [] for medium in releaseResult['medium-list']: for track in medium['track-list']: tracks.append({ 'number': totalTracks + 1, 'title': unicode(track['recording']['title']), 'id': unicode(track['recording']['id']), 'url': u"http://musicbrainz.org/track/" + track['recording']['id'], 'duration': int(track['recording']['length'] if 'length' in track['recording'] else track['length'] if 'length' in track else 0) }) totalTracks += 1 release_dict = { 'hasasin': bool(releaseResult.get('asin')), 'asin': unicode(releaseResult.get('asin')) if 'asin' in releaseResult else None, 'trackscount': totalTracks, 'releaseid': unicode(releaseResult.get('id')), 'releasedate': unicode(releaseResult.get('date')) if 'date' in releaseResult else None, 'format': format, 'country': country } release_dict['tracks'] = tracks releaselist.append(release_dict)
def getReleaseGroup(rgid): """ Returns a dictionary of the best stuff from a release group """ with mb_lock: releaselist = [] releaseGroup = None q, sleepytime = startmb() try: releaseGroup = musicbrainzngs.get_release_group_by_id( rgid, [ "artists", "releases", "media", "discids", ])['release-group'] except WebServiceError, e: logger.warn( 'Attempt to retrieve information from MusicBrainz for release group "%s" failed (%s)' % (rgid, str(e))) time.sleep(5) if not releaseGroup: return False time.sleep(sleepytime) # I think for now we have to make separate queries for each release, in order # to get more detailed release info (ASIN, track count, etc.) for release in releaseGroup['release-list']: releaseResult = None try: releaseResult = musicbrainzngs.get_release_by_id( release['id'], ["recordings", "media"])['release'] except WebServiceError, e: logger.warn( 'Attempt to retrieve release information for %s from MusicBrainz failed (%s)' % (releaseResult.title, str(e))) time.sleep(5) if not releaseResult: continue #skip releases that do not have any release date associated with them #if we don't do this the albums will get the release date "None" and will #automatically be set to wanted if "Automatically Mark Upcoming Albums as Wanted" is set #because None is not a valid date and will never be in the past so it is always upcoming if 'date' not in releaseResult: continue if releaseGroup['type'] == 'live' and releaseResult[ 'status'] != 'Official': logger.debug('%s is not an official live album. Skipping' % releaseResult.name) continue time.sleep(sleepytime) formats = { '2xVinyl': '2', 'Vinyl': '2', 'CD': '0', 'Cassette': '3', '2xCD': '1', 'Digital Media': '0' } countries = { 'US': '0', 'GB': '1', 'JP': '2', } try: format = int( formats[releaseResult['medium-list'][0]['format']]) except: format = 3 try: country = int(countries[releaseResult['country']]) except: country = 3 totalTracks = 0 tracks = [] for medium in releaseResult['medium-list']: for track in medium['track-list']: tracks.append({ 'number': totalTracks + 1, 'title': unicode(track['recording']['title']), 'id': unicode(track['recording']['id']), 'url': u"http://musicbrainz.org/track/" + track['recording']['id'], 'duration': int(track['recording']['length'] if 'length' in track['recording'] else track['length'] if 'length' in track else 0) }) totalTracks += 1 release_dict = { 'hasasin': bool(releaseResult.get('asin')), 'asin': unicode(releaseResult.get('asin')) if 'asin' in releaseResult else None, 'trackscount': totalTracks, 'releaseid': unicode(releaseResult.get('id')), 'releasedate': unicode(releaseResult.get('date')), 'format': format, 'country': country } release_dict['tracks'] = tracks releaselist.append(release_dict)