1
0
Fork 0
mirror of https://github.com/Findus23/RadioStats.git synced 2024-09-19 16:03:48 +02:00
RadioStats/parser/orf.py
Lukas Winkler d286059289
major overhaul
- use new ORF API
- better structured fetchers
- easier channel metadata
2020-09-28 18:31:57 +02:00

17 lines
565 B
Python

from parser import BaseFetcher
from utils import *
class OrfFetcher(BaseFetcher):
def get(self, channel):
r = careful_fetch(f"https://audioapi.orf.at/{channel.shortname}/json/4.0/live")
r.raise_for_status()
for song in r.json()[0]["items"]:
time = datetime.fromtimestamp(song["start"] / 1000)
try:
artist = song["interpreter"]
title = song["title"]
except KeyError:
print("not a song")
continue
yield (time, artist, title)