1
0
Fork 0
mirror of https://github.com/Findus23/RadioStats.git synced 2024-09-19 16:03:48 +02:00
RadioStats/parser/ara.py

28 lines
784 B
Python
Raw Normal View History

2021-11-23 21:32:02 +01:00
import json
from websocket import create_connection
from parser import BaseFetcher
from utils import *
2021-11-23 21:32:02 +01:00
URL = "wss://www.arabella.at/api/_socket/"
class ArabellaFetcher(BaseFetcher):
def get(self, channel):
2021-11-23 21:32:02 +01:00
ws = create_connection(URL, suppress_origin=True)
init = ws.recv()
ws.send(json.dumps({"type": "select_channels", "channelIds": [1]}))
result = ws.recv()
data = json.loads(result)
tracks = [data["currentTrack"]]
tracks.extend(data["previousTracks"])
tracks.extend(data["futureTracks"])
for track in tracks:
artist = track["artist"]
title = track["title"]
time = time_to_date(string_to_time(track["time"], seconds=False))
yield time, artist, title