Skip to content

Spotify ETL Project - External Url Field Mapping Correction (artist_list) #8

Open
@sumanthmalipeddi

Description

@sumanthmalipeddi

@darshilparmar as per our discussion in general chat in discord , here are the comments and code correction snippets.

artist_list = []
for row in data['items']:
    for key, value in row.items():
        if key == "track":
            for artist in value['artists']:
                artist_dict = {'artist_id':artist['id'], 'artist_name':artist['name'], 
                                   '**external_url': artist['href']}**
                artist_list.append(artist_dict)

If we fetch external_url from artist['href'] we will get external_url': 'https://api.spotify.com/v1/artists/5YGY8feqx7naU7z4HrwZM6
. Instead, we may use this corrected snippet of code to navigate to the publicly available artist page directly like 'external_url': 'https://open.spotify.com/artist/0oOet2f43PA68X5RxKobEy'.

artist_list = []
for row in data['items']:
    for key, value in row.items():
        if key == 'track':
            for artist in value['artists']:
                artist_dict = {'artist_id' : artist['id'],'artist_name' : artist['name'], 
                                   **'external_url' : artist['external_urls']['spotify'] }**
                artist_list.append(artist_dict)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions