Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
sumanthmalipeddi opened this issue Jun 7, 2024 · 0 comments

Comments

@sumanthmalipeddi
Copy link

@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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant