Fix IndexError e.g. for channels if stream info missing

This commit is contained in:
croneter 2017-09-13 15:41:06 +02:00
parent 02ba51bc15
commit 14fc334422

View file

@ -1754,8 +1754,16 @@ class API():
videotracks = [] videotracks = []
audiotracks = [] audiotracks = []
subtitlelanguages = [] subtitlelanguages = []
# Sometimes, aspectratio is on the "toplevel" try:
aspectratio = self.item[0].attrib.get('aspectRatio', None) # Sometimes, aspectratio is on the "toplevel"
aspectratio = self.item[0].attrib.get('aspectRatio', None)
except IndexError:
# There is no stream info at all, returning empty
return {
'video': videotracks,
'audio': audiotracks,
'subtitle': subtitlelanguages
}
# TODO: what if several Media tags exist?!? # TODO: what if several Media tags exist?!?
# Loop over parts # Loop over parts
for child in self.item[0]: for child in self.item[0]: