当前位置: 首页>>代码示例>>Python>>正文


Python json_layer.json_loads函数代码示例

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


在下文中一共展示了json_loads函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: handleFree

    def handleFree(self):
        found = re.search(self.WAIT_PATTERN, self.html)
        seconds = int(found.group(1))
        self.logDebug("Found wait", seconds)
        self.setWait(seconds + 1)
        self.wait()
        response = self.load('http://cloudzer.net/io/ticket/slot/%s' % self.file_info['ID'], post=' ', cookies=True)
        self.logDebug("Download slot request response", response)
        response = json_loads(response)
        if response["succ"] is not True:
            self.fail("Unable to get a download slot")

        recaptcha = ReCaptcha(self)
        challenge, response = recaptcha.challenge(self.CAPTCHA_KEY)
        post_data = {"recaptcha_challenge_field": challenge, "recaptcha_response_field": response}
        response = json_loads(self.load('http://cloudzer.net/io/ticket/captcha/%s' % self.file_info['ID'], post=post_data, cookies=True))
        self.logDebug("Captcha check response", response)
        self.logDebug("First check")

        if "err" in response:
            if response["err"] == "captcha":
                self.logDebug("Wrong captcha")
                self.invalidCaptcha()
                self.retry()
            elif "Sie haben die max" in response["err"] or "You have reached the max" in response["err"]:
                self.logDebug("Download limit reached, waiting an hour")
                self.setWait(3600, True)
                self.wait()
        if "type" in response:
            if response["type"] == "download":
                url = response["url"]
                self.logDebug("Download link", url)
                self.download(url, disposition=True)
开发者ID:AlexandrePinheiro,项目名称:pyload,代码行数:33,代码来源:CloudzerNet.py

示例2: handleFree

    def handleFree(self):
        ukey = re.search(self.__pattern__, self.pyfile.url).group(1)
        json_url = "http://ifile.it/new_download-request.json"
        post_data = {"ukey": ukey, "ab": "0"}

        json_response = json_loads(self.load(json_url, post=post_data))
        self.logDebug(json_response)
        if json_response["status"] == 3:
            self.offline()

        if json_response["captcha"]:
            captcha_key = re.search(self.RECAPTCHA_KEY_PATTERN, self.html).group(1)
            recaptcha = ReCaptcha(self)
            post_data["ctype"] = "recaptcha"

            for i in range(5):
                post_data["recaptcha_challenge"], post_data["recaptcha_response"] = recaptcha.challenge(captcha_key)
                json_response = json_loads(self.load(json_url, post=post_data))
                self.logDebug(json_response)

                if json_response["retry"]:
                    self.invalidCaptcha()
                else:
                    self.correctCaptcha()
                    break
            else:
                self.fail("Incorrect captcha")

        if not "ticket_url" in json_response:
            self.parseError("Download URL")

        self.download(json_response["ticket_url"])
开发者ID:tetratec,项目名称:shareacc,代码行数:32,代码来源:IfileIt.py

示例3: challenge

    def challenge(self, html):
        adyoulike_data_string = None
        found = re.search(self.ADYOULIKE_INPUT_PATTERN, html)
        if found:
            adyoulike_data_string = found.group(1)
        else:
            self.plugin.fail("Can't read AdYouLike input data")

        # {"adyoulike":{"key":"P~zQ~O0zV0WTiAzC-iw0navWQpCLoYEP"},
        # "all":{"element_id":"ayl_private_cap_92300","lang":"fr","env":"prod"}}
        ayl_data = json_loads(adyoulike_data_string)

        res = self.plugin.load(
            r'http://api-ayl.appspot.com/challenge?key=%(ayl_key)s&env=%(ayl_env)s&callback=%(callback)s' % {
            "ayl_key": ayl_data[self.engine]["key"], "ayl_env": ayl_data["all"]["env"],
            "callback": self.ADYOULIKE_CALLBACK})

        found = re.search(self.ADYOULIKE_CHALLENGE_PATTERN, res)
        challenge_string = None
        if found:
            challenge_string = found.group(1)
        else:
            self.plugin.fail("Invalid AdYouLike challenge")
        challenge_data = json_loads(challenge_string)

        return ayl_data, challenge_data
开发者ID:DasLampe,项目名称:pyload,代码行数:26,代码来源:DlFreeFr.py

示例4: result

    def result(self, server, challenge):
        # Adyoulike.g._jsonp_5579316662423138
        # ({"translations":{"fr":{"instructions_visual":"Recopiez « Soonnight » ci-dessous :"}},
        # "site_under":true,"clickable":true,"pixels":{"VIDEO_050":[],"DISPLAY":[],"VIDEO_000":[],"VIDEO_100":[],
        # "VIDEO_025":[],"VIDEO_075":[]},"medium_type":"image/adyoulike",
        # "iframes":{"big":"<iframe src=\"http://www.soonnight.com/campagn.html\" scrolling=\"no\"
        # height=\"250\" width=\"300\" frameborder=\"0\"></iframe>"},"shares":{},"id":256,
        # "token":"e6QuI4aRSnbIZJg02IsV6cp4JQ9~MjA1","formats":{"small":{"y":300,"x":0,"w":300,"h":60},
        # "big":{"y":0,"x":0,"w":300,"h":250},"hover":{"y":440,"x":0,"w":300,"h":60}},
        # "tid":"SqwuAdxT1EZoi4B5q0T63LN2AkiCJBg5"})

        if isinstance(server, basestring):
            server = json_loads(server)

        if isinstance(challenge, basestring):
            challenge = json_loads(challenge)

        try:
            instructions_visual = challenge['translations'][server['all']['lang']]['instructions_visual']
            result = re.search(u'«(.+?)»', instructions_visual).group(1).strip()

        except AttributeError:
            errmsg = _("AdYouLike result not found")
            self.plugin.fail(errmsg)
            raise AttributeError(errmsg)

        result = {'_ayl_captcha_engine' : "adyoulike",
                  '_ayl_env'            : server['all']['env'],
                  '_ayl_tid'            : challenge['tid'],
                  '_ayl_token_challenge': challenge['token'],
                  '_ayl_response'       : response}

        self.logDebug("Result: %s" % result)

        return result
开发者ID:kurtiss,项目名称:htpc,代码行数:35,代码来源:CaptchaService.py

示例5: handle_free

    def handle_free(self, pyfile):
        m = re.search('<h2>((Daily )?Download Limit)</h2>', self.html)
        if m:
            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.html = self.load(url)
        m = re.search(r'<form id="file_form" action="(.*?)"', self.html)
        if m:
            url = m.group(1)
        else:
            self.error(_("No URL"))

        self.link = url
开发者ID:earthGavinLee,项目名称:pyload,代码行数:35,代码来源:UploadingCom.py

示例6: challenge

    def challenge(self, key=None, html=None):
        if not key:
            if self.detect_key(html):
                key = self.key
            else:
                errmsg = _("AdYouLike key not found")
                self.plugin.fail(errmsg)
                raise TypeError(errmsg)

        ayl, callback = key

        # {"adyoulike":{"key":"P~zQ~O0zV0WTiAzC-iw0navWQpCLoYEP"},
        # "all":{"element_id":"ayl_private_cap_92300","lang":"fr","env":"prod"}}
        ayl = json_loads(ayl)

        html = self.plugin.req.load("http://api-ayl.appspot.com/challenge",
                                    get={'key'     : ayl['adyoulike']['key'],
                                         'env'     : ayl['all']['env'],
                                         'callback': callback})
        try:
            challenge = json_loads(re.search(callback + r'\s*\((.+?)\)', html).group(1))

        except AttributeError:
            errmsg = _("AdYouLike challenge pattern not found")
            self.plugin.fail(errmsg)
            raise AttributeError(errmsg)

        self.logDebug("Challenge: %s" % challenge)

        return self.result(ayl, challenge), challenge
开发者ID:kurtiss,项目名称:htpc,代码行数:30,代码来源:CaptchaService.py

示例7: result

    def result(self, server, challenge):
        #: Adyoulike.g._jsonp_5579316662423138
        #: ({'translations':{'fr':{'instructions_visual':"Recopiez « Soonnight » ci-dessous :"}},
        #: 'site_under':true,'clickable':true,'pixels':{'VIDEO_050':[],'DISPLAY':[],'VIDEO_000':[],'VIDEO_100':[],
        #: 'VIDEO_025':[],'VIDEO_075':[]},'medium_type':"image/adyoulike",
        #: 'iframes':{'big':"<iframe src=\"http://www.soonnight.com/campagn.html\" scrolling=\"no\"
        #: height=\"250\" width=\"300\" frameborder=\"0\"></iframe>"},'shares':{},'id':256,
        #: 'token':"e6QuI4aRSnbIZJg02IsV6cp4JQ9~MjA1",'formats':{'small':{'y':300,'x':0,'w':300,'h':60},
        #: 'big':{'y':0,'x':0,'w':300,'h':250},'hover':{'y':440,'x':0,'w':300,'h':60}},
        #: 'tid':"SqwuAdxT1EZoi4B5q0T63LN2AkiCJBg5"})

        if isinstance(server, basestring):
            server = json_loads(server)

        if isinstance(challenge, basestring):
            challenge = json_loads(challenge)

        try:
            instructions_visual = challenge['translations'][server['all']['lang']]['instructions_visual']
            result = re.search(u'«(.+?)»', instructions_visual).group(1).strip()

        except AttributeError:
            self.fail(_("AdYouLike result not found"))

        result = {'_ayl_captcha_engine' : "adyoulike",
                  '_ayl_env'            : server['all']['env'],
                  '_ayl_tid'            : challenge['tid'],
                  '_ayl_token_challenge': challenge['token'],
                  '_ayl_response'       : response}

        self.log_debug("Result: %s" % result)

        return result
开发者ID:earthGavinLee,项目名称:pyload,代码行数:33,代码来源:AdYouLike.py

示例8: process

    def process(self, pyfile):

        if re.match(self.__pattern__, pyfile.url):
            link_status = {'generated': pyfile.url}
        elif not self.account:
            # Check account
            self.logError(_("Please enter your %s account or deactivate this plugin") % "rpnet")
            self.fail("No rpnet account provided")
        else:
            (user, data) = self.account.selectAccount()

            self.logDebug("Original URL: %s" % pyfile.url)
            # Get the download link 
            response = self.load("https://premium.rpnet.biz/client_api.php",
                                 get={"username": user, "password": data['password'],
                                      "action": "generate", "links": self.pyfile.url})

            self.logDebug("JSON data: %s" % response)
            link_status = json_loads(response)['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.logDebug("Need to wait at least 30 seconds before requery")
                self.setWait(30)  # wait for 30 seconds
                self.wait()
                # Lets query the server again asking for the status on the link,
                # we need to keep doing this until we reach 100
                max_tries = 30
                my_try = 0
                while (my_try <= max_tries):
                    self.logDebug("Try: %d ; Max Tries: %d" % (my_try, max_tries))
                    response = self.load("https://premium.rpnet.biz/client_api.php",
                                         get={"username": user, "password": data['password'],
                                              "action": "downloadInformation", "id": link_status['id']})
                    self.logDebug("JSON data hdd query: %s" % response)
                    download_status = json_loads(response)['download']

                    if download_status['status'] == '100':
                        link_status['generated'] = download_status['rpnet_link']
                        self.logDebug("Successfully downloaded to rpnet HDD: %s" % link_status['generated'])
                        break
                    else:
                        self.logDebug("At %s%% for the file download" % download_status['status'])

                    self.setWait(30)
                    self.wait()
                    my_try += 1

                if my_try > max_tries:  # We went over the limit!
                    self.fail("Waited for about 15 minutes for download to finish but failed")

        if 'generated' in link_status:
            self.download(link_status['generated'], disposition=True)
        elif 'error' in link_status:
            self.fail(link_status['error'])
        else:
            self.fail("Something went wrong, not supposed to enter here")
开发者ID:BlackSmith,项目名称:pyload,代码行数:57,代码来源:RPNetBiz.py

示例9: handle_premium

    def handle_premium(self, pyfile):
        user, info = self.account.select()

        #: Get the download link
        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
            max_tries = 30
            my_try = 0
            while (my_try <= max_tries):
                self.log_debug("Try: %d ; Max Tries: %d" % (my_try, max_tries))
                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 > max_tries:  #: 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:earthGavinLee,项目名称:pyload,代码行数:51,代码来源:RPNetBiz.py

示例10: api_response

    def api_response(self, api="captcha", post=False, multipart=False):
        req = getRequest()
        req.c.setopt(HTTPHEADER, ["Accept: application/json", "User-Agent: pyLoad %s" % self.core.version])

        if post:
            if not isinstance(post, dict):
                post = {}
            post.update({"username": self.getConfig("username"),
                         "password": self.getConfig("passkey")})

        res = None
        try:
            json = req.load("%s%s" % (self.API_URL, api),
                            post=post,
                            multipart=multipart)
            self.logDebug(json)
            res = json_loads(json)

            if "error" in res:
                raise DeathByCaptchaException(res['error'])
            elif "status" not in res:
                raise DeathByCaptchaException(str(res))

        except BadHeader, e:
            if 403 == e.code:
                raise DeathByCaptchaException('not-logged-in')
            elif 413 == e.code:
                raise DeathByCaptchaException('invalid-captcha')
            elif 503 == e.code:
                raise DeathByCaptchaException('service-overload')
            elif e.code in (400, 405):
                raise DeathByCaptchaException('invalid-request')
            else:
                raise
开发者ID:kurtiss,项目名称:htpc,代码行数:34,代码来源:DeathByCaptcha.py

示例11: get_json_response

    def get_json_response(self, get_dict, post_dict, field):
        res = json_loads(self.load('https://filepost.com/files/get/', get=get_dict, post=post_dict))

        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_time=res['js']['params']['next_download'])
                #: ~? self.retry(wait_time=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]
开发者ID:earthGavinLee,项目名称:pyload,代码行数:34,代码来源:FilepostCom.py

示例12: process

    def process(self, pyfile):
        if re.match(self.__pattern__, pyfile.url):
            new_url = pyfile.url
        elif not self.account:
            self.logError(_("Please enter your %s account or deactivate this plugin") % "Fastix")
            self.fail("No Fastix account provided")
        else:
            self.logDebug("Old URL: %s" % pyfile.url)
            api_key = self.account.getAccountData(self.user)
            api_key = api_key["api"]
            url = "http://fastix.ru/api_v2/?apikey=%s&sub=getdirectlink&link=%s" % (api_key, pyfile.url)
            page = self.load(url)
            data = json_loads(page)
            self.logDebug("Json data: %s" % str(data))
            if "error\":true" in page:
                self.offline()
            else:
                new_url = data["downloadlink"]

        if new_url != pyfile.url:
            self.logDebug("New URL: %s" % new_url)

        if pyfile.name.startswith("http") or pyfile.name.startswith("Unknown"):
            #only use when name wasnt already set
            pyfile.name = self.getFilename(new_url)

        self.download(new_url, disposition=True)

        check = self.checkDownload({"error": "<title>An error occurred while processing your request</title>",
                                    "empty": re.compile(r"^$")})

        if check == "error":
            self.retry(reason="An error occurred while generating link.", wait_time=60)
        elif check == "empty":
            self.retry(reason="Downloaded File was empty.", wait_time=60)
开发者ID:BlackSmith,项目名称:pyload,代码行数:35,代码来源:FastixRu.py

示例13: getJsonResponse

 def getJsonResponse(self, get_dict, post_dict, field):     
     json_response = json_loads(self.load('https://filepost.com/files/get/', get = get_dict, post = post_dict))
     self.logDebug(json_response)
     
     if not 'js' in json_response: self.parseError('JSON %s 1' % field)       
     
     # i changed js_answer to json_response['js'] since js_answer is nowhere set.
     # i don't know the JSON-HTTP specs in detail, but the previous author
     # accessed json_response['js']['error'] as well as js_answer['error'].
     # see the two lines commented out with  "# ~?".
     if 'error' in json_response['js']:
         if json_response['js']['error'] == 'download_delay':
             self.retry(json_response['js']['params']['next_download'])
             # ~? self.retry(js_answer['params']['next_download'])
         elif 'Wrong file password' in json_response['js']['error']:
             return None 
         elif 'You entered a wrong CAPTCHA code' in json_response['js']['error']:
             return None  
         elif 'CAPTCHA Code nicht korrekt' in json_response['js']['error']:
             return None
         elif 'CAPTCHA' in json_response['js']['error']:
             self.logDebug('error response is unknown, but mentions CAPTCHA -> return None')
             return None
         else:
             self.fail(json_response['js']['error'])
             # ~? self.fail(js_answer['error'])
     
     if not 'answer' in json_response['js'] or not field in json_response['js']['answer']: 
         self.parseError('JSON %s 2' % field)
         
     return json_response['js']['answer'][field]
开发者ID:4Christopher,项目名称:pyload,代码行数:31,代码来源:FilepostCom.py

示例14: do_recaptcha

    def do_recaptcha(self):
        self.logDebug('Trying to solve captcha')
        captcha_key = re.search(self.CAPTCHA_KEY_PATTERN, self.html).group(1)
        shortencode = re.search(self.CAPTCHA_SHORTENCODE_PATTERN, self.html).group(1)
        url = re.search(self.CAPTCHA_DOWNLOAD_PATTERN, self.html).group(1)

        recaptcha = ReCaptcha(self)

        for i in range(5):
            challenge, code = recaptcha.challenge(captcha_key)

            response = json_loads(self.load(self.file_info['HOST'] + '/rest/captcha/test',
                                            post={'challenge': challenge,
                                                  'response': code,
                                                  'shortencode': shortencode}))
            self.logDebug("reCaptcha response : %s" % response)
            if response == True:
                self.correctCaptcha()
                break
            else:
                self.invalidCaptcha()
        else:
            self.fail("Invalid captcha")

        return url
开发者ID:DasLampe,项目名称:pyload,代码行数:25,代码来源:ZippyshareCom.py

示例15: decrypt

    def decrypt(self, pyfile):
        self.html = self.load(pyfile.url)
        found = re.search(self.ML_LINK_PATTERN, self.html)
        ml_url = found.group(1) if found else None
        
        json_list = json_loads(self.load("http://multiupload.com/progress/", get = {
            "d": re.search(self.__pattern__, pyfile.url).group(1),
            "r": str(int(time()*1000))        
            }))
        new_links = []
               
        prefered_set = map(lambda s: s.lower().split('.')[0], set(self.getConfig("preferedHoster").split('|')))       
        
        if ml_url and 'multiupload' in prefered_set: new_links.append(ml_url)               
        
        for link in json_list:          
            if link['service'].lower() in prefered_set and int(link['status']) and not int(link['deleted']):
                url = self.getLocation(link['url'])
                if url: new_links.append(url)        

        if not new_links:                    
            ignored_set = map(lambda s: s.lower().split('.')[0], set(self.getConfig("ignoredHoster").split('|')))
            
            if 'multiupload' not in ignored_set: new_links.append(ml_url)                   
        
            for link in json_list:         
                if link['service'].lower() not in ignored_set and int(link['status']) and not int(link['deleted']):
                    url = self.getLocation(link['url'])
                    if url: new_links.append(url)

        if new_links:
            self.core.files.addLinks(new_links, self.pyfile.package().id)
        else:
            self.fail('Could not extract any links')
开发者ID:4Christopher,项目名称:pyload,代码行数:34,代码来源:MultiuploadCom.py


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