MCPcopy Create free account
hub / github.com/dbr/tvdb_api / _parseBanners

Method _parseBanners

tvdb_api.py:954–1003  ·  view source on GitHub ↗

Parses banners XML, from http://thetvdb.com/api/[APIKEY]/series/[SERIES ID]/banners.xml Banners are retrieved using t['show name]['_banners'], for example: >>> t = Tvdb(banners = True) >>> t['scrubs']['_banners'].keys() [u'fanart', u'poster', u'seasonwide',

(self, sid)

Source from the content-addressed store, hash-verified

952 return sorted(languages)
953
954 def _parseBanners(self, sid):
955 """Parses banners XML, from
956 http://thetvdb.com/api/[APIKEY]/series/[SERIES ID]/banners.xml
957
958 Banners are retrieved using t['show name]['_banners'], for example:
959
960 >>> t = Tvdb(banners = True)
961 >>> t['scrubs']['_banners'].keys()
962 [u'fanart', u'poster', u'seasonwide', u'season', u'series']
963 >>> t['scrubs']['_banners']['poster']['680x1000'][35308]['_bannerpath']
964 u'http://thetvdb.com/banners/posters/76156-2.jpg'
965 >>>
966
967 Any key starting with an underscore has been processed (not the raw
968 data from the XML)
969
970 This interface will be improved in future versions.
971 """
972 LOG.debug('Getting season banners for %s' % (sid))
973 banners_resp = self._getetsrc(self.config['url_seriesBanner'] % sid)
974 banners = {}
975 for cur_banner in banners_resp.keys():
976 banners_info = self._getetsrc(self.config['url_seriesBannerInfo'] % (sid, cur_banner))
977 for banner_info in banners_info:
978 bid = banner_info.get('id')
979 btype = banner_info.get('keyType')
980 btype2 = banner_info.get('resolution')
981 if btype is None or btype2 is None:
982 continue
983
984 if btype not in banners:
985 banners[btype] = {}
986 if btype2 not in banners[btype]:
987 banners[btype][btype2] = {}
988 if bid not in banners[btype][btype2]:
989 banners[btype][btype2][bid] = {}
990
991 banners[btype][btype2][bid]['bannerpath'] = banner_info['fileName']
992 banners[btype][btype2][bid]['resolution'] = banner_info['resolution']
993 banners[btype][btype2][bid]['subKey'] = banner_info['subKey']
994
995 for k, v in list(banners[btype][btype2][bid].items()):
996 if k.endswith("path"):
997 new_key = "_%s" % k
998 LOG.debug("Transforming %s to %s" % (k, new_key))
999 new_url = self.config['url_artworkPrefix'] % v
1000 banners[btype][btype2][bid][new_key] = new_url
1001
1002 banners[btype]['raw'] = banners_info
1003 self._setShowData(sid, "_banners", banners)
1004
1005 def _parseActors(self, sid):
1006 """Parsers actors XML, from

Callers 1

_getShowDataMethod · 0.95

Calls 2

_getetsrcMethod · 0.95
_setShowDataMethod · 0.95

Tested by

no test coverage detected