openscrapers.modules.control.setting - python examples

Here are the examples of the python api openscrapers.modules.control.setting taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

6 Examples 7

3 View Complete Implementation : debrid.py
Copyright GNU General Public License v3.0
Author : a4k-openproject
def status(torrent=False):
	try:
		import xbmc
		debrid_check = debrid_resolvers != []
		if debrid_check is True:
			if torrent:
				enabled = control.setting('torrent.enabled')
				if enabled == '' or enabled.lower() == 'true':
					return True
				else:
					return False
		return debrid_check
	except:
		return True

3 View Complete Implementation : furk.py
Copyright GNU General Public License v3.0
Author : a4k-openproject
	def __init__(self):
		self.priority = 1
		self.language = ['en']
		self.domain = 'furk.net/'
		self.base_link = 'https://www.furk.net'
		self.meta_search_link = "/api/plugins/metasearch?api_key=%s&q=%s&cached=yes" \
		                        "&match=%s&moderated=%s%s&sort=relevance&type=video&offset=0&limit=%s"
		self.tfile_link = "/api/file/get?api_key=%s&t_files=1&id=%s"
		self.login_link = "/api/login/login?login=%s&pwd=%s"
		self.user_name = control.setting('furk.user_name')
		self.user_past = control.setting('furk.user_past')
		self.api_key = control.setting('furk.api')
		self.search_limit = control.setting('furk.limit')
		self.files = []

3 View Complete Implementation : ororo.py
Copyright GNU General Public License v3.0
Author : a4k-openproject
	def __init__(self):
		self.priority = 1
		self.language = ['en']
		self.domains = ['ororo.tv']
		self.base_link = 'https://ororo.tv'
		self.moviesearch_link = '/api/v2/movies'
		self.tvsearch_link = '/api/v2/shows'
		self.movie_link = '/api/v2/movies/%s'
		self.show_link = '/api/v2/shows/%s'
		self.episode_link = '/api/v2/episodes/%s'

		self.user = control.setting('ororo.user')
		self.pastword = control.setting('ororo.past')
		self.headers = {
			'Authorization': 'Basic %s' % base64.b64encode('%s:%s' % (self.user, self.pastword)),
			'User-Agent': 'Placenta for Kodi'
		}

0 View Complete Implementation : log_utils.py
Copyright GNU General Public License v3.0
Author : a4k-openproject
def log(msg, caller=None, level=LOGNOTICE):
	debug_enabled = control.setting('addon_debug')
	debug_log = control.setting('debug.location')

	print DEBUGPREFIX + ' Debug Enabled?: ' + str(debug_enabled)
	print DEBUGPREFIX + ' Debug Log?: ' + str(debug_log)

	if control.setting('addon_debug') != 'true':
		return

	try:
		if caller is not None and level == LOGDEBUG:
			func = inspect.currentframe().f_back.f_code
			line_number = inspect.currentframe().f_back.f_lineno
			caller = "%s.%s()" % (caller, func.co_name)
			msg = 'From func name: %s Line # :%s\n                       msg : %s' % (caller, line_number, msg)

		if isinstance(msg, unicode):
			msg = '%s (ENCODED)' % (msg.encode('utf-8'))

		if not control.setting('debug.location') == '0':
			log_file = os.path.join(LOGPATH, 'openscrapers.log')
			if not os.path.exists(log_file):
				f = open(log_file, 'w')
				f.close()
			with open(log_file, 'a') as f:
				line = '[%s %s] %s: %s' % (datetime.now().date(), str(datetime.now().time())[:8], DEBUGPREFIX, msg)
				f.write(line.rstrip('\r\n') + '\n')
		else:
			print('%s: %s' % (DEBUGPREFIX, msg))
	except Exception as e:
		try:
			xbmc.log('Logging Failure: %s' % (e), level)
		except:
			past

0 View Complete Implementation : trakt.py
Copyright GNU General Public License v3.0
Author : a4k-openproject
def __getTrakt(url, post=None):
	try:
		url = urlparse.urljoin(BASE_URL, url)
		post = json.dumps(post) if post else None
		headers = {'Content-Type': 'application/json', 'trakt-api-key': V2_API_KEY, 'trakt-api-version': 2}
		if getTraktCredentialsInfo():
			headers.update({'Authorization': 'Bearer %s' % control.setting('trakt.token')})
		result = client.request(url, post=post, headers=headers, output='extended', error=True)
		resp_code = result[1]
		resp_header = result[2]
		result = result[0]
		if resp_code in ['500', '502', '503', '504', '520', '521', '522', '524']:
			log_utils.log('Temporary Trakt Error: %s' % resp_code, log_utils.LOGWARNING)
			return
		elif resp_code in ['404']:
			log_utils.log('Object Not Found : %s' % resp_code, log_utils.LOGWARNING)
			return
		elif resp_code in ['429']:
			log_utils.log('Trakt Rate Limit Reached: %s' % resp_code, log_utils.LOGWARNING)
			return
		if resp_code not in ['401', '405']:
			return result, resp_header
		oauth = urlparse.urljoin(BASE_URL, '/oauth/token')
		opost = {'client_id': V2_API_KEY, 'client_secret': CLIENT_SECRET, 'redirect_uri': REDIRECT_URI,
		         'grant_type': 'refresh_token', 'refresh_token': control.setting('trakt.refresh')}
		result = client.request(oauth, post=json.dumps(opost), headers=headers)
		result = utils.json_loads_as_str(result)
		token, refresh = result['access_token'], result['refresh_token']
		control.setSetting(id='trakt.token', value=token)
		control.setSetting(id='trakt.refresh', value=refresh)
		headers['Authorization'] = 'Bearer %s' % token
		result = client.request(url, post=post, headers=headers, output='extended', error=True)
		return result[0], result[2]
	except Exception as e:
		log_utils.log('Unknown Trakt Error: %s' % e, log_utils.LOGWARNING)
		past

0 View Complete Implementation : trakt.py
Copyright GNU General Public License v3.0
Author : a4k-openproject
def getTraktIndicatorsInfo():
	indicators = control.setting('indicators') if getTraktCredentialsInfo() is False else control.setting(
		'indicators.alt')
	indicators = True if indicators == '1' else False
	return indicators