2018-02-13 22:31:30 +01:00
|
|
|
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"]:
|
2019-09-14 17:36:04 +02:00
|
|
|
# for whatever crazy reason only half of the channels are the other way round
|
|
|
|
if channel.shortname in ["oe3", "fm4", "noe", "wie", "stm"]:
|
2018-02-13 22:31:30 +01:00
|
|
|
artist, title = song["title"].split(" - ")[:2]
|
|
|
|
else:
|
2019-09-14 17:36:04 +02:00
|
|
|
title, artist = song["title"].split(" - ")[:2]
|
2018-02-13 22:31:30 +01:00
|
|
|
else:
|
|
|
|
artist = ""
|
|
|
|
title = song["title"]
|
|
|
|
if channel.shortname == "fm4" and "|" in title:
|
|
|
|
title = title.split("|")[0]
|
|
|
|
|
|
|
|
yield (time, artist, title)
|