Skip to content
This repository has been archived by the owner on Feb 21, 2021. It is now read-only.

Commit

Permalink
Fix UI & closes #8
Browse files Browse the repository at this point in the history
  • Loading branch information
simonsmh committed Sep 23, 2019
1 parent eb9416b commit ac35f9f
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 143 deletions.
84 changes: 20 additions & 64 deletions ui/main.ui
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
<bool>true</bool>
</property>
<property name="plainText">
<string/>
<string>Made by Simon Shi
在左侧使用账号/密码登录,填入 Token 后,点击启动即可刷EGPA。</string>
</property>
<property name="centerOnScroll">
<bool>false</bool>
Expand Down Expand Up @@ -335,79 +336,21 @@
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="catLabel">
<widget class="QLabel" name="urlLabel">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;可以选择文本内容,使用了 https://hitokoto.cn/ 的服务&lt;/p&gt;&lt;table border=&quot;0&quot;style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px;&quot;cellspacing=&quot;0&quot;cellpadding=&quot;0&quot;&gt;&lt;td rowspan=&quot;9&quot;/&gt;&lt;td colspan=&quot;4&quot;&gt;&lt;p&gt;提交不同的参数代表不同的类别,具体:&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;p&gt;a&lt;/p&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt;&lt;p&gt;Anime-动画&lt;/p&gt;&lt;/td&gt;&lt;td/&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;p&gt;b&lt;/p&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt;&lt;p&gt;Comic–漫画&lt;/p&gt;&lt;/td&gt;&lt;td/&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;p&gt;c&lt;/p&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt;&lt;p&gt;Game–游戏&lt;/p&gt;&lt;/td&gt;&lt;td/&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;p&gt;d&lt;/p&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt;&lt;p&gt;Novel–小说&lt;/p&gt;&lt;/td&gt;&lt;td/&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;p&gt;e&lt;/p&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt;&lt;p&gt;Myself–原创&lt;/p&gt;&lt;/td&gt;&lt;td/&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;p&gt;f&lt;/p&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt;&lt;p&gt;Internet–来自网络&lt;/p&gt;&lt;/td&gt;&lt;td/&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;p&gt;g&lt;/p&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt;&lt;p&gt;Other–其他&lt;/p&gt;&lt;/td&gt;&lt;td/&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;p&gt;其他不存在参数&lt;/p&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt;&lt;p&gt;任意类型随机取得&lt;/p&gt;&lt;/td&gt;&lt;td/&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string/>
</property>
<property name="statusTip">
<string>可以选择文本内容,使用了 https://hitokoto.cn/ 的服务</string>
<string>填入文本内容生成的链接</string>
</property>
<property name="whatsThis">
<string/>
</property>
<property name="text">
<string>使用的文本内容</string>
<string>文本生成链接</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="comboBox">
<property name="statusTip">
<string>可以选择文本内容,使用了 https://hitokoto.cn/ 的服务</string>
</property>
<property name="currentText">
<string>Anime - 动画</string>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<item>
<property name="text">
<string>Anime - 动画</string>
</property>
</item>
<item>
<property name="text">
<string>Comic – 漫画</string>
</property>
</item>
<item>
<property name="text">
<string>Game – 游戏</string>
</property>
</item>
<item>
<property name="text">
<string>Novel – 小说</string>
</property>
</item>
<item>
<property name="text">
<string>Myself – 原创</string>
</property>
</item>
<item>
<property name="text">
<string>Internet – 来自网络</string>
</property>
</item>
<item>
<property name="text">
<string>Other – 其他</string>
</property>
</item>
<item>
<property name="text">
<string>All - 随机</string>
</property>
</item>
<item>
<property name="text">
<string>自定义</string>
</property>
</item>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="waitLabel">
<property name="toolTip">
Expand All @@ -417,7 +360,7 @@
<string>每个操作之间的间隔,填入浮点数</string>
</property>
<property name="text">
<string>等待时间</string>
<string>等待时间间隔</string>
</property>
</widget>
</item>
Expand Down Expand Up @@ -465,6 +408,19 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="plainText">
<string>这里可以填写备忘录</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="urlLineedit">
<property name="statusTip">
<string>填入文本内容生成的链接</string>
</property>
<property name="text">
<string>https://v1.hitokoto.cn/?encode=text</string>
</property>
</widget>
</item>
</layout>
Expand Down
65 changes: 23 additions & 42 deletions ybqt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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,
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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()

Expand Down Expand Up @@ -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)))
Expand All @@ -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:
Expand All @@ -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()
Expand All @@ -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()
Expand All @@ -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)
Expand All @@ -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()
Expand All @@ -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):
Expand Down
5 changes: 3 additions & 2 deletions ybqtloginui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -29,5 +31,4 @@ def setupUi(self, LoginWindow):
def retranslateUi(self, LoginWindow):
_translate = QtCore.QCoreApplication.translate
LoginWindow.setWindowTitle(_translate("LoginWindow", "登录易班"))

from PyQt5 import QtWebEngineWidgets
Loading

0 comments on commit ac35f9f

Please sign in to comment.