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 _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)
def _get_data(self, mediaid, urltype): if not settings.kyradb_user_apikey or not settings.kyradb_userkey: raise ProviderError( "KyraDB API key and User key is required for artwork from KyraDB: " + str(self.provtypes)) headers = { 'Apikey': settings.kyradb_user_apikey, 'Userkey': settings.kyradb_userkey } self.log('uncached', xbmc.LOGINFO) response = self.doget(self.apiurl.format(mediaid, urltype), headers=headers) result = json.loads( response.text, cls=UTF8JSONDecoder) if response is not None else None if result and result.get('error'): if result['error'] != 4: # 4: "No results" raise ProviderError(result['message']) result = None return 'Empty' if result is None else result
def onNotification(self, sender, method, data): if method.startswith('Other.') and sender != 'script.artwork.beef:control': return if method == 'Other.CancelCurrent': if self.status == STATUS_PROCESSING: self.abort = True elif self.signal: self.signal = None self.processor.close_progress() elif method == 'Other.ProcessNewVideos': self.processor.create_progress() self.signal = 'newvideos' elif method == 'Other.ProcessNewAndOldVideos': self.processor.create_progress() self.signal = 'oldvideos' elif method == 'Other.ProcessAllVideos': self.processor.create_progress() self.signal = 'allvideos' elif method == 'Other.ProcessLocalVideos': self.processor.create_progress() self.signal = 'localvideos' elif method == 'Other.ProcessAfterSettings': self.processaftersettings = True elif method == 'Player.OnStop': if settings.enableservice: data = json.loads(data) if self.watchitem(data): self.stoppeditems.add((data['item']['type'], data['item']['id'])) elif method == 'VideoLibrary.OnScanStarted': if settings.enableservice and self.status == STATUS_PROCESSING: self.abort = True elif method == 'VideoLibrary.OnScanFinished': if settings.enableservice: scan_olditems = settings.enable_olditem_updates and get_date() > self.last_videoupdate self.signal = 'oldvideos' if scan_olditems else 'newvideos' self.processor.create_progress() elif method == 'VideoLibrary.OnUpdate': if not settings.enableservice: return data = json.loads(data) if not self.watchitem(data): return if (data['item']['type'], data['item']['id']) in self.stoppeditems: self.stoppeditems.remove((data['item']['type'], data['item']['id'])) return if not self.scanning: self.recentvideos[data['item']['type']].append(data['item']['id']) self.signal = 'recentvideos' elif pykodi.get_kodi_version() >= 18: if method == 'AudioLibrary.OnScanFinished': if settings.enableservice_music: scan_olditems = settings.enable_olditem_updates and get_date() > self.last_musicupdate self.signal = 'oldmusic' if scan_olditems else 'newmusic' elif method == 'Other.ProcessNewMusic': self.processor.create_progress() self.signal = 'newmusic' elif method == 'Other.ProcessNewAndOldMusic': self.processor.create_progress() self.signal = 'oldmusic' elif method == 'Other.ProcessAllMusic': self.processor.create_progress() self.signal = 'allmusic'