-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
34 lines (26 loc) · 1005 Bytes
/
main.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
from newsDownloader import news
from termExtraction import terms
from spotifyConnection import SpotifyAPI
findNews = news()
findTerms = terms()
spotify = SpotifyAPI()
#Asks user for spotify username and calls to promptLogin, which gives app permission to create and add to playlists
userName = input('Please enter your username/email used for Spotify: ')
spotify.promptLogin(userName)
#Asks user for a name for the playlist
playlistName = input('Please enter the name of the playlist you would like to create: ')
spotify.createPlaylist(playlistName)
#Gets news from news API
findNews.getNews()
#Loops through news taken from API and uses findTerms to get the frequency of terms
for i in findNews.newsData:
findTerms.tf(i)
try:
#Searches using filtered terms and appends to song list
spotify.search(findTerms.frequencyData[0][0])
except:
findTerms.tfClear()
continue
#Adds songs to playlist
spotify.addToPlaylist()
print('Playlist created successfully')