Skip to content

Commit

Permalink
Handle pls playlist parsing exception
Browse files Browse the repository at this point in the history
  • Loading branch information
nsteel committed Feb 16, 2016
1 parent 047a662 commit e3a8c32
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions mopidy_tunein/tunein.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,14 @@ def parse_pls(data):
continue
for i in xrange(cp.getint(section, 'numberofentries')):
try:
# TODO: Remove this horrible hack
if cp.get(section, 'length%d' % (i+1)) == '-1':
yield cp.get(section, 'file%d' % (i+1))
# TODO: Remove this horrible hack to avoid adverts
if cp.has_option(section, 'length%d' % (i+1)):
if cp.get(section, 'length%d' % (i+1)) == '-1':
yield cp.get(section, 'file%d' % (i+1))
else:
yield cp.get(section, 'file%d' % (i+1))
except configparser.NoOptionError:
yield cp.get(section, 'file%d' % (i+1))
return


def fix_asf_uri(uri):
Expand Down Expand Up @@ -305,8 +308,11 @@ def parse_stream_url(self, url):
parser = find_playlist_parser(extension, content_type)
if parser:
playlist_data = StringIO.StringIO(playlist)
results = [u for u in parser(playlist_data)
if u and u != url]
try:
results = [u for u in parser(playlist_data)
if u and u != url]
except Exception as e:
logger.error('TuneIn playlist parsing failed %s' % e)
if not results:
logger.debug('Parsing failure, '
'malformed playlist: %s' % playlist)
Expand Down

0 comments on commit e3a8c32

Please sign in to comment.