mirror of
https://github.com/Findus23/RadioStats.git
synced 2024-09-19 16:03:48 +02:00
21 lines
709 B
Python
21 lines
709 B
Python
from utils import *
|
|
|
|
|
|
def get(channel):
|
|
r = careful_fetch(channel.streamurl + "played.html?type=json")
|
|
print(r.text)
|
|
for song in r.json():
|
|
time = datetime.fromtimestamp(song["playedat"])
|
|
|
|
if " - " in song["title"]:
|
|
if channel.shortname == "oe3" or channel.shortname == "fm4":
|
|
artist, title = song["title"].split(" - ")[:2]
|
|
else:
|
|
title, artist = song["title"].split(" - ")[:2] # non oe3 channels are the other way round
|
|
else:
|
|
artist = ""
|
|
title = song["title"]
|
|
if channel.shortname == "fm4" and "|" in title:
|
|
title = title.split("|")[0]
|
|
|
|
yield (time, artist, title)
|