-
Notifications
You must be signed in to change notification settings - Fork 0
/
music_playlist_creator.py
52 lines (41 loc) · 1.77 KB
/
music_playlist_creator.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
from unittest import result
import requests
import json
import pandas as pd
print("Welcome! You can use this application to create a music playlist")
df = pd.DataFrame()
while True:
try:
song=input("What song would you like to add to your playlist?")
if (song.lower() == "quit"):
print("Thank you for creating your playlist, Enjoy!")
break # User said to quit in any case; exit the loop
response = requests.get("https://itunes.apple.com/search?term="+song+"&limit=1")
jsonResponse=response.json()
for results in jsonResponse['results']:
musician =results['artistName']
title =results['trackName']
recording =results['trackViewUrl']
print("Artist Name is")
print(results['artistName'])
musician =results['artistName']
print("Collection Name is")
print(results['collectionName'])
print("Track Name is")
print(results['trackName'])
title =results['trackName']
print("Genre is")
print(results['primaryGenreName'])
print("Here is the album cover")
print(results['artworkUrl30'])
print("Here is the link to the song")
print(results['trackViewUrl'])
recording =results['trackViewUrl']
playlist ={
"musician": musician,
"title": title,
"recording":recording }
df = df.append({'musician':musician, 'title':title, 'recording':recording},ignore_index=True)
except:
print("Something went wrong, please don't stop the music. Try again.")
print(df)