Exemplo n.º 1
0
    def get_images(self, uniqueids, types=None):
        if not settings.get_apienabled('tmdb'):
            return {}
        if types is not None and not self.provides(types):
            return {}
        if not self.baseurl:
            return {}
        mediaid = get_mediaid(uniqueids, ('tmdbse', 'tvdb', 'tvdbse', 'unknown'))
        if not mediaid:
            return {}
        if 'tmdbse' in uniqueids:
            splits = mediaid.split('/')
            data = {'show_id': splits[0], 'season_number': splits[1], 'episode_number': splits[2]}
        elif 'tvdbse' in uniqueids and 'tvdb' not in uniqueids:
            splits = mediaid.split('/')
            data = self.get_data(self.tvdbidsearch_url % mediaid)
            if not data or not data['tv_results']:
                return {}
            data = data['tv_results'][0]
            data = {'show_id': data['id'], 'season_number': splits[1], 'episode_number': splits[2]}
        else:
            data = self.get_data(self.tvdbidsearch_url % mediaid)
            if not data or not data['tv_episode_results']:
                return {}
            data = data['tv_episode_results'][0]
        data = self.get_data(self.apiurl % (data['show_id'], data['season_number'], data['episode_number']))
        if not data:
            return {}

        return self.process_data(data)
Exemplo n.º 2
0
    def get_images(self, uniqueids, types=None):
        if not settings.get_apienabled('tadb'):
            return {}
        if types is not None and not self.provides(types) or not (
                uniqueids.get('mbtrack') or uniqueids.get('mbgroup')
                or uniqueids.get('mbartist')):
            return {}

        images = {}
        for idsource, artdata in self.artmap.iteritems():
            if idsource not in uniqueids or types is not None and not \
                    any(x in types for x in artdata['artmap'].itervalues()):
                continue
            data = self.get_data(artdata['url'], {'i': uniqueids[idsource]})
            if not data or not data.get(artdata['datakey']):
                continue
            data = data[artdata['datakey']][0]
            for originaltype, finaltype in artdata['artmap'].iteritems():
                if (originaltype in ('strAlbumThumbBack', 'strAlbumSpine')):
                    continue
                if originaltype == 'strArtistThumb':
                    finaltype = 'artistthumb'
                elif originaltype in ('strTrackThumb', 'strAlbumThumb'):
                    finaltype = 'poster'
                if data.get(originaltype):
                    _insertart(
                        images, finaltype,
                        self._build_image(data[originaltype],
                                          _get_imagesize(originaltype),
                                          artdata['datakey']))

        return images
Exemplo n.º 3
0
 def get_images(self, uniqueids, types=None):
     if not settings.get_apienabled('tvdb'):
         return {}
     if types is not None and not self.provides(types):
         return {}
     mediaid = get_mediaid(uniqueids)
     if not mediaid:
         return {}
     result = {}
     languages = base.languages
     # Useful fanart can be hidden by the language filter, try a few of the most frequently used
     flanguages = ['en', 'de', 'fr', 'es', 'ru']
     flanguages.extend(lang for lang in languages if lang not in flanguages)
     for arttype in self.artmap:
         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 not data:
                 continue
             isseason = arttype.startswith('season')
             if not isseason:
                 if generaltype not in result:
                     result[generaltype] = []
             for image in data['data']:
                 if not image.get('fileName'
                                  ) or isseason and not image.get('subKey'):
                     continue
                 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'] or '_cache/' + image['fileName'])
                 resultimage[
                     'language'] = language if shouldset_imagelanguage(
                         image) else None
                 resultimage['rating'] = self._get_rating(image)
                 if arttype in ('series', 'seasonwide'):
                     resultimage['size'] = SortedDisplay(758, '758x140')
                 elif arttype == 'season':
                     resultimage['size'] = SortedDisplay(1000, '680x1000')
                 else:
                     resultimage['size'] = parse_sortsize(image, arttype)
                 result[ntype].append(resultimage)
     return result
Exemplo n.º 4
0
    def get_images(self, uniqueids, types=None):
        if not settings.get_apienabled('tmdb'):
            return {}
        if types is not None and not self.provides(types):
            return {}
        mediaid = get_mediaid(uniqueids)
        if not mediaid:
            return {}
        if not self.baseurl:
            return {}
        data = self.get_data(self.apiurl % mediaid)
        if not data:
            return {}

        return self.process_data(data)
Exemplo n.º 5
0
    def get_images(self, uniqueids, types=None):
        if not settings.get_apienabled('kyradb'):
            return {}
        mediaid = get_mediaid(uniqueids)
        if not mediaid:
            return {}
        if types is None:
            types = self.provtypes

        result = {}
        if any(x in self.animatedtypes for x in types):
            result.update(self._get_animated_images(mediaid))
        if 'characterart' in types:
            characterart = self._get_characterart(mediaid)
            if characterart:
                result['characterart'] = characterart

        return result
Exemplo n.º 6
0
 def get_images(self, uniqueids, types=None):
     if not settings.get_apienabled('fanarttv'):
         return {}
     if types is not None and not self.provides(types):
         return {}
     mediaid = get_mediaid(uniqueids, self.mediatype)
     if not mediaid or isinstance(mediaid, tuple) and not mediaid[0]:
         return {}
     data = self.get_data(mediaid[0] if isinstance(mediaid, tuple) else mediaid)
     if not data:
         return {}
     if self.mediatype == mediatypes.MUSICVIDEO:
         return self._get_images(data, mediaid)
     elif self.mediatype == mediatypes.ALBUM:
         if not data.get('albums', {}).get(mediaid):
             return {}
         return self._get_images(data['albums'][mediaid])
     else:
         return self._get_images(data)
Exemplo n.º 7
0
    def _inner_get_images(self, uniqueids, idsource, types):
        if not settings.get_apienabled('tadb'):
            return {}
        if not uniqueids.get(idsource):
            return {}
        artdata = self.artmap[idsource]
        if types and not any(x in types
                             for x in artdata['artmap'].itervalues()):
            return {}

        images = {}
        data = self.get_data(artdata['url'], {'i': uniqueids[idsource]})
        if not data or not data.get(artdata['datakey']):
            return {}
        data = data[artdata['datakey']][0]
        for originaltype, finaltype in artdata['artmap'].iteritems():
            if data.get(originaltype):
                _insertart(
                    images, finaltype,
                    self._build_image(data[originaltype],
                                      _get_imagesize(originaltype),
                                      artdata['datakey']))

        return images
Exemplo n.º 8
0
    def get_images(self, uniqueids, types=None):
        if not settings.get_apienabled('tvdb'):
            return {}
        if types is not None and not self.provides(types):
            return {}
        mediaid = get_mediaid(uniqueids)
        if not mediaid:
            return {}
        result = {}
        languages = base.languages
        # Useful fanart can be hidden by the language filter, try a few of the most frequently used
        flanguages = ['en', 'de', 'fr', 'es', 'ru']
        flanguages.extend(lang for lang in languages if lang not in flanguages)
        for arttype in self.artmap:
            if types and not typematches(self.artmap[arttype], types):
                continue
            arttype_error = False
            for language in languages if arttype != 'fanart' else flanguages:
                generaltype = self.artmap[arttype]
                data = self.get_data(mediaid, arttype, language)
                if not data:
                    continue
                isseason = arttype.startswith('season')
                if not isseason:
                    if generaltype not in result:
                        result[generaltype] = []
                for image in data['data']:
                    if not image.get('fileName'
                                     ) or isseason and not image.get('subKey'):
                        continue
                    ntype = generaltype
                    if isseason:
                        try:
                            int(image['subKey'])
                        except ValueError:
                            if arttype_error:
                                continue
                            arttype_error = True
                            self.log(
                                "Provider returned unexpected content and '{0}' "
                                .format(arttype) +
                                "artwork could not be processed:\n" +
                                "expected a season number but got '{0}'".
                                format(image['subKey']), xbmc.LOGWARNING)
                            continue
                        ntype = ntype % image['subKey']
                        if ntype not in result:
                            result[ntype] = []

                    # skip duplicates
                    if any(x for x in result[ntype]
                           if x['url'].endswith(image['fileName'])):
                        continue

                    resultimage = {'provider': self.name}
                    resultimage['url'] = self.imageurl_base + image['fileName']
                    resultimage['preview'] = self.imageurl_base + (
                        image['thumbnail'] or '_cache/' + image['fileName'])
                    resultimage[
                        'language'] = language if shouldset_imagelanguage(
                            image) else None
                    resultimage['rating'] = self._get_rating(image)
                    if arttype in ('series', 'seasonwide'):
                        resultimage['size'] = SortedDisplay(758, '758x140')
                    elif arttype == 'season':
                        resultimage['size'] = SortedDisplay(1000, '680x1000')
                    else:
                        resultimage['size'] = parse_sortsize(image, arttype)
                    result[ntype].append(resultimage)
        return result