mirror of
https://github.com/Findus23/RadioStats.git
synced 2024-09-19 16:03:48 +02:00
27 lines
784 B
Python
27 lines
784 B
Python
import json
|
|
|
|
from websocket import create_connection
|
|
|
|
from parser import BaseFetcher
|
|
from utils import *
|
|
|
|
URL = "wss://www.arabella.at/api/_socket/"
|
|
|
|
|
|
class ArabellaFetcher(BaseFetcher):
|
|
def get(self, channel):
|
|
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
|