def album_info(): if request.method != 'GET': return None MBD = MusicBrainzDatabase albumID = request.args.get('id', type=int) album_info = MBD.get_album_info(albumID) releaseID = album_info['release_id'] rgID = album_info['release_group_id'] release_group_info = MBD.get_release_group_info(rgID) secondary_types = MBD.get_release_group_secondary_types(rgID) release_events = MBD.get_release_events(releaseID) result = dict(album_info) result['covers_count'] = MusicDatabase.getAlbumCoversCount(albumID) if result['language']: result['language'] = LanguageEnum.name(result['language']) if result['release_status']: result['release_status'] = ReleaseStatusEnum.name( result['release_status']) result['release_group'] = dict(release_group_info) rg_type = result['release_group']['release_group_type'] if rg_type: rg_type = ReleaseGroupTypeEnum.name(rg_type) result['release_group']['release_group_type'] = rg_type result['release_group_secondary_types'] = secondary_types result['release_events'] = [dict(x) for x in release_events] ratings = MusicDatabase.get_albums_ratings([albumID], current_user.userID) result['rating'] = ratings[albumID] return jsonify(result)
def release_group_releases(): if request.method != 'GET': return None rgID = request.args.get('id', type=int) print('id', rgID) use_bard_tags = config.config['use_bard_tags'] MBD = MusicBrainzDatabase releases = MBD.get_release_group_releases(rgID) release_group_info = MBD.get_release_group_info(rgID) secondary_types = MBD.get_release_group_secondary_types(rgID) result = [] for release in releases: mediums = MBD.get_release_mediums(release['id']) rel = dict(release) album_id = rel['album_id'] rel['mediums_desc'] = MBD.mediumlist_to_string(mediums) rel['audio_properties'] = [ album_properties_to_string(x) for x in MusicDatabase.getAlbumProperties(release['album_id']) ] rel['album_disambiguation'] = (MBD.getAlbumDisambiguation( release, use_uselabel=use_bard_tags)) rel['tracks_count'] = MBD.get_release_tracks_count(release['id']) release_events = MBD.get_release_events(rel['id']) if rel['language']: rel['language'] = LanguageEnum.name(rel['language']) if rel['release_status']: rel['release_status'] = ReleaseStatusEnum.name( rel['release_status']) rel['release_group'] = dict(release_group_info) rg_type = rel['release_group']['release_group_type'] if rg_type: rg_type = ReleaseGroupTypeEnum.name(rg_type) rel['release_group']['release_group_type'] = rg_type rel['release_group_secondary_types'] = secondary_types rel['release_events'] = [dict(x) for x in release_events] ratings = MusicDatabase.get_albums_ratings([album_id], current_user.userID) rel['rating'] = ratings[album_id] result.append(rel) return jsonify(result)