25 lines
687 B
Python
25 lines
687 B
Python
from conf.settings import AZURACAST_URL, AZURACAST_API_KEY
|
|
import requests
|
|
|
|
|
|
def authorize_url(url):
|
|
file_url = url
|
|
API_KEY = AZURACAST_API_KEY
|
|
headers = {
|
|
"Authorization": f"Bearer {API_KEY}"
|
|
}
|
|
return requests.get(file_url, headers=headers)
|
|
|
|
class AzuraCast:
|
|
api_key = AZURACAST_API_KEY
|
|
url = AZURACAST_URL
|
|
|
|
@staticmethod
|
|
def add_to_playlist(azura_id, data):
|
|
file_url = f"{AZURACAST_URL}api/station/it-radio/file/{azura_id}"
|
|
response = authorize_url(file_url)
|
|
file_play = f"{AZURACAST_URL}api/station/it-radio/file/{response.json()['unique_id']}/play"
|
|
data.update(unique_id=file_play)
|
|
return data
|
|
|
|
|