johnwmillr / LyricsGenius

Download song lyrics and metadata from Genius.com 🎶🎤
http://www.johnwmillr.com/scraping-genius-lyrics/
MIT License
898 stars 159 forks source link

How do i get the youtube url #129

Closed e-harsley closed 4 years ago

e-harsley commented 4 years ago

Hi, How do i get the youtube url from the song media

allerter commented 4 years ago

If you save the artist object:

with open('saved_file.json') as f:
    data = json.load(f)
for song in data['songs']:
    links = song['media']
    if links:
        for media in links:
            if media['provider'] == 'youtube':
                print(media['url'])

If you save the song object:

with open('saved_file.json') as f:
    data = json.load(f)
links = data['media']
if links:
    for media in links:
        if media['provider'] == 'youtube':
            print(media['url'])