示例#1
0
    def cachefor(self, artmap, multiplethreads=False):
        if not self.imagecachebase or self.debug:
            return 0
        urls = [
            url for url in artmap.values()
            if url and not url.startswith(('http', 'image'))
        ]
        if not urls:
            return 0
        if self.alreadycached is not None:
            if not self.alreadycached:
                self.alreadycached = [
                    pykodi.unquoteimage(texture['url'])
                    for texture in quickjson.get_textures()
                    if not pykodi.unquoteimage(texture['url']).startswith((
                        'http', 'image'))
                ]
            alreadycached = self.alreadycached
        else:
            alreadycached = [
                pykodi.unquoteimage(texture['url'])
                for texture in quickjson.get_textures(urls)
            ]
        count = [0]

        def worker(path):
            try:
                res, _ = self.doget(self.imagecachebase +
                                    urllib.quote(pykodi.quoteimage(path), ''),
                                    stream=True)
                if res:
                    res.iter_content(chunk_size=1024)
                    res.close()
                    count[0] += 1
            except GetterError:
                pass

        threads = []
        for path in urls:
            if path in alreadycached:
                continue
            if multiplethreads:
                t = threading.Thread(target=worker, args=(path, ))
                threads.append(t)
                t.start()
            else:
                worker(path)
        for t in threads:
            t.join()
        return count[0]
示例#2
0
def _get_seasons_artwork(seasons):
    resultseasons = {}
    resultart = {}
    for season in seasons:
        resultseasons[season['season']] = season['seasonid']
        for arttype, url in season['art'].iteritems():
            arttype = arttype.lower()
            if not arttype.startswith(('tvshow.', 'season.')):
                resultart['%s.%s.%s' % (mediatypes.SEASON, season['season'],
                                        arttype)] = pykodi.unquoteimage(url)
    return resultseasons, resultart
示例#3
0
def get_own_artwork(jsondata):
    return dict((arttype.lower(), unquoteimage(url))
                for arttype, url in jsondata['art'].iteritems()
                if '.' not in arttype)