コード例 #1
0
 def get_request(self, *args, **kwargs):
     """ Get API request from cache (or online if no cached version) """
     cache_days = kwargs.pop('cache_days', 0)  # Number of days to cache retrieved object if not already in cache.
     cache_name = kwargs.pop('cache_name', '')  # Affix to standard cache name.
     cache_only = kwargs.pop('cache_only', False)  # Only retrieve object from cache.
     cache_force = kwargs.pop('cache_force', False)  # Force retrieved object to be saved in cache. Use int to specify cache_days for fallback object.
     cache_fallback = kwargs.pop('cache_fallback', False)  # Object to force cache if no object retrieved.
     cache_refresh = kwargs.pop('cache_refresh', False)  # Ignore cached timestamps and retrieve new object.
     cache_combine_name = kwargs.pop('cache_combine_name', False)  # Combine given cache_name with auto naming via args/kwargs
     headers = kwargs.pop('headers', None) or self.headers  # Optional override to default headers.
     postdata = kwargs.pop('postdata', None)  # Postdata if need to POST to a RESTful API.
     is_xml = kwargs.pop('is_xml', False)  # Response needs translating from XML to dict
     request_url = self.get_request_url(*args, **kwargs)
     return cache.use_cache(
         self.get_api_request_json, request_url,
         headers=headers,
         postdata=postdata,
         is_xml=is_xml,
         cache_refresh=cache_refresh,
         cache_days=cache_days,
         cache_name=cache_name,
         cache_only=cache_only,
         cache_force=cache_force,
         cache_fallback=cache_fallback,
         cache_combine_name=cache_combine_name)
コード例 #2
0
 def get_id(self, unique_id, id_type, trakt_type=None, output_type=None):
     """
     trakt_type: movie, show, episode, person, list
     output_type: trakt, slug, imdb, tmdb, tvdb
     """
     return cache.use_cache(
         self._get_id, unique_id, id_type, trakt_type=trakt_type, output_type=output_type,
         cache_name=u'trakt_get_id.{}.{}.{}.{}'.format(id_type, unique_id, trakt_type, output_type),
         cache_days=cache.CACHE_LONG)
コード例 #3
0
 def get_artwork_type(self, ftv_id, ftv_type, artwork_type):
     return cache.use_cache(self._get_artwork_type,
                            ftv_id,
                            ftv_type,
                            artwork_type,
                            cache_name='fanart_tv.type.{}.{}.{}.{}'.format(
                                self.language, ftv_id, ftv_type,
                                artwork_type),
                            cache_only=self.cache_only,
                            cache_refresh=self.cache_refresh)
コード例 #4
0
 def get_tmdb_id(self, tmdb_type=None, imdb_id=None, tvdb_id=None, query=None, year=None, episode_year=None, raw_data=False, **kwargs):
     kwargs['cache_days'] = cache.CACHE_SHORT
     kwargs['cache_name'] = 'TMDb.get_tmdb_id'
     kwargs['cache_combine_name'] = True
     return cache.use_cache(
         self._get_tmdb_id, tmdb_type, imdb_id, tvdb_id, query, year, episode_year, raw_data, **kwargs)
コード例 #5
0
 def get_details(self, tmdb_type, tmdb_id, season=None, episode=None, **kwargs):
     kwargs['cache_days'] = cache.CACHE_LONG
     kwargs['cache_name'] = 'TMDb.get_details'
     kwargs['cache_combine_name'] = True
     return cache.use_cache(self._get_details, tmdb_type, tmdb_id, season, episode, **kwargs)
コード例 #6
0
 def get_tvshow_nextaired(self, tmdb_id):
     """ Get updated next aired data for tvshows using 24hr cache """
     return cache.use_cache(
         self._get_tvshow_nextaired, tmdb_id,
         cache_name='TMDb.get_tvshow_nextaired.{}'.format(tmdb_id),
         cache_days=cache.CACHE_SHORT)