Beispiel #1
0
 def get_data(self, url, params=None):
     apikey = settings.get_apikey('tadb')
     if not apikey:
         raise build_key_error('tadb')
     result = cache.cacheFunction(self._get_data,
                                  url.format(settings.get_apikey('tadb')),
                                  params)
     return result if result != 'Empty' else None
 def _get_data(self, url):
     apikey = settings.get_apikey('tmdb')
     if not apikey:
         raise build_key_error('tmdb')
     self.log('uncached', xbmc.LOGINFO)
     response = self.doget(url, params={'api_key': apikey})
     return 'Empty' if response is None else json.loads(response.text, cls=UTF8JSONDecoder)
 def _get_data(self, mediaid):
     apikey = settings.get_apikey('fanarttv')
     if not apikey:
         raise build_key_error('fanarttv')
     self.log('uncached', xbmc.LOGINFO)
     headers = {'api-key': apikey}
     if settings.fanarttv_clientkey:
         headers['client-key'] = settings.fanarttv_clientkey
     response = self.doget(self.apiurl % (self.api_section, mediaid), headers=headers)
     return 'Empty' if response is None else json.loads(response.text, cls=UTF8JSONDecoder)
 def baseurl(self):
     if not self._baseurl:
         apikey = settings.get_apikey('tmdb')
         if not apikey:
             raise build_key_error('tmdb')
         response = self.doget(cfgurl, params={'api_key': apikey})
         if response is None:
             return
         self._baseurl = response.json()['images']['secure_base_url']
     return self._baseurl
 def _get_data(self, url, params=None):
     apikey = settings.get_apikey('tmdb')
     if not apikey:
         raise build_key_error('tmdb')
     self.log('uncached', xbmc.LOGINFO)
     if params is None:
         params = {'api_key': apikey}
     else:
         params = dict(params, api_key=apikey)
     response = self.doget(url, params=params)
     return 'Empty' if response is None else response.json()
 def _get_data(self, mediaid, arttype, language):
     if not settings.get_apikey('tvdb'):
         raise build_key_error('tvdb')
     self.log('uncached', xbmc.LOGINFO)
     getparams = {
         'params': {
             'keyType': arttype
         },
         'headers': {
             'Accept-Language': language
         }
     }
     response = self.doget(self.apiurl % mediaid, **getparams)
     return 'Empty' if response is None else json.loads(response.text,
                                                        cls=UTF8JSONDecoder)
Beispiel #7
0
 def login(self):
     response = self.getter.session.post(
         self.loginurl,
         json={'apikey': settings.get_apikey('tvdb')},
         headers={
             'Content-Type': 'application/json',
             'User-Agent': settings.useragent
         },
         timeout=15)
     if response is not None and response.status_code == 401:
         raise build_key_error('tvdb')
     if not response or not response.headers['Content-Type'].startswith(
             'application/json'):
         raise ProviderError("Provider returned unexected content")
     self.getter.session.headers[
         'authorization'] = 'Bearer %s' % response.json()['token']
     return True
Beispiel #8
0
 def get_data(self, url, params):
     result = cache.cacheFunction(self._get_data,
                                  url.format(settings.get_apikey('tadb')),
                                  params)
     return result if result != 'Empty' else None