Skip to content

Commit

Permalink
ttvdb: Check if there are any banners before iterating the list
Browse files Browse the repository at this point in the history
fixes #13511
  • Loading branch information
mspieth committed Nov 16, 2019
1 parent 1df343e commit 4b6d381
Showing 1 changed file with 25 additions and 24 deletions.
49 changes: 25 additions & 24 deletions mythtv/bindings/python/MythTV/ttvdb/tvdb_api.py
Expand Up @@ -958,30 +958,31 @@ def _parseBanners(self, sid):
banners = {}
for cur_banner in bannersEt.keys():
banners_info = self._getetsrc(self.config['url_seriesBannerInfo'] % (sid, cur_banner))
for banner_info in banners_info:
bid = banner_info.get('id')
btype = banner_info.get('keyType')
btype2 = banner_info.get('resolution')
if btype is None or btype2 is None:
continue

if btype not in banners:
banners[btype] = {}
if btype2 not in banners[btype]:
banners[btype][btype2] = {}
if bid not in banners[btype][btype2]:
banners[btype][btype2][bid] = {}

banners[btype][btype2][bid]['bannerpath'] = banner_info['fileName']
banners[btype][btype2][bid]['resolution'] = banner_info['resolution']
banners[btype][btype2][bid]['subKey'] = banner_info['subKey']

for k, v in list(banners[btype][btype2][bid].items()):
if k.endswith("path"):
new_key = "_%s" % k
log().debug("Transforming %s to %s" % (k, new_key))
new_url = self.config['url_artworkPrefix'] % v
banners[btype][btype2][bid][new_key] = new_url
if banner_info is not None:
for banner_info in banners_info:
bid = banner_info.get('id')
btype = banner_info.get('keyType')
btype2 = banner_info.get('resolution')
if btype is None or btype2 is None:
continue

if btype not in banners:
banners[btype] = {}
if btype2 not in banners[btype]:
banners[btype][btype2] = {}
if bid not in banners[btype][btype2]:
banners[btype][btype2][bid] = {}

banners[btype][btype2][bid]['bannerpath'] = banner_info['fileName']
banners[btype][btype2][bid]['resolution'] = banner_info['resolution']
banners[btype][btype2][bid]['subKey'] = banner_info['subKey']

for k, v in list(banners[btype][btype2][bid].items()):
if k.endswith("path"):
new_key = "_%s" % k
log().debug("Transforming %s to %s" % (k, new_key))
new_url = self.config['url_artworkPrefix'] % v
banners[btype][btype2][bid][new_key] = new_url

banners[btype]['raw'] = banners_info
self._setShowData(sid, "_banners", banners)
Expand Down

0 comments on commit 4b6d381

Please sign in to comment.