From 38f156dc64c089d1824863971402c548ce46132b Mon Sep 17 00:00:00 2001 From: Hechtus Date: Mon, 7 Oct 2013 09:33:54 +0200 Subject: [PATCH] Check if the stream is valid. --- mopidy_radio/library.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/mopidy_radio/library.py b/mopidy_radio/library.py index 629ebe6..195fcb6 100644 --- a/mopidy_radio/library.py +++ b/mopidy_radio/library.py @@ -55,10 +55,11 @@ def _station_to_tracks(self, station): if station['podcastUrls']: tracks = [] for track in station['podcastUrls']: - tracks.append(Track(uri = track['streamUrl'], - name = station['name'] + ': ' + track['title'], - date = dateutil.parser.parse(track['published']).date().isoformat(), - bitrate = track['bitRate'])) + if track['streamStatus'] == 'VALID': + tracks.append(Track(uri = track['streamUrl'], + name = station['name'] + ': ' + track['title'], + date = dateutil.parser.parse(track['published']).date().isoformat(), + bitrate = track['bitRate'])) return tracks for suffix in ['m3u', 'pls']: @@ -68,7 +69,10 @@ def _station_to_tracks(self, station): return [Track(uri = url, name = station['name'], bitrate = station['bitrate'])] - - return [Track(uri = station['streamUrls'][0]['streamUrl'], - name = station['name'], - bitrate = station['streamUrls'][0]['bitRate'])] + + if station['streamUrls'][0]['streamStatus'] == 'VALID': + return [Track(uri = station['streamUrls'][0]['streamUrl'], + name = station['name'], + bitrate = station['streamUrls'][0]['bitRate'])] + else: + return []