Skip to content

Commit

Permalink
update: show params
Browse files Browse the repository at this point in the history
- 重命名 ui 的 .py 文件
- 添加显示参数
  • Loading branch information
1299172402 committed Nov 4, 2022
1 parent bb8f61b commit 6b0ad4d
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 41 deletions.
51 changes: 45 additions & 6 deletions BBDown_GUI/UI/main.ui
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@
<widget class="QPushButton" name="pushButton_download">
<property name="geometry">
<rect>
<x>510</x>
<x>508</x>
<y>360</y>
<width>93</width>
<height>28</height>
Expand All @@ -282,7 +282,7 @@
<widget class="QPushButton" name="pushButton_advanced">
<property name="geometry">
<rect>
<x>410</x>
<x>409</x>
<y>360</y>
<width>93</width>
<height>28</height>
Expand Down Expand Up @@ -831,12 +831,19 @@
<item>
<widget class="QLabel" name="label_bbdown">
<property name="text">
<string> BBDown</string>
<string>程序位置</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_bbdown"/>
<widget class="QLineEdit" name="lineEdit_bbdown">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;BBDown 程序位置&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="whatsThis">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_bbdown">
Expand Down Expand Up @@ -1142,6 +1149,9 @@
<property name="text">
<string>启用代理</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
Expand All @@ -1163,7 +1173,7 @@
<item>
<widget class="QCheckBox" name="checkBox_ep_host">
<property name="text">
<string>EP代理</string>
<string>番剧代理</string>
</property>
</widget>
</item>
Expand All @@ -1177,7 +1187,7 @@
<item>
<widget class="QCheckBox" name="checkBox_area">
<property name="text">
<string>地区</string>
<string>地区指定</string>
</property>
</widget>
</item>
Expand All @@ -1196,6 +1206,35 @@
</layout>
</widget>
</widget>
<widget class="QWidget" name="horizontalLayoutWidget_6">
<property name="geometry">
<rect>
<x>30</x>
<y>460</y>
<width>571</width>
<height>31</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_12">
<item>
<widget class="QLabel" name="label_param">
<property name="text">
<string>运行参数</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_param"/>
</item>
<item>
<widget class="QPushButton" name="pushButton_param">
<property name="text">
<string>生成</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
<resources/>
<connections/>
Expand Down
4 changes: 2 additions & 2 deletions BBDown_GUI/UI/about.py → BBDown_GUI/UI/ui_about.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'D:\Desktop\BBDown_GUI\UI\about.ui'
# Form implementation generated from reading ui file 'd:\Desktop\BBDown_GUI\BBDown_GUI\UI\about.ui'
#
# Created by: PyQt5 UI code generator 5.15.4
# Created by: PyQt5 UI code generator 5.15.6
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.
Expand Down
30 changes: 25 additions & 5 deletions BBDown_GUI/UI/main.py → BBDown_GUI/UI/ui_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,10 @@ def setupUi(self, Form_main):
self.lineEdit_url.setObjectName("lineEdit_url")
self.horizontalLayout_4.addWidget(self.lineEdit_url)
self.pushButton_download = QtWidgets.QPushButton(Form_main)
self.pushButton_download.setGeometry(QtCore.QRect(510, 360, 93, 28))
self.pushButton_download.setGeometry(QtCore.QRect(508, 360, 93, 28))
self.pushButton_download.setObjectName("pushButton_download")
self.pushButton_advanced = QtWidgets.QPushButton(Form_main)
self.pushButton_advanced.setGeometry(QtCore.QRect(410, 360, 93, 28))
self.pushButton_advanced.setGeometry(QtCore.QRect(409, 360, 93, 28))
self.pushButton_advanced.setObjectName("pushButton_advanced")
self.pushButton_about = QtWidgets.QPushButton(Form_main)
self.pushButton_about.setEnabled(True)
Expand Down Expand Up @@ -427,6 +427,7 @@ def setupUi(self, Form_main):
self.verticalLayout_3.setContentsMargins(0, 0, 0, 0)
self.verticalLayout_3.setObjectName("verticalLayout_3")
self.checkBox_enable_proxy = QtWidgets.QCheckBox(self.verticalLayoutWidget)
self.checkBox_enable_proxy.setChecked(True)
self.checkBox_enable_proxy.setObjectName("checkBox_enable_proxy")
self.verticalLayout_3.addWidget(self.checkBox_enable_proxy)
self.horizontalLayout_9 = QtWidgets.QHBoxLayout()
Expand Down Expand Up @@ -457,6 +458,21 @@ def setupUi(self, Form_main):
self.lineEdit_area.setObjectName("lineEdit_area")
self.horizontalLayout_10.addWidget(self.lineEdit_area)
self.verticalLayout_3.addLayout(self.horizontalLayout_10)
self.horizontalLayoutWidget_6 = QtWidgets.QWidget(Form_main)
self.horizontalLayoutWidget_6.setGeometry(QtCore.QRect(30, 460, 571, 31))
self.horizontalLayoutWidget_6.setObjectName("horizontalLayoutWidget_6")
self.horizontalLayout_12 = QtWidgets.QHBoxLayout(self.horizontalLayoutWidget_6)
self.horizontalLayout_12.setContentsMargins(0, 0, 0, 0)
self.horizontalLayout_12.setObjectName("horizontalLayout_12")
self.label_param = QtWidgets.QLabel(self.horizontalLayoutWidget_6)
self.label_param.setObjectName("label_param")
self.horizontalLayout_12.addWidget(self.label_param)
self.lineEdit_param = QtWidgets.QLineEdit(self.horizontalLayoutWidget_6)
self.lineEdit_param.setObjectName("lineEdit_param")
self.horizontalLayout_12.addWidget(self.lineEdit_param)
self.pushButton_param = QtWidgets.QPushButton(self.horizontalLayoutWidget_6)
self.pushButton_param.setObjectName("pushButton_param")
self.horizontalLayout_12.addWidget(self.pushButton_param)

self.retranslateUi(Form_main)
QtCore.QMetaObject.connectSlotsByName(Form_main)
Expand Down Expand Up @@ -548,7 +564,9 @@ def retranslateUi(self, Form_main):
self.checkBox_language.setToolTip(_translate("Form_main", "<html><head/><body><p>设置混流的音频语言(代码),如chi, jpn等</p></body></html>"))
self.checkBox_language.setText(_translate("Form_main", "设置混流的音频语言代码"))
self.lineEdit_language.setPlaceholderText(_translate("Form_main", "如chi,jpn"))
self.label_bbdown.setText(_translate("Form_main", " BBDown"))
self.label_bbdown.setText(_translate("Form_main", "程序位置"))
self.lineEdit_bbdown.setToolTip(_translate("Form_main", "<html><head/><body><p>BBDown 程序位置</p></body></html>"))
self.lineEdit_bbdown.setWhatsThis(_translate("Form_main", "<html><head/><body><p><br/></p></body></html>"))
self.pushButton_bbdown.setText(_translate("Form_main", "浏览"))
self.radioButton_p_current.setText(_translate("Form_main", "下载当前分P"))
self.radioButton_p_all.setText(_translate("Form_main", "下载全部分P"))
Expand Down Expand Up @@ -578,6 +596,8 @@ def retranslateUi(self, Form_main):
self.groupBox_13.setTitle(_translate("Form_main", "代理"))
self.checkBox_enable_proxy.setText(_translate("Form_main", "启用代理"))
self.checkBox_host.setText(_translate("Form_main", "代理地址"))
self.checkBox_ep_host.setText(_translate("Form_main", "EP代理"))
self.checkBox_area.setText(_translate("Form_main", "地区"))
self.checkBox_ep_host.setText(_translate("Form_main", "番剧代理"))
self.checkBox_area.setText(_translate("Form_main", "地区指定"))
self.lineEdit_area.setPlaceholderText(_translate("Form_main", "如hk"))
self.label_param.setText(_translate("Form_main", "运行参数"))
self.pushButton_param.setText(_translate("Form_main", "生成"))
4 changes: 2 additions & 2 deletions BBDown_GUI/UI/qrcode.py → BBDown_GUI/UI/ui_qrcode.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'D:\Desktop\BBDown_GUI\UI\qrcode.ui'
# Form implementation generated from reading ui file 'd:\Desktop\BBDown_GUI\BBDown_GUI\UI\qrcode.ui'
#
# Created by: PyQt5 UI code generator 5.15.4
# Created by: PyQt5 UI code generator 5.15.6
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.
Expand Down
66 changes: 40 additions & 26 deletions BBDown_GUI/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
import json
import subprocess

from BBDown_GUI.UI.main import Ui_Form_main
from BBDown_GUI.UI.qrcode import Ui_Form_QRcode
from BBDown_GUI.UI.about import Ui_Form_about
from BBDown_GUI.UI.ui_main import Ui_Form_main
from BBDown_GUI.UI.ui_qrcode import Ui_Form_QRcode
from BBDown_GUI.UI.ui_about import Ui_Form_about

from PyQt5.QtWidgets import QApplication, QMainWindow, QFileDialog
from PyQt5.QtCore import QThread, pyqtSignal
Expand All @@ -27,6 +27,10 @@ def resource_path(relative_path):

return os.path.join(base_path, relative_path)

def log(message=''):
t = time.time()
print(f'[{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(t))}.{int(t * 1000) % 1000}] - {message}')

class RunBBDown(QThread):
signal = pyqtSignal(int)
def __init__(self, command):
Expand Down Expand Up @@ -131,6 +135,7 @@ def Load(self):
self.pushButton_ffmpeg.clicked.connect(self.ffmpegpath)
self.pushButton_dir.clicked.connect(self.downpath)
self.pushButton_bbdown.clicked.connect(self.bbdownpath)
self.pushButton_param.clicked.connect(self.param)
self.pushButton_download.clicked.connect(self.download)
self.pushButton_advanced.clicked.connect(self.advanced)
self.advanced = False
Expand Down Expand Up @@ -171,25 +176,8 @@ def bbdownpath(self):
global bbdowndir
bbdowndir = self.lineEdit_bbdown.text()

# 开始下载
def download(self):
def Save():
config = {}
for i in dir(self):
if i[:9]=="checkBox_":
exec(f"config[i] = self.{i}.isChecked()")
elif i[:12]=="radioButton_":
exec(f"config[i] = self.{i}.isChecked()")
elif i[:9]=="lineEdit_":
exec(f"config[i] = self.{i}.text()")
elif i[:9]=="comboBox_":
exec(f"config[i] = self.{i}.currentIndex()")
config["advanced"] = self.advanced
f = open(os.path.join(workdir, "config.json"), "w")
f.write(json.dumps(config, indent=4))
f.close()

Save()
# 获取下载参数(有返回值)
def arg(self):
args = ''

# 下载地址
Expand Down Expand Up @@ -321,12 +309,38 @@ def Save():
# 下载路径
args += f' --work-dir "{self.lineEdit_dir.text()}" '

return args

def param(self):
args = self.arg()
self.lineEdit_param.setText(args)

# 开始下载
def download(self):
def Save():
config = {}
for i in dir(self):
if i[:9]=="checkBox_":
exec(f"config[i] = self.{i}.isChecked()")
elif i[:12]=="radioButton_":
exec(f"config[i] = self.{i}.isChecked()")
elif i[:9]=="lineEdit_":
exec(f"config[i] = self.{i}.text()")
elif i[:9]=="comboBox_":
exec(f"config[i] = self.{i}.currentIndex()")
config["advanced"] = self.advanced
f = open(os.path.join(workdir, "config.json"), "w")
f.write(json.dumps(config, indent=4))
f.close()

Save()
args = self.arg()

# 测试专用
'''
if self.advanced and self.checkBox_debug.isChecked():
print("[BBDown_GUI_args]")
print(args)
'''
log('BBDown GUI 启动下载任务')
log(f"运行参数: {args}")

try:
self.job_down = RunBBDown(args)
self.job_down.start()
Expand Down

0 comments on commit 6b0ad4d

Please sign in to comment.