def map_album(item): return { 'title': item['AlbumTitle'], 'year': dateutil.parser.parse(item['ReleaseDate']).strftime('%Y'), 'id': ids.to_id(item['AA_PK']), 'image_url': item.get('ImageURL') }
def map_album(items): album = items[0] license = album.get('License', 'by-nc-nd') return { 'id': album['AA_PK'], 'title': album['AlbumTitle'], 'artist_name': album['ArtistName'], 'year': dateutil.parser.parse(album['ReleaseDate']).strftime('%Y'), 'artist_id': ids.to_id(album['PK']), 'image_url': album.get('ImageURL'), 'description': album.get('Description'), 'license': license, 'license_name': licenses.names[license], 'tracks': list(map(map_track, items[slice(1, len(items)+1)])) }
def map_track(item): track = { 'title': item['TrackTitle'], 'id': ids.to_id(item['PK']), 'audio_url': item["AudioURL"] } if is_single(item): release_date = item['ReleaseDate'] track['year'] = dateutil.parser.parse(release_date).strftime('%Y') if not is_single(item): track['album_title'] = item['AlbumTitle'] track['album_id'] = item['AA_PK'] license = item.get('License') if license: track["license"] = license track["license_name"] = licenses.names[license] track['feature_sort'] = item.get('FeatureSort') return track
def map_list_item(item): return { 'name': item['AA_SK'], 'id': ids.to_id(item['PK']), 'image_url': item.get('ImageURL') }
def map_track(item): return { 'id': ids.to_id(item['PK']), 'title': item['TrackTitle'], 'audio_url': item['AudioURL'] }