Example #1
0
    def rampage_query(self, query):
        """Download PDF with query

        Args:
            query: Query of input

        """

        scihub_api = SciHubAPI(query, callback=self.rampage_callback,
                               rampage_type=SciHubRampageType.INPUT,
                               conf=self._conf, log=self.log)
        self.beforeRampage.emit()
        scihub_api.start()
Example #2
0
    def rampage_with_captcha(self, captcha_answer):
        """ Download PDF with captcha query (self._captcha_query) and captcha answer

        Args:
            captcha_answer: Captcha answer

        """

        scihub_api = SciHubAPI(self._captcha_query, callback=self.rampage_callback,
                               rampage_type=SciHubRampageType.PDF_CAPTCHA_RESPONSE,
                               conf=self._conf, log=self.log, captcha_answer=captcha_answer)

        self.beforeRampage.emit()
        scihub_api.start()
Example #3
0
    def show_captcha(self, pdf_captcha_response):
        """Callback function for PDF captcha response

        Args:
            pdf_captcha_response: PDF captcha response

        """

        self._captcha_query = pdf_captcha_response

        scihub_api = SciHubAPI('', log=self.log, conf=self._conf)
        _, captcha_img_url = scihub_api.get_captcha_info(pdf_captcha_response)
        self._captcha_img_file = scihub_api.download_captcha_img(
            captcha_img_url)
        captcha_img_local_url = 'file://' + self._captcha_img_file.name

        self._scihub_captcha.showWindowCaptcha.emit(captcha_img_local_url)
Example #4
0
    def captcha_callback(self, pdf_captcha_response):
        """Callback function for PDF captcha response

        Args:
            pdf_captcha_response: PDF captcha response

        """

        self._captcha_query = pdf_captcha_response
        _, captcha_img_url = SciHubAPI.get_captcha_info(pdf_captcha_response)
        self._scihub_captcha.showWindowCaptcha.emit(captcha_img_url)
Example #5
0
    def show_captcha(self, pdf_captcha_response):
        """Callback function for PDF captcha response

        Args:
            pdf_captcha_response: PDF captcha response

        """

        self._captcha_query = pdf_captcha_response

        scihub_api = SciHubAPI(self._input,
                               None,
                               log=self.log,
                               conf=self._conf)
        _, captcha_img_url = scihub_api.get_captcha_info(pdf_captcha_response)
        captcha_img_file = scihub_api.download_captcha_img(captcha_img_url)
        self._captcha_img_file_path = Path(captcha_img_file.name).as_posix()
        captcha_img_local_uri = Path(captcha_img_file.name).as_uri()

        self._scihub_captcha.showWindowCaptcha.emit(captcha_img_local_uri)
Example #6
0
    def rampage_with_captcha(self, captcha_answer):
        """ Download PDF with captcha query (self._captcha_query) and captcha answer

        Args:
            captcha_answer: Captcha answer

        """

        if os.path.exists(self._captcha_img_file_path) and os.path.isfile(
                self._captcha_img_file_path):
            os.remove(self._captcha_img_file_path)

        scihub_api = SciHubAPI(
            self._input,
            self._captcha_query,
            callback=self.rampage_callback,
            rampage_type=SciHubRampageType.PDF_CAPTCHA_RESPONSE,
            conf=self._conf,
            log=self.log,
            captcha_answer=captcha_answer)

        self.beforeRampage.emit()
        scihub_api.start()
Example #7
0
 def rampage(self, query):
     scihub_api = SciHubAPI(query, callback=self._afterRampage, conf=self._conf, log=self._log)
     self._beforeRampage()
     scihub_api.start()