Skip to content

Commit

Permalink
Check if the stream is valid.
Browse files Browse the repository at this point in the history
  • Loading branch information
hechtus committed Oct 7, 2013
1 parent 85b66ba commit 38f156d
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions mopidy_radio/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']:
Expand All @@ -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 []

0 comments on commit 38f156d

Please sign in to comment.