Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
1 changed file
with
8 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,17 @@ | ||
#Code by: Mazikeen El Bezra, ID: 10832578, documentation used: https://developer.musixmatch.com/documentation, https://requests.readthedocs.io/en/master/, adapted from: https://www.youtube.com/watch?v=WFRzKmpepj4&t=1108s | ||
''' function to return 30% of the lyrics of a requested song''' | ||
def my_func(): | ||
import requests | ||
import requests #import request package which is used to import HTTP requests | ||
import json | ||
|
||
key= "&apikey=352a18cc5baa9cd34bd6fc0aa20c3401" | ||
key= "&apikey=352a18cc5baa9cd34bd6fc0aa20c3401" #API key used to access the music API | ||
url="https://api.musixmatch.com/ws/1.1/" | ||
parameters="&q_artist="+"&f_artist_id="+"&page="+"&page_size=" | ||
|
||
print("Welcome to the lyrics search!\n") | ||
artist= input("What's the name of the song?-->") | ||
song= input("Who's the artist?-->") | ||
#calls api method needed with user's inputs | ||
api= url + "matcher.lyrics.get" + "?format=json&callback=callback" + "&q_artist=" + artist + "&q_track=" + song + key | ||
request = requests.get(api) | ||
data = request.json() | ||
print(data['message']['body']['lyrics']['lyrics_body']) | ||
|
||
request = requests.get(api) #sends a GET request to the specified url to get data from server | ||
data = request.json() #parse it as a JSON object | ||
print(data['message']['body']['lyrics']['lyrics_body']) #access object lyrics and return the required object value |