本文整理汇总了Python中module.plugins.internal.utils.json.loads函数的典型用法代码示例。如果您正苦于以下问题:Python loads函数的具体用法?Python loads怎么用?Python loads使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了loads函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handle_free
def handle_free(self, pyfile):
m = re.search('<h2>((Daily )?Download Limit)</h2>', self.data)
if m is not None:
pyfile.error = encode(m.group(1))
self.log_warning(pyfile.error)
self.retry(6, (6 * 60 if m.group(2) else 15) * 60, pyfile.error)
ajax_url = "http://uploading.com/files/get/?ajax"
self.req.http.c.setopt(pycurl.HTTPHEADER, ["X-Requested-With: XMLHttpRequest"])
self.req.http.lastURL = pyfile.url
res = json.loads(self.load(ajax_url, post={'action': 'second_page', 'code': self.info['pattern']['ID']}))
if 'answer' in res and 'wait_time' in res['answer']:
wait_time = int(res['answer']['wait_time'])
self.log_info(_("Waiting %d seconds") % wait_time)
self.wait(wait_time)
else:
self.error(_("No AJAX/WAIT"))
res = json.loads(self.load(ajax_url, post={'action': 'get_link', 'code': self.info['pattern']['ID'], 'pass': 'false'}))
if 'answer' in res and 'link' in res['answer']:
url = res['answer']['link']
else:
self.error(_("No AJAX/URL"))
self.data = self.load(url)
m = re.search(r'<form id="file_form" action="(.*?)"', self.data)
if m is not None:
url = m.group(1)
else:
self.error(_("No URL"))
self.link = url
示例2: handle_free
def handle_free(self, pyfile):
data = {'ukey': self.info['pattern']['ID']}
m = re.search(self.AB1_PATTERN, self.data)
if m is None:
self.error(_("__AB1"))
data['__ab1'] = m.group(1)
recaptcha = ReCaptcha(self)
m = re.search(self.RECAPTCHA_PATTERN, self.data)
captcha_key = m.group(1) if m else recaptcha.detect_key()
if captcha_key is None:
self.error(_("ReCaptcha key not found"))
response, challenge = recaptcha.challenge(captcha_key)
self.account.form_data = {'recaptcha_challenge_field': challenge,
'recaptcha_response_field' : response}
self.account.relogin()
self.retry(2)
json_url = "http://filecloud.io/download-request.json"
res = self.load(json_url, post=data)
self.log_debug(res)
res = json.loads(res)
if "error" in res and res['error']:
self.fail(res)
self.log_debug(res)
if res['captcha']:
data['ctype'] = "recaptcha"
data['recaptcha_response'], data['recaptcha_challenge'] = recaptcha.challenge(captcha_key)
json_url = "http://filecloud.io/download-request.json"
res = self.load(json_url, post=data)
self.log_debug(res)
res = json.loads(res)
if "retry" in res and res['retry']:
self.retry_captcha()
else:
self.captcha.correct()
if res['dl']:
self.data = self.load('http://filecloud.io/download.html')
m = re.search(self.LINK_FREE_PATTERN % self.info['pattern']['ID'], self.data)
if m is None:
self.error(_("LINK_FREE_PATTERN not found"))
if "size" in self.info and self.info['size']:
self.check_data = {'size': int(self.info['size'])}
self.link = m.group(1)
else:
self.fail(_("Unexpected server response"))
示例3: handle_premium
def handle_premium(self, pyfile):
user, info = self.account.select()
res = self.load("https://premium.rpnet.biz/client_api.php",
get={'username': user,
'password': info['login']['password'],
'action' : "generate",
'links' : pyfile.url})
self.log_debug("JSON data: %s" % res)
link_status = json.loads(res)['links'][0] #: Get the first link... since we only queried one
#: Check if we only have an id as a HDD link
if 'id' in link_status:
self.log_debug("Need to wait at least 30 seconds before requery")
self.wait(30) #: Wait for 30 seconds
#: Lets query the server again asking for the status on the link,
#: We need to keep doing this until we reach 100
attemps = 30
my_try = 0
while (my_try <= attemps):
self.log_debug("Try: %d ; Max Tries: %d" % (my_try, attemps))
res = self.load("https://premium.rpnet.biz/client_api.php",
get={'username': user,
'password': info['login']['password'],
'action' : "downloadInformation",
'id' : link_status['id']})
self.log_debug("JSON data hdd query: %s" % res)
download_status = json.loads(res)['download']
if download_status['status'] == "100":
link_status['generated'] = download_status['rpnet_link']
self.log_debug("Successfully downloaded to rpnet HDD: %s" % link_status['generated'])
break
else:
self.log_debug("At %s%% for the file download" % download_status['status'])
self.wait(30)
my_try += 1
if my_try > attemps: #: We went over the limit!
self.fail(_("Waited for about 15 minutes for download to finish but failed"))
if 'generated' in link_status:
self.link = link_status['generated']
return
elif 'error' in link_status:
self.fail(link_status['error'])
else:
self.fail(_("Something went wrong, not supposed to enter here"))
示例4: 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.check_file({'login': re.compile(self.NOT_LOGGED_IN_PATTERN)}):
self.account.relogin()
self.retry(msg=_("Not logged in"))
示例5: 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)
jso = json.loads(html)
if jso['response_status'] == 200:
if "reset_in" in jso['response']:
self._schedule_refresh(user, jso['response']['reset_in'])
validuntil = jso['response']['expire_date']
trafficleft = float(jso['response']['traffic_left']) / 1024 #@TODO: Remove `/ 1024` in 0.4.10
premium = True
else:
self.log_error(jso['response_details'])
except Exception, e:
self.log_error(e, trace=True)
示例6: send_to_transmission
def send_to_transmission(self, url):
transmission_rpc_url = self.get_config('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: 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
示例8: 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
示例9: grab_hosters
def grab_hosters(self, user, password, data):
hostings = json.loads(self.load("https://www.nopremium.pl/clipboard.php?json=3").strip())
hostings_domains = [domain for row in hostings for domain in row['domains'] if row['sdownload'] == "0"]
self.log_debug(hostings_domains)
return hostings_domains
示例10: 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)
res = json.loads(self.load(urlparse.urljoin("http://115.com/", url), decode=False))
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"))
示例11: 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")
示例12: 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}
示例13: 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 = "b45b1aa10f1ac2941910a7f0d10f8e28"
#: Url to retrieve the actual song url
streams = json.loads(self.load("https://api.soundcloud.com/tracks/%s/streams" % song_id,
get={'client_id': client_id}))
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.get_config('quality') == "Higher" else -1]
pyfile.name += '.' + stream_name.split('_')[1].lower()
示例14: 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
示例15: get_account_status
def get_account_status(self, user, password):
#: Using the rpnet API, check if valid premium account
res = self.load("https://premium.rpnet.biz/client_api.php",
get={'username': user, 'password': password,
'action': "showAccountInformation"})
self.log_debug("JSON data: %s" % res)
return json.loads(res)