Esempio n. 1
0
 def get_images(self, mediaid, types=None):
     if types and not self.provides(types):
         return {}
     result = {}
     languages = [pykodi.get_language(xbmc.ISO_639_1)]
     if languages[0] != 'en':
         languages.append('en')
     # Useful fanart can be hidden by the language filter, try a few of the most frequently used
     flanguages = ['en', 'de', 'fr', 'es', 'ru']
     if languages[0] not in flanguages:
         flanguages.append(languages[0])
     for arttype in self.artmap.keys():
         if types and not typematches(self.artmap[arttype], types):
             continue
         for language in languages if arttype != 'fanart' else flanguages:
             generaltype = self.artmap[arttype]
             data = self.get_data(mediaid, arttype, language)
             if data == 'Empty':
                 continue
             isseason = arttype.startswith('season')
             if not isseason:
                 if generaltype not in result:
                     result[generaltype] = []
             for image in data['data']:
                 ntype = generaltype
                 if isseason:
                     ntype = ntype % image['subKey']
                     if ntype not in result:
                         result[ntype] = []
                 resultimage = {'provider': self.name}
                 resultimage['url'] = self.imageurl_base + image['fileName']
                 resultimage['preview'] = self.imageurl_base + image['thumbnail']
                 resultimage['language'] = language if shouldset_imagelanguage(image) else None
                 if image['ratingsInfo']['average']:
                     resultimage['rating'] = SortedDisplay(image['ratingsInfo']['average'], '{0:.1f} stars'.format(image['ratingsInfo']['average']))
                 else:
                     resultimage['rating'] = SortedDisplay(5, 'Not rated')
                 if arttype in ('series', 'seasonwide'):
                     resultimage['size'] = SortedDisplay(758, '758x140')
                 elif arttype == 'season':
                     resultimage['size'] = SortedDisplay(1000, '680x1000')
                 else:
                     try:
                         sortsize = int(image['resolution'].split('x')[0 if arttype != 'poster' else 1])
                     except ValueError:
                         self.log('whoops, ValueError on "%s"' % image['resolution'])
                         sortsize = 0
                     resultimage['size'] = SortedDisplay(sortsize, image['resolution'])
                 result[ntype].append(resultimage)
     return result
 def setlanguages(self):
     self.language = pykodi.get_language(xbmc.ISO_639_1)
     if self.language == 'en':
         self.autolanguages = (self.language, None)
     else:
         self.autolanguages = (self.language, 'en', None)