3 from .models import Track, SomaLogLine
6 def get_current_nonstop_track():
8 soma_log_line = SomaLogLine.objects.select_related().order_by('-play_timestamp')[0]
12 if soma_log_line.play_timestamp < (datetime.datetime.now() - datetime.timedelta(hours=1)):
13 # last known line is way too old
15 if not soma_log_line.on_air:
16 # nonstop should be on air but it's not :/
19 current_nonstop_file = soma_log_line.filepath
20 if not 'Tranches/' in current_nonstop_file.filepath and (
21 not 'tracks/' in current_nonstop_file.filepath):
22 # nonstop is playing but it's not a nonstop track :/
24 current_track = soma_log_line.filepath.track
25 if current_track is None:
26 # nonstop is playing a nonstop track, but it's unknown :/
28 d = {'track_title': current_track.title}
29 if current_track.artist:
30 d['track_artist'] = current_track.artist.name