mirror of
https://github.com/Findus23/RadioStats.git
synced 2024-09-09 04:23:47 +02:00
fix kronehit
This commit is contained in:
parent
91d0be6eb0
commit
b75de418f6
2 changed files with 9 additions and 15 deletions
|
@ -5,13 +5,13 @@ from websocket import create_connection, WebSocket
|
|||
from parser import BaseFetcher
|
||||
from utils import *
|
||||
|
||||
URL = "wss://www.arabella.at/api/_socket/"
|
||||
|
||||
|
||||
class ArabellaFetcher(BaseFetcher):
|
||||
URL = "wss://www.arabella.at/api/_socket/"
|
||||
def get(self, channel):
|
||||
ws: WebSocket = create_connection(
|
||||
URL,
|
||||
self.URL,
|
||||
suppress_origin=True,
|
||||
header=["User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:98.0) Gecko/20100101 Firefox/98.0"]
|
||||
)
|
||||
|
@ -23,8 +23,10 @@ class ArabellaFetcher(BaseFetcher):
|
|||
ws.close()
|
||||
data = json.loads(result)
|
||||
tracks = [data["currentTrack"]]
|
||||
tracks.extend(data["previousTracks"])
|
||||
tracks.extend(data["futureTracks"])
|
||||
if "previousTracks" in data:
|
||||
tracks.extend(data["previousTracks"])
|
||||
if "futureTracks" in data:
|
||||
tracks.extend(data["futureTracks"])
|
||||
for track in tracks:
|
||||
artist = track["artist"]
|
||||
title = track["title"]
|
||||
|
|
|
@ -1,13 +1,5 @@
|
|||
from parser import BaseFetcher
|
||||
from utils import *
|
||||
|
||||
URL = "https://www.kronehit.at/alles-ueber-kronehit/hitsuche/?format=json&channel=1"
|
||||
from parser import ArabellaFetcher
|
||||
|
||||
|
||||
class KroneHitFetcher(BaseFetcher):
|
||||
def get(self, channel):
|
||||
for track in fetch(URL, True)["items"]:
|
||||
artist = track["ArtistName"]
|
||||
title = track["TrackName"]
|
||||
time = time_to_date(string_to_time(track["PlayTime"], seconds=False))
|
||||
yield time, artist, title
|
||||
class KroneHitFetcher(ArabellaFetcher):
|
||||
URL = "wss://www.kronehit.at/api/_socket/"
|
||||
|
|
Loading…
Reference in a new issue