[common] add Extractor.input() method

pull/5516/head
Mike Fährmann 5 months ago
parent 257e9fb435
commit b38a917355
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

@ -14,6 +14,7 @@ import ssl
import time
import netrc
import queue
import getpass
import logging
import datetime
import requests
@ -250,6 +251,15 @@ class Extractor():
seconds, reason)
time.sleep(seconds)
def input(self, prompt, echo=True):
if echo:
try:
return input(prompt)
except (EOFError, OSError):
return None
else:
return getpass.getpass(prompt)
def _get_auth_info(self):
"""Return authentication information as (username, password) tuple"""
username = self.config("username")

@ -35,10 +35,7 @@ class ReadcomiconlineBase():
self.log.warning(
"Redirect to \n%s\nVisit this URL in your browser, solve "
"the CAPTCHA, and press ENTER to continue", response.url)
try:
input()
except (EOFError, OSError):
pass
self.input()
else:
raise exception.StopExtraction(
"Redirect to \n%s\nVisit this URL in your browser and "

@ -1312,11 +1312,8 @@ class TwitterAPI():
msg = "Account temporarily locked"
if self.extractor.config("locked") != "wait":
raise exception.AuthorizationError(msg)
self.log.warning("%s. Press ENTER to retry.", msg)
try:
input()
except (EOFError, OSError):
pass
self.log.warning(msg)
self.extractor.input("Press ENTER to retry.")
retry = True
elif "Could not authenticate you" in msg:

Loading…
Cancel
Save