• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python json.loads函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中module.plugins.internal.utils.json.loads函数的典型用法代码示例。如果您正苦于以下问题:Python loads函数的具体用法?Python loads怎么用?Python loads使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了loads函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
开发者ID:johny149,项目名称:openmediavault-pyload,代码行数:35,代码来源:UploadingCom.py


示例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"))
开发者ID:johny149,项目名称:openmediavault-pyload,代码行数:59,代码来源:FilecloudIo.py


示例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"))
开发者ID:johny149,项目名称:openmediavault-pyload,代码行数:50,代码来源:RPNetBiz.py


示例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"))
开发者ID:johny149,项目名称:openmediavault-pyload,代码行数:31,代码来源:FileserveCom.py


示例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)
开发者ID:johny149,项目名称:openmediavault-pyload,代码行数:28,代码来源:RapidgatorNet.py


示例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)
开发者ID:johny149,项目名称:openmediavault-pyload,代码行数:30,代码来源:TransmissionRPC.py


示例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
开发者ID:johny149,项目名称:openmediavault-pyload,代码行数:31,代码来源:DailymotionCom.py


示例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
开发者ID:johny149,项目名称:openmediavault-pyload,代码行数:7,代码来源:SimplyPremiumCom.py


示例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
开发者ID:johny149,项目名称:openmediavault-pyload,代码行数:7,代码来源:NoPremiumPl.py


示例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"))
开发者ID:johny149,项目名称:openmediavault-pyload,代码行数:29,代码来源:YibaishiwuCom.py


示例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")
开发者ID:johny149,项目名称:openmediavault-pyload,代码行数:31,代码来源:YadiSk.py


示例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}
开发者ID:johny149,项目名称:openmediavault-pyload,代码行数:32,代码来源:LinksnappyCom.py


示例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()
开发者ID:johny149,项目名称:openmediavault-pyload,代码行数:27,代码来源:SoundcloudCom.py


示例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
开发者ID:johny149,项目名称:openmediavault-pyload,代码行数:7,代码来源:FastixRu.py


示例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)
开发者ID:johny149,项目名称:openmediavault-pyload,代码行数:8,代码来源:RPNetBiz.py


示例16: api_response

 def api_response(self, **kwargs):
     """
     Dispatch a call to the api, see megacrypter.com/api_doc
     """
     self.log_debug("JSON request: " + json.dumps(kwargs))
     res = self.load(self.API_URL, post=json.dumps(kwargs))
     self.log_debug("API Response: " + res)
     return json.loads(res)
开发者ID:johny149,项目名称:openmediavault-pyload,代码行数:8,代码来源:MegacrypterCom.py


示例17: get_json_response

    def get_json_response(self, *args, **kwargs):
        res = self.load(*args, **kwargs)
        if not res.startswith('{'):
            self.retry()

        self.log_debug(res)

        return json.loads(res)
开发者ID:johny149,项目名称:openmediavault-pyload,代码行数:8,代码来源:RapiduNet.py


示例18: signin

 def signin(self, user, password, data):
     jsonResponse = self.load(self.API_URL,
                              get={'action'  : 'connectUser',
                                   'login'   : user,
                                   'password': password})
     res = json.loads(jsonResponse)
     if res['response_code'] != "ok":
         self.fail_login()
开发者ID:johny149,项目名称:openmediavault-pyload,代码行数:8,代码来源:MegaDebridEu.py


示例19: signin

    def signin(self, user, password, data):
        jsondata = self.load("https://api.over-load.me/account.php",
                             get={'user': user,
                                  'auth': password}).strip()

        data = json.loads(jsondata)

        if data['err'] == 1:
            self.fail_login()
开发者ID:johny149,项目名称:openmediavault-pyload,代码行数:9,代码来源:OverLoadMe.py


示例20: handle_free

    def handle_free(self):
        self.data = self.load(self.url)
        action = self.load(self.url, post={'checkDownload': "check"})
        action = json.loads(action)
        self.log_debug(action)

        if "fail" in action:
            if action['fail'] == "timeLimit":
                self.data = self.load(self.url, post={'checkDownload': "showError", 'errorType': "timeLimit"})

                self.do_long_wait(re.search(self.LONG_WAIT_PATTERN, self.data))

            elif action['fail'] == "parallelDownload":
                self.log_warning(_("Parallel download error, now waiting 60s"))
                self.retry(wait=60, msg=_("parallelDownload"))

            else:
                self.fail(_("Download check returned: %s") % action['fail'])

        elif "success" in action:
            if action['success'] == "showCaptcha":
                self.do_captcha()
                self.do_timmer()
            elif action['success'] == "showTimmer":
                self.do_timmer()

        else:
            self.error(_("Unknown server response"))

        #: Show download link
        res = self.load(self.url, post={'downloadLink': "show"})
        self.log_debug("Show downloadLink response: %s" % res)
        if "fail" in res:
            self.error(_("Couldn't retrieve download url"))

        #: This may either download our file or forward us to an error page
        self.download(self.url, post={'download': "normal"})
        self.log_debug(self.req.http.lastEffectiveURL)

        check = self.check_file({'expired': self.LINK_EXPIRED_PATTERN,
                                    'wait'   : re.compile(self.LONG_WAIT_PATTERN),
                                    'limit'  : self.DL_LIMIT_PATTERN})

        if check == "expired":
            self.log_debug("Download link was expired")
            self.retry()

        elif check == "wait":
            self.do_long_wait(self.last_check)

        elif check == "limit":
            self.log_warning(_("Download limited reached for today"))
            self.wait(seconds_to_midnight(), True)
            self.retry()

        self.thread.m.reconnecting.wait(3)  #: Ease issue with later downloads appearing to be in parallel
开发者ID:johny149,项目名称:openmediavault-pyload,代码行数:56,代码来源:FileserveCom.py



注:本文中的module.plugins.internal.utils.json.loads函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python utils.fs_encode函数代码示例发布时间:2022-05-27
下一篇:
Python json.loads函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap