From f17bb3bddb0e5774e78bb4b30a2f136e31f29a20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Gl=C3=BCpker?= Date: Sat, 19 Mar 2016 13:23:47 +0100 Subject: Show number of 'NO CAPTCHA'-Messages --- 9kwpyqt.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to '9kwpyqt.py') diff --git a/9kwpyqt.py b/9kwpyqt.py index 6e9f044..039ca1c 100755 --- a/9kwpyqt.py +++ b/9kwpyqt.py @@ -32,6 +32,9 @@ class CaptchaGUI(QWidget): apiurl = API_URL+"?source=pythonapi&apikey="+API_KEY+"&" offlinemessage = "Click \"Start\" to fetch next captcha." + waitingoncaptcha = 0 + + def __init__(self, parent=None): super(CaptchaGUI, self).__init__(parent) self.setMinimumWidth(400) @@ -221,14 +224,19 @@ class CaptchaGUI(QWidget): content = str(self.networkCaptchaIDReply.readAll(), encoding='utf-8') self.networkCaptchaIDReply.deleteLater() if content == 'NO CAPTCHA': - status = self.captchaImage.text()+"." + self.waitingoncaptcha += 1 + status = "Server responded with 'NO CAPTCHA' "+str(self.waitingoncaptcha)+" times." self.captchaImage.setText(status) QTimer.singleShot(1000, self.getCaptchaID) - elif not content.isnumeric(): - self.captchaImage.setText("Unknown error? ID not 'NO CAPTCHA' nor number") - else: + elif content.isnumeric(): + self.waitingoncaptcha = 0 + print("New Captcha:", int(content)) self.currentCaptchaID = int(content) self.getCaptchaIMG() + else: + self.waitingoncaptcha += 1 + print("Unknown error? ID not 'NO CAPTCHA' nor number") + print(content) def getCaptchaIMG(self): url = QUrl(self.apiurl+"action=usercaptchashow&id="+str(self.currentCaptchaID)) -- cgit v1.2.3