def toggleAll(setting, open_id=None, sourceList=None): from civitasscrapers import getAllHosters sourceList = getAllHosters() if not sourceList else sourceList for i in sourceList: source_setting = 'provider.' + i control.setSetting(source_setting, setting) control.openSettings(open_id)
def ToggleProviderAll(enable): from civitasscrapers import providerNames sourceList = providerNames() (setting, open_id) = ('true', '0.3') if enable else ('false', '0.2') for i in sourceList: source_setting = 'provider.' + i control.setSetting(source_setting, setting) control.openSettings(open_id)
def ScraperChoice(): from civitasscrapers import providerSources sourceList = sorted(providerSources()) control.idle() select = control.selectDialog([i for i in sourceList]) if select == -1: return module_choice = sourceList[select] control.setSetting('module.provider', module_choice) control.openSettings('0.1')
def authTrakt(): try: if getTraktCredentialsInfo() == True: if control.yesnoDialog( control.lang(32511).encode('utf-8'), control.lang(32512).encode('utf-8'), '', 'Trakt'): control.setSetting(id='trakt.user', value='') control.setSetting(id='trakt.token', value='') control.setSetting(id='trakt.refresh', value='') raise Exception() result = getTraktAsJson('/oauth/device/code', {'client_id': V2_API_KEY}) verification_url = (control.lang(32513) % result['verification_url']).encode('utf-8') user_code = (control.lang(32514) % result['user_code']).encode('utf-8') expires_in = int(result['expires_in']) device_code = result['device_code'] interval = result['interval'] progressDialog = control.progressDialog progressDialog.create('Trakt', verification_url, user_code) for i in range(0, expires_in): try: if progressDialog.iscanceled(): break time.sleep(1) if not float(i) % interval == 0: raise Exception() r = getTraktAsJson( '/oauth/device/token', { 'client_id': V2_API_KEY, 'client_secret': CLIENT_SECRET, 'code': device_code }) if 'access_token' in r: break except: pass try: progressDialog.close() except: pass token, refresh = r['access_token'], r['refresh_token'] headers = { 'Content-Type': 'application/json', 'trakt-api-key': V2_API_KEY, 'trakt-api-version': 2, 'Authorization': 'Bearer %s' % token } result = client.request(urlparse.urljoin(BASE_URL, '/users/me'), headers=headers) result = utils.json_loads_as_str(result) user = result['username'] control.setSetting(id='trakt.user', value=user) control.setSetting(id='trakt.token', value=token) control.setSetting(id='trakt.refresh', value=refresh) raise Exception() except: control.openSettings('4.1')
source_setting = 'provider.' + i control.setSetting(source_setting, setting) control.openSettings(open_id) def toggleAll(setting, open_id=None, sourceList=None): from civitasscrapers import getAllHosters sourceList = getAllHosters() if not sourceList else sourceList for i in sourceList: source_setting = 'provider.' + i control.setSetting(source_setting, setting) control.openSettings(open_id) if mode == "CivitasSettings": control.openSettings('0.0', 'script.module.civitasscrapers') if mode == "ScraperChoice": ScraperChoice() if mode == "ToggleProviderAll": ToggleProviderAll(False if params['action'] == "DisableModuleAll" else True) if mode == "toggleAll": open_id = params['open_id'] if 'open_id' in params else '0.0' sourcelist = params['sourcelist'] if 'sourcelist' in params else None toggleAll(params['setting'], open_id, sourceList=sourcelist) if mode == "toggleAllDebrid": sourcelist = [