From ac35f9f1d15808f861e1bd713bea1acb20d051ce Mon Sep 17 00:00:00 2001 From: Simon Shi Date: Mon, 23 Sep 2019 19:03:29 +0800 Subject: [PATCH] Fix UI & closes #8 --- ui/main.ui | 84 ++++++++++++-------------------------------------- ybqt.py | 65 ++++++++++++++------------------------ ybqtloginui.py | 5 +-- ybqtmainui.py | 54 ++++++++++++-------------------- 4 files changed, 65 insertions(+), 143 deletions(-) diff --git a/ui/main.ui b/ui/main.ui index 170493a..85baac0 100644 --- a/ui/main.ui +++ b/ui/main.ui @@ -42,7 +42,8 @@ true - + Made by Simon Shi +在左侧使用账号/密码登录,填入 Token 后,点击启动即可刷EGPA。 false @@ -335,79 +336,21 @@ - + - <html><head/><body><p>可以选择文本内容,使用了 https://hitokoto.cn/ 的服务</p><table border="0"style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px;"cellspacing="0"cellpadding="0"><td rowspan="9"/><td colspan="4"><p>提交不同的参数代表不同的类别,具体:</p></td></tr><tr><td><p>a</p></td><td colspan="2"><p>Anime-动画</p></td><td/></tr><tr><td><p>b</p></td><td colspan="2"><p>Comic–漫画</p></td><td/></tr><tr><td><p>c</p></td><td colspan="2"><p>Game–游戏</p></td><td/></tr><tr><td><p>d</p></td><td colspan="2"><p>Novel–小说</p></td><td/></tr><tr><td><p>e</p></td><td colspan="2"><p>Myself–原创</p></td><td/></tr><tr><td><p>f</p></td><td colspan="2"><p>Internet–来自网络</p></td><td/></tr><tr><td><p>g</p></td><td colspan="2"><p>Other–其他</p></td><td/></tr><tr><td><p>其他不存在参数</p></td><td colspan="2"><p>任意类型随机取得</p></td><td/></tr></table></body></html> + - 可以选择文本内容,使用了 https://hitokoto.cn/ 的服务 + 填入文本内容生成的链接 - 使用的文本内容 + 文本生成链接 - - - - 可以选择文本内容,使用了 https://hitokoto.cn/ 的服务 - - - Anime - 动画 - - - 0 - - - - Anime - 动画 - - - - - Comic – 漫画 - - - - - Game – 游戏 - - - - - Novel – 小说 - - - - - Myself – 原创 - - - - - Internet – 来自网络 - - - - - Other – 其他 - - - - - All - 随机 - - - - - 自定义 - - - - @@ -417,7 +360,7 @@ 每个操作之间的间隔,填入浮点数 - 等待时间 + 等待时间间隔 @@ -465,6 +408,19 @@ 0 + + 这里可以填写备忘录 + + + + + + + 填入文本内容生成的链接 + + + https://v1.hitokoto.cn/?encode=text + diff --git a/ybqt.py b/ybqt.py index 0566d48..370d3d6 100755 --- a/ybqt.py +++ b/ybqt.py @@ -16,7 +16,7 @@ class MyThread(QtCore.QThread): - def __init__(self, token, captcha, add_vote_count, vote_control_count, vote_reply_count, add_topic_count, topic_control_count, topic_reply_count, vote, vote_up, vote_reply, topic_up, topic_reply, cat, waitime): + def __init__(self, token, captcha, add_vote_count, vote_control_count, vote_reply_count, add_topic_count, topic_control_count, topic_reply_count, vote, vote_up, vote_reply, topic_up, topic_reply, url, waitime): super(MyThread, self).__init__() self.token = dict(yiban_user_token=token) self.add_vote_count = add_vote_count @@ -30,33 +30,16 @@ def __init__(self, token, captcha, add_vote_count, vote_control_count, vote_repl self.vote_reply = vote_reply self.topic_up = topic_up self.topic_reply = topic_reply - self.cat = cat + self.url = url self.waitime = waitime - def getHitokoto(self): - cato = { - 0: "a", - 1: "b", - 2: "c", - 3: "d", - 4: "e", - 5: "f", - 6: "g", - 7: "", - } - Get_Hitokoto = r.get("https://v1.hitokoto.cn/", - params={"c": cato.get(self.cat), "encode": "json"}, timeout=10) - Hitokoto = Get_Hitokoto.json()["hitokoto"] - From = Get_Hitokoto.json()["from"] - return Hitokoto + " --" + From - - def getElse(self, url=None): - Get_Url = r.get(url, timeout=10) + def getURL(self): + Get_Url = r.get(self.url, timeout=10) return str(Get_Url.text) def wait(self): try: - self.getEPGA() + self.getEGPA() except: pass finally: @@ -92,14 +75,14 @@ def login(self): finally: self.wait() - def getEPGA(self): + def getEGPA(self): try: - Get_EPGA = r.get(yblogin.BASEURL + "newgroup/indexPub/group_id/" + + Get_EGPA = r.get(yblogin.BASEURL + "newgroup/indexPub/group_id/" + self.group_id + "/puid/" + self.puid, headers=yblogin.header, cookies=self.token, timeout=10) - EPGA = re.search(r"EGPA:[0-9\.]*", Get_EPGA.text) - self.epgasig.emit(EPGA.group()) + EGPA = re.search(r"EGPA:[0-9\.]*", Get_EGPA.text) + self.egpasig.emit(EGPA.group()) except: - self.epgasig.emit("无法连接服务器") + self.egpasig.emit("无法连接服务器") def runVote(self): try: @@ -109,7 +92,7 @@ def runVote(self): self.prog = 0 for i in range(0, int(self.add_vote_count)): try: - text = self.getHitokoto() + text = self.getURL() response = ybvote.vote( self.token, self.puid, @@ -174,7 +157,7 @@ def runVote(self): if self.vote_reply: for i in range(0, int(self.vote_reply_count)): try: - response = votego.reply(self.getHitokoto()) + response = votego.reply(self.getURL()) self.sig.emit(self.fprint( "添加投票评论" + response, dlevel=1, num=i)) except: @@ -205,8 +188,8 @@ def runTopic(self): self.group_id, self.channel_id ).add( - self.getHitokoto(), - self.getHitokoto() + self.getURL(), + self.getURL() ) self.sig.emit(self.fprint("添加话题" + response, dlevel=1, num=i)) except: @@ -243,7 +226,7 @@ def runTopic(self): for i in range(0, int(self.topic_reply_count)): try: response = topicgo.reply( - self.article_id, self.getHitokoto()) + self.article_id, self.getURL()) self.sig.emit(self.fprint( "添加话题评论" + response, dlevel=1, num=i)) except: @@ -261,7 +244,7 @@ def runTopic(self): self.wait() sig = QtCore.pyqtSignal(str) - epgasig = QtCore.pyqtSignal(str) + egpasig = QtCore.pyqtSignal(str) prosig = QtCore.pyqtSignal(int) stopsig = QtCore.pyqtSignal() @@ -289,8 +272,6 @@ def __init__(self): QtCore.QCoreApplication.setApplicationName("ybqt") self.settings = QtCore.QSettings(os.getcwd() + "/ybqt.ini", QtCore.QSettings.IniFormat) self.settings.setFallbacksEnabled(False) - self.plainTextEdit.appendPlainText("Made by Simon Shi") - self.plainTextEdit.appendPlainText("在左侧使用账号/密码登录,填入 Token 后,点击启动即可刷EGPA。") if os.path.exists(os.getcwd() + "/ybqt.ini"): self.resize(self.settings.value('size', QtCore.QSize(501, 501))) self.move(self.settings.value('pos', QtCore.QPoint(0, 0))) @@ -311,7 +292,7 @@ def __init__(self): self.topic_upCheckbox.setChecked(False) if not self.settings.value("topic_reply", 0, type=int): self.topic_replyCheckbox.setChecked(False) - self.comboBox.setCurrentIndex(self.settings.value("combo", 0, type=int)) + self.urlLineedit.setText(self.settings.value("url", type=str)) self.doubleSpinBox.setValue(self.settings.value("double", 0.0000, type=float)) self.NotePad.setPlainText(self.settings.value("note", type=str)) else: @@ -335,7 +316,7 @@ def DisableButton(self): self.vote_replyCheckbox.setDisabled(True) self.topic_upCheckbox.setDisabled(True) self.topic_replyCheckbox.setDisabled(True) - self.comboBox.setDisabled(True) + self.urlLineedit.setDisabled(True) self.doubleSpinBox.setDisabled(True) self.progressBar.setValue(0) self.QsettingHook() @@ -353,12 +334,12 @@ def DisableButton(self): self.settings.value("vote_reply", 0, type=int), self.settings.value("topic_up", 0, type=int), self.settings.value("topic_reply", 0, type=int), - self.settings.value("combo", 0, type=int), + self.settings.value("url", type=str), self.settings.value("double", 0.0000, type=float) ) self.mythread.sig.connect(self.PrintText) self.mythread.prosig.connect(self.Progress) - self.mythread.epgasig.connect(self.EpgaShowup) + self.mythread.egpasig.connect(self.EgpaShowup) self.mythread.stopsig.connect(self.StopThread) self.mythread.finished.connect(self.EnableButton) self.mythread.start() @@ -383,7 +364,7 @@ def EnableButton(self): self.vote_replyCheckbox.setEnabled(True) self.topic_upCheckbox.setEnabled(True) self.topic_replyCheckbox.setEnabled(True) - self.comboBox.setEnabled(True) + self.urlLineedit.setEnabled(True) self.doubleSpinBox.setEnabled(True) self.lauchButton.released.disconnect() self.lauchButton.released.connect(self.DisableButton) @@ -405,7 +386,7 @@ def QsettingHook(self): self.settings.setValue("vote_reply", self.vote_replyCheckbox.checkState()) self.settings.setValue("topic_up", self.topic_upCheckbox.checkState()) self.settings.setValue("topic_reply", self.topic_replyCheckbox.checkState()) - self.settings.setValue("combo", self.comboBox.currentIndex()) + self.settings.setValue("url", self.urlLineedit.text()) self.settings.setValue("double", self.doubleSpinBox.text()) self.settings.setValue("note", self.NotePad.toPlainText()) self.settings.sync() @@ -414,7 +395,7 @@ def StopThread(self): if self.mythread.isRunning(): self.mythread.terminate() - def EpgaShowup(self, string): + def EgpaShowup(self, string): self.setWindowTitle("易班"+string) def Progress(self, integer): diff --git a/ybqtloginui.py b/ybqtloginui.py index 54cf4af..cad216a 100644 --- a/ybqtloginui.py +++ b/ybqtloginui.py @@ -2,12 +2,14 @@ # Form implementation generated from reading ui file 'ui/login.ui' # -# Created by: PyQt5 UI code generator 5.10 +# Created by: PyQt5 UI code generator 5.13.1 # # WARNING! All changes made in this file will be lost! + from PyQt5 import QtCore, QtGui, QtWidgets + class Ui_LoginWindow(object): def setupUi(self, LoginWindow): LoginWindow.setObjectName("LoginWindow") @@ -29,5 +31,4 @@ def setupUi(self, LoginWindow): def retranslateUi(self, LoginWindow): _translate = QtCore.QCoreApplication.translate LoginWindow.setWindowTitle(_translate("LoginWindow", "登录易班")) - from PyQt5 import QtWebEngineWidgets diff --git a/ybqtmainui.py b/ybqtmainui.py index e9dee0e..42c9757 100644 --- a/ybqtmainui.py +++ b/ybqtmainui.py @@ -2,12 +2,14 @@ # Form implementation generated from reading ui file 'ui/main.ui' # -# Created by: PyQt5 UI code generator 5.10 +# Created by: PyQt5 UI code generator 5.13.1 # # WARNING! All changes made in this file will be lost! + from PyQt5 import QtCore, QtGui, QtWidgets + class Ui_mainWindow(object): def setupUi(self, mainWindow): mainWindow.setObjectName("mainWindow") @@ -26,7 +28,6 @@ def setupUi(self, mainWindow): self.plainTextEdit.setSizePolicy(sizePolicy) self.plainTextEdit.setToolTip("") self.plainTextEdit.setReadOnly(True) - self.plainTextEdit.setPlainText("") self.plainTextEdit.setCenterOnScroll(False) self.plainTextEdit.setObjectName("plainTextEdit") self.gridLayout_3.addWidget(self.plainTextEdit, 0, 1, 1, 1) @@ -144,22 +145,11 @@ def setupUi(self, mainWindow): self.tokenLineedit.setText("") self.tokenLineedit.setObjectName("tokenLineedit") self.formLayout_4.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.tokenLineedit) - self.catLabel = QtWidgets.QLabel(self.centralwidget) - self.catLabel.setWhatsThis("") - self.catLabel.setObjectName("catLabel") - self.formLayout_4.setWidget(2, QtWidgets.QFormLayout.LabelRole, self.catLabel) - self.comboBox = QtWidgets.QComboBox(self.centralwidget) - self.comboBox.setObjectName("comboBox") - self.comboBox.addItem("") - self.comboBox.addItem("") - self.comboBox.addItem("") - self.comboBox.addItem("") - self.comboBox.addItem("") - self.comboBox.addItem("") - self.comboBox.addItem("") - self.comboBox.addItem("") - self.comboBox.addItem("") - self.formLayout_4.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.comboBox) + self.urlLabel = QtWidgets.QLabel(self.centralwidget) + self.urlLabel.setToolTip("") + self.urlLabel.setWhatsThis("") + self.urlLabel.setObjectName("urlLabel") + self.formLayout_4.setWidget(2, QtWidgets.QFormLayout.LabelRole, self.urlLabel) self.waitLabel = QtWidgets.QLabel(self.centralwidget) self.waitLabel.setToolTip("") self.waitLabel.setObjectName("waitLabel") @@ -186,6 +176,9 @@ def setupUi(self, mainWindow): self.NotePad.setSizePolicy(sizePolicy) self.NotePad.setObjectName("NotePad") self.formLayout_4.setWidget(5, QtWidgets.QFormLayout.SpanningRole, self.NotePad) + self.urlLineedit = QtWidgets.QLineEdit(self.centralwidget) + self.urlLineedit.setObjectName("urlLineedit") + self.formLayout_4.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.urlLineedit) self.gridLayout_3.addLayout(self.formLayout_4, 0, 0, 1, 1) mainWindow.setCentralWidget(self.centralwidget) self.statusbar = QtWidgets.QStatusBar(mainWindow) @@ -193,13 +186,14 @@ def setupUi(self, mainWindow): mainWindow.setStatusBar(self.statusbar) self.retranslateUi(mainWindow) - self.comboBox.setCurrentIndex(0) QtCore.QMetaObject.connectSlotsByName(mainWindow) def retranslateUi(self, mainWindow): _translate = QtCore.QCoreApplication.translate mainWindow.setWindowTitle(_translate("mainWindow", "易班 EGPA")) self.plainTextEdit.setStatusTip(_translate("mainWindow", "程序输出日志,如出错请咨询开发者")) + self.plainTextEdit.setPlainText(_translate("mainWindow", "Made by Simon Shi\n" +"在左侧使用账号/密码登录,填入 Token 后,点击启动即可刷EGPA。")) self.add_vote_countLabel.setStatusTip(_translate("mainWindow", "发起投票数量,如不需要请改为0关闭自动发起投票")) self.add_vote_countLabel.setText(_translate("mainWindow", "发起投票数量")) self.add_vote_countSpinbox.setStatusTip(_translate("mainWindow", "发起投票数量,如不需要请改为0关闭自动发起投票")) @@ -226,23 +220,13 @@ def retranslateUi(self, mainWindow): self.tokenLabel.setStatusTip(_translate("mainWindow", "Token是易班账号密码验证的优秀替代方式,可用于访问易班服务,重新登录将重置Token")) self.tokenLabel.setText(_translate("mainWindow", "Token")) self.tokenLineedit.setStatusTip(_translate("mainWindow", "Token是易班账号密码验证的优秀替代方式,可用于访问易班服务,重新登录将重置Token")) - self.catLabel.setToolTip(_translate("mainWindow", "

可以选择文本内容,使用了 https://hitokoto.cn/ 的服务

提交不同的参数代表不同的类别,具体:

a

Anime-动画

b

Comic–漫画

c

Game–游戏

d

Novel–小说

e

Myself–原创

f

Internet–来自网络

g

Other–其他

其他不存在参数

任意类型随机取得

")) - self.catLabel.setStatusTip(_translate("mainWindow", "可以选择文本内容,使用了 https://hitokoto.cn/ 的服务")) - self.catLabel.setText(_translate("mainWindow", "使用的文本内容")) - self.comboBox.setStatusTip(_translate("mainWindow", "可以选择文本内容,使用了 https://hitokoto.cn/ 的服务")) - self.comboBox.setCurrentText(_translate("mainWindow", "Anime - 动画")) - self.comboBox.setItemText(0, _translate("mainWindow", "Anime - 动画")) - self.comboBox.setItemText(1, _translate("mainWindow", "Comic – 漫画")) - self.comboBox.setItemText(2, _translate("mainWindow", "Game – 游戏")) - self.comboBox.setItemText(3, _translate("mainWindow", "Novel – 小说")) - self.comboBox.setItemText(4, _translate("mainWindow", "Myself – 原创")) - self.comboBox.setItemText(5, _translate("mainWindow", "Internet – 来自网络")) - self.comboBox.setItemText(6, _translate("mainWindow", "Other – 其他")) - self.comboBox.setItemText(7, _translate("mainWindow", "All - 随机")) - self.comboBox.setItemText(8, _translate("mainWindow", "自定义")) + self.urlLabel.setStatusTip(_translate("mainWindow", "填入文本内容生成的链接")) + self.urlLabel.setText(_translate("mainWindow", "文本生成链接")) self.waitLabel.setStatusTip(_translate("mainWindow", "每个操作之间的间隔,填入浮点数")) - self.waitLabel.setText(_translate("mainWindow", "等待时间")) + self.waitLabel.setText(_translate("mainWindow", "等待时间间隔")) self.doubleSpinBox.setStatusTip(_translate("mainWindow", "每个操作之间的间隔,填入浮点数")) self.loginButton.setText(_translate("mainWindow", "账号/密码登录")) self.lauchButton.setText(_translate("mainWindow", "启动")) - + self.NotePad.setPlainText(_translate("mainWindow", "这里可以填写备忘录")) + self.urlLineedit.setStatusTip(_translate("mainWindow", "填入文本内容生成的链接")) + self.urlLineedit.setText(_translate("mainWindow", "https://v1.hitokoto.cn/?encode=text"))