'url': d['emission'].get_absolute_url(),
'chat': chat_url,
}
+
+ track_title = None
+ playing_txt = os.path.join(settings.MEDIA_ROOT, 'playing.txt')
+ if os.path.exists(playing_txt):
+ track_title = open(playing_txt).read().strip()
+ if len(track_title) < 6:
+ track_title = None
if d.get('nonstop'):
d['nonstop'] = {
'title': d['nonstop'].title,
}
- playing_txt = os.path.join(settings.MEDIA_ROOT, 'playing.txt')
- if os.path.exists(playing_txt):
- d['track_title'] = open(playing_txt).read().strip()
+ if track_title:
+ d['track_title'] = track_title
+ elif d.get('emission') and not d.get('episode') and track_title:
+ # live emission, if there's a track playing, and no known episode,
+ # display it.
+ d['episode'] = {
+ 'title': track_title,
+ 'url': d['emission']['url'],
+ }
+
if d.get('current_slot'):
del d['current_slot']
return JsonResponse({'data': d})