本文整理汇总了Python中module.plugins.internal.misc.json.loads函数的典型用法代码示例。如果您正苦于以下问题:Python loads函数的具体用法?Python loads怎么用?Python loads使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了loads函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: grab_hosters
def grab_hosters(self, user, password, data):
html = self.load("http://fastix.ru/api_v2",
get={'apikey': "5182964c3f8f9a7f0b00000a_kelmFB4n1IrnCDYuIFn2y",
'sub' : "allowed_sources"})
host_list = json.loads(html)
host_list = host_list['allow']
return host_list
示例2: get_json_response
def get_json_response(self, get_dict, post_dict, field):
html = self.load('https://filepost.com/files/get/', get=get_dict, post=post_dict)
res = json.loads(html)
self.log_debug(res)
if not 'js' in res:
self.error(_("JSON %s 1") % field)
#: I changed js_answer to res['js'] since js_answer is nowhere set.
#: I don't know the JSON-HTTP specs in detail, but the previous author
#: Accessed res['js']['error'] as well as js_answer['error'].
#: See the two lines commented out with "# ~?".
if 'error' in res['js']:
if res['js']['error'] == "download_delay":
self.retry(wait=res['js']['params']['next_download'])
#: ~? self.retry(wait=js_answer['params']['next_download'])
elif 'Wrong file password' in res['js']['error'] \
or 'You entered a wrong CAPTCHA code' in res['js']['error'] \
or 'CAPTCHA Code nicht korrekt' in res['js']['error']:
return None
elif 'CAPTCHA' in res['js']['error']:
self.log_debug("Error response is unknown, but mentions CAPTCHA")
return None
else:
self.fail(res['js']['error'])
if not 'answer' in res['js'] or not field in res['js']['answer']:
self.error(_("JSON %s 2") % field)
return res['js']['answer'][field]
示例3: grab_hosters
def grab_hosters(self, user, password, data):
json_data = self.load("http://www.simply-premium.com/api/hosts.php", get={'format': "json", 'online': 1})
json_data = json.loads(json_data)
host_list = [element['regex'] for element in json_data['result']]
return host_list
示例4: get_info
def get_info(cls, url="", html=""):
info = super(YadiSk, cls).get_info(url, html)
if html:
if 'idclient' not in info:
info['idclient'] = ""
for _i in xrange(32):
info ['idclient'] += random.choice('0123456abcdef')
m = re.search(r'<script id="models-client" type="application/json">(.+?)</script>', html)
if m is not None:
api_data = json.loads(m.group(1))
try:
for sect in api_data:
if 'model' in sect:
if sect['model'] == "config":
info['version'] = sect['data']['version']
info['sk'] = sect['data']['sk']
elif sect['model'] == "resource":
info['id'] = sect['data']['id']
info['size'] = sect['data']['meta']['size']
info['name'] = sect['data']['name']
except Exception, e:
info['status'] = 8
info['error'] = _("Unexpected server response: %s") % e.message
else:
info['status'] = 8
info['error'] = _("could not find required json data")
示例5: decrypt
def decrypt(self, pyfile):
url, result = self._get_url(pyfile.url)
self.log_debug("Location (%d): %s" % (result, url))
if result == 0:
#: Load and parse html
html = self.load(pyfile.url)
m = re.search(self.LINK_PATTERN, html)
if m is not None:
#: File page
self.links.append("http://www.mediafire.com/file/%s" % m.group(1))
else:
#: Folder page
m = re.search(self.FOLDER_KEY_PATTERN, html)
if m is not None:
folder_key = m.group(1)
self.log_debug("FOLDER KEY: %s" % folder_key)
html = self.load("http://www.mediafire.com/api/folder/get_info.php",
get={'folder_key' : folder_key,
'response_format': "json",
'version' : 1})
json_data = json.loads(html)
# self.log_info(json_data)
if json_data['response']['result'] == "Success":
for link in json_data['response']['folder_info']['files']:
self.links.append("http://www.mediafire.com/file/%s" % link['quickkey'])
else:
self.fail(json_data['response']['message'])
elif result == 1:
self.offline()
else:
self.links.append(url)
示例6: send_to_transmission
def send_to_transmission(self, url):
transmission_rpc_url = self.config.get('rpc_url')
client_request_id = self.classname + "".join(random.choice('0123456789ABCDEF') for _i in xrange(4))
req = get_request()
try:
response = self.load(transmission_rpc_url,
post=json.dumps({'arguments': {'filename': url},
'method' : 'torrent-add',
'tag' : client_request_id}),
req=req)
except Exception, e:
if isinstance(e, BadHeader) and e.code == 409:
headers = dict(re.findall(r'(?P<name>.+?): (?P<value>.+?)\r?\n', req.header))
session_id = headers['X-Transmission-Session-Id']
req.c.setopt(pycurl.HTTPHEADER, ["X-Transmission-Session-Id: %s" % session_id])
try:
response = self.load(transmission_rpc_url,
post=json.dumps({'arguments': {'filename': url},
'method' : 'torrent-add',
'tag' : client_request_id}),
req=req)
res = json.loads(response)
if "result" in res:
self.log_debug("Result: %s" % res['result'])
except Exception, e:
self.log_error(e)
示例7: handle_premium
def handle_premium(self):
premium_url = None
if self.__name__ == "FileserveCom":
#: Try api download
res = self.load("http://app.fileserve.com/api/download/premium/",
post={'username': self.account.user,
'password': self.account.get_login('password'),
'shorten': self.file_id})
if res:
res = json.loads(res)
if res['error_code'] == "302":
premium_url = res['next']
elif res['error_code'] in ["305", "500"]:
self.temp_offline()
elif res['error_code'] in ["403", "605"]:
self.restart(premium=False)
elif res['error_code'] in ["606", "607", "608"]:
self.offline()
else:
self.log_error(res['error_code'], res['error_message'])
self.download(premium_url or self.pyfile.url)
if not premium_url and \
self.scan_download({'login': re.compile(self.NOT_LOGGED_IN_PATTERN)}):
self.account.relogin()
self.retry(msg=_("Not logged in"))
示例8: grab_info
def grab_info(self, user, password, data):
r = self.load('http://gen.linksnappy.com/lseAPI.php',
get={'act' : 'USERDETAILS',
'username': user,
'password': hashlib.md5(password).hexdigest()})
self.log_debug("JSON data: " + r)
j = json.loads(r)
if j['error']:
return {'premium': False}
validuntil = j['return']['expire']
if validuntil == "lifetime":
validuntil = -1
elif validuntil == "expired":
return {'premium': False}
else:
validuntil = float(validuntil)
if 'trafficleft' not in j['return'] or isinstance(j['return']['trafficleft'], str):
trafficleft = -1
else:
trafficleft = self.parse_traffic(j['return']['trafficleft'], "MB")
return {'premium' : True ,
'validuntil' : validuntil ,
'trafficleft': trafficleft}
示例9: signin
def signin(self, user, password, data):
data = json.loads(self.load("https://nitroflare.com/api/v2/getKeyInfo",
get={'user' : user,
'premiumKey': password}))
if data['type'] != 'success' or data['result']['status'] == "banned":
self.fail_login()
示例10: signin
def signin(self, user, password, data):
try:
html = self.load(urlparse.urljoin(self.API_URL, "login"),
post={'username': user,
'password': password})
self.log_debug("API:LOGIN", html)
json_data = json.loads(html)
if json_data['response_status'] == 200:
data['sid'] = str(json_data['response']['session_id'])
if 'reset_in' in json_data['response']:
self.timeout = float(json_data['response']['reset_in'])
self.TUNE_TIMEOUT = False
else:
self.TUNE_TIMEOUT = True
return
else:
self.log_error(json_data['response_details'])
except Exception, e:
self.log_error(e, trace=True)
示例11: handle_free
def handle_free(self, pyfile):
m = re.search(self.LINK_FREE_PATTERN, self.data)
if m is None:
self.error(_("LINK_FREE_PATTERN not found"))
url = m.group(1)
self.log_debug(('FREEUSER' if m.group(2) == "download" else 'GUEST') + ' URL', url)
html = self.load(urlparse.urljoin("http://115.com/", url), decode=False)
res = json.loads(html)
if "urls" in res:
mirrors = res['urls']
elif "data" in res:
mirrors = res['data']
else:
mirrors = None
for mr in mirrors:
try:
self.link = mr['url'].replace("\\", "")
self.log_debug("Trying URL: " + self.link)
break
except Exception:
pass
else:
self.fail(_("No working link found"))
示例12: grab_info
def grab_info(self, user, password, data):
validuntil = None
trafficleft = None
premium = False
sid = None
try:
sid = data.get('sid', None)
html = self.load(urlparse.urljoin(self.API_URL, "info"),
get={'sid': sid})
self.log_debug("API:USERINFO", html)
json_data = json.loads(html)
if json_data['response_status'] == 200:
validuntil = json_data['response']['expire_date']
trafficleft = float(json_data['response']['traffic_left']) / 1024 #@TODO: Remove `/ 1024` in 0.4.10
premium = True
else:
self.log_error(json_data['response_details'])
except Exception, e:
self.log_error(e, trace=True)
示例13: get_info
def get_info(urls):
result = []
regex = re.compile(DailymotionCom.__pattern__)
apiurl = "https://api.dailymotion.com/video/%s"
request = {'fields': "access_error,status,title"}
for url in urls:
id = regex.match(url).group('ID')
html = get_url(apiurl % id, get=request)
info = json.loads(html)
name = info['title'] + ".mp4" if "title" in info else url
if "error" in info or info['access_error']:
status = "offline"
else:
status = info['status']
if status in ("ready", "published"):
status = "online"
elif status in ("waiting", "processing"):
status = "temp. offline"
else:
status = "offline"
result.append((name, 0, statusMap[status], url))
return result
示例14: handle_free
def handle_free(self, pyfile):
try:
song_id = re.search(r'sounds:(\d+)"', self.data).group(1)
except Exception:
self.error(_("Could not find song id"))
try:
client_id = re.search(r'"clientID":"(.+?)"', self.data).group(1)
except Exception:
client_id = "02gUJC0hH2ct1EGOcYXQIzRFU91c72Ea"
#: Url to retrieve the actual song url
html = self.load("https://api.soundcloud.com/tracks/%s/streams" % song_id,
get={'client_id': client_id})
streams = json.loads(html)
regex = re.compile(r'[^\d]')
http_streams = sorted([(key, value) for key, value in streams.items() if key.startswith('http_')],
key=lambda t: regex.sub(t[0], ''),
reverse=True)
self.log_debug("Streams found: %s" % (http_streams or "None"))
if http_streams:
stream_name, self.link = http_streams[0 if self.config.get('quality') == "Higher" else -1]
pyfile.name += '.' + stream_name.split('_')[1].lower()
示例15: handle_free
def handle_free(self, pyfile):
action, inputs = self.parse_html_form('id="ifree_form"')
if not action:
self.error(_("Form not found"))
pyfile.size = float(inputs['sssize'])
self.log_debug(action, inputs)
inputs['desc'] = ""
self.data = self.load(urlparse.urljoin("http://letitbit.net/", action), post=inputs)
m = re.search(self.SECONDS_PATTERN, self.data)
seconds = int(m.group(1)) if m else 60
self.log_debug("Seconds found", seconds)
m = re.search(self.CAPTCHA_CONTROL_FIELD, self.data)
recaptcha_control_field = m.group(1)
self.log_debug("ReCaptcha control field found", recaptcha_control_field)
self.wait(seconds)
res = self.load("http://letitbit.net/ajax/download3.php", post=" ")
if res != '1':
self.error(_("Unknown response - ajax_check_url"))
self.log_debug(res)
self.captcha = ReCaptcha(pyfile)
response, challenge = self.captcha.challenge()
post_data = {'recaptcha_challenge_field': challenge,
'recaptcha_response_field': response,
'recaptcha_control_field': recaptcha_control_field}
self.log_debug("Post data to send", post_data)
res = self.load("http://letitbit.net/ajax/check_recaptcha.php", post=post_data)
self.log_debug(res)
if not res or res == "error_wrong_captcha":
self.retry_captcha()
elif res == "error_free_download_blocked":
self.log_warning(_("Daily limit reached"))
self.wait(seconds_to_midnight(), True)
elif res.startswith('['):
urls = json.loads(res)
elif res.startswith('http://'):
urls = [res]
else:
self.error(_("Unknown response - captcha check"))
self.link = urls[0]