-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetSongs.py
62 lines (54 loc) · 1.28 KB
/
getSongs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import lyricsgenius
import json
artists = [
{
'name':'Cozz',
'file': 'Cozz'
},
{
'name':'Abbas Hamad',
'file': 'Bas'
},
{
'name': 'AriLennox',
'file': 'AriLennox',
},
{
'name': 'J. cole',
'file': 'J.Cole',
},
{
'name': 'JID',
'file': 'JID',
},
{
'name': 'Lute',
'file': 'Lute',
},
{
'name': 'EarthGang',
'file': 'EARTHGANG',
},
{
'name': 'Omen',
'file': 'Omen',
}
]
lyricsList = []
for selectedArtist in artists:
genius = lyricsgenius.Genius(
"HBLNRdl6oUI2cIduP-Ffs91AWBt0NV1lut7QHN6KE7M0jk_EGJ0SVd6lyl_nRU9A", timeout=500)
artist = genius.search_artist(selectedArtist['name'], max_songs=100,)
artist.save_lyrics()
with open('Lyrics_'+selectedArtist['file']+'.json') as f:
data = json.load(f)
for song in data['songs']:
if song['lyrics'] != None:
lyrics_dict = {
'title': song['title'],
'artist': song['primary_artist']['name'],
'lyrics': song['lyrics'].split("\n")
}
lyricsList.append(lyrics_dict)
with open('api/utils/songs.json', 'w') as json_file:
json.dump(lyricsList, json_file)