コード例 #1
0
def get_song(id):
    song_details_base_url = endpoints.song_details_base_url + id
    song_response = requests.get(song_details_base_url).text.encode().decode(
        'unicode-escape')
    song_response = json.loads(song_response)
    song_data = helper.format_song(song_response[id])
    return song_data
コード例 #2
0
ファイル: jiosaavn.py プロジェクト: vinayakext2/nkl-musiq
def get_song(id, lyrics):
    try:
        song_details_base_url = endpoints.song_details_base_url + id
        song_response = requests.get(
            song_details_base_url).text.encode().decode('unicode-escape')
        song_response = json.loads(song_response)
        song_data = helper.format_song(song_response[id], lyrics)
        if song_data:
            return song_data
    except:
        return None
コード例 #3
0
def search_for_song(query,lyrics):
    search_base_url = endpoints.search_base_url+query
    response = requests.get(search_base_url).text.encode().decode('unicode-escape')
    response = json.loads(response)
    song_response = response['songs']['data']
    songs = []
    for song in song_response:
        id = song['id']
        song_details_base_url = endpoints.song_details_base_url+id
        song_response = requests.get(song_details_base_url).text.encode().decode('unicode-escape')
        song_response = json.loads(song_response)
        song_data = helper.format_song(song_response[id],lyrics)
        songs.append(song_data)
    return songs