Skip to content

Commit 29774ba

Browse files
committed
✨ 时装请求图片格式选项
1 parent ea8def9 commit 29774ba

File tree

5 files changed

+53
-20
lines changed

5 files changed

+53
-20
lines changed

src/DownloadManager.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,6 @@ def __thread__EpisodeTask(self, curr_id: int, epi: Episode) -> None:
158158
img_url = img["complete_url"]
159159
else:
160160
img_url = img["url"]
161-
img_url = re.sub(r"@[^?]*\?", "", img_url)
162161
match_cpx = re.search(r"[?&]cpx=([^&]*)", img_url)
163162
cpx = match_cpx.group(1) if match_cpx else ""
164163
img_path = epi.downloadImg(index, img_url, cpx)

src/Episode.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,25 @@ def _() -> list[dict]:
154154
)
155155
return False
156156

157+
# ?###########################################################
158+
# ? 配置图片下载格式
159+
img_format_list = {
160+
"default": "",
161+
"jpg": "@10000w.jpg",
162+
"webp": "@10000w.webp",
163+
"avif": "@10000w.avif",
164+
"1700jpg": "@1700w.jpg",
165+
"1400jpg": "@1400w.jpg",
166+
"1100jpg": "@1100w.jpg",
167+
"1700webp": "@1700w.webp",
168+
"1400webp": "@1400w.webp",
169+
"1700avif": "@1700w.avif",
170+
"1400avif": "@1400w.avif",
171+
"1100avif": "@1100w.avif",
172+
}
173+
img_format = self.mainGUI.getConfig("img_format")
174+
imgs_urls = [img_url + img_format_list[img_format] for img_url in imgs_urls]
175+
157176
# ?###########################################################
158177
# ? 获取图片token
159178
ImageTokenURL = (

src/ui/PySide_src/mainWindow.ui

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,8 @@
192192
<rect>
193193
<x>0</x>
194194
<y>0</y>
195-
<width>524</width>
196-
<height>191</height>
195+
<width>98</width>
196+
<height>28</height>
197197
</rect>
198198
</property>
199199
<layout class="QVBoxLayout" name="v_Layout_myLibrary"/>
@@ -1097,7 +1097,7 @@ li.checked::marker { content: &quot;\2612&quot;; }
10971097
<number>0</number>
10981098
</property>
10991099
<item>
1100-
<widget class="QLabel" name="label_img_format">
1100+
<widget class="QLabel" name="label_epi_rename_rule">
11011101
<property name="text">
11021102
<string>章节命名规则:</string>
11031103
</property>
@@ -1166,9 +1166,9 @@ li.checked::marker { content: &quot;\2612&quot;; }
11661166
</spacer>
11671167
</item>
11681168
<item>
1169-
<widget class="QLabel" name="label_epi_rename_rule">
1169+
<widget class="QLabel" name="label_img_format">
11701170
<property name="text">
1171-
<string>下载图片格式:</string>
1171+
<string>请求图片格式:</string>
11721172
</property>
11731173
</widget>
11741174
</item>

src/ui/PySide_src/mainWindow_ui.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def setupUi(self, MainWindow):
146146
self.scrollArea_myLibrary.setWidgetResizable(True)
147147
self.scrollAreaWidgetContents_myLibrary = QWidget()
148148
self.scrollAreaWidgetContents_myLibrary.setObjectName(u"scrollAreaWidgetContents_myLibrary")
149-
self.scrollAreaWidgetContents_myLibrary.setGeometry(QRect(0, 0, 524, 191))
149+
self.scrollAreaWidgetContents_myLibrary.setGeometry(QRect(0, 0, 98, 28))
150150
self.v_Layout_myLibrary = QVBoxLayout(self.scrollAreaWidgetContents_myLibrary)
151151
self.v_Layout_myLibrary.setObjectName(u"v_Layout_myLibrary")
152152
self.scrollArea_myLibrary.setWidget(self.scrollAreaWidgetContents_myLibrary)
@@ -692,10 +692,10 @@ def setupUi(self, MainWindow):
692692
self.h_Layout_save_prefer = QHBoxLayout()
693693
self.h_Layout_save_prefer.setObjectName(u"h_Layout_save_prefer")
694694
self.h_Layout_save_prefer.setContentsMargins(0, 0, 0, 0)
695-
self.label_img_format = QLabel(self.tab_setting)
696-
self.label_img_format.setObjectName(u"label_img_format")
695+
self.label_epi_rename_rule = QLabel(self.tab_setting)
696+
self.label_epi_rename_rule.setObjectName(u"label_epi_rename_rule")
697697

698-
self.h_Layout_save_prefer.addWidget(self.label_img_format)
698+
self.h_Layout_save_prefer.addWidget(self.label_epi_rename_rule)
699699

700700
self.horizontalSpacer = QSpacerItem(20, 20, QSizePolicy.Policy.Preferred, QSizePolicy.Policy.Minimum)
701701

@@ -715,10 +715,10 @@ def setupUi(self, MainWindow):
715715

716716
self.h_Layout_save_prefer.addItem(self.horizontalSpacer_15)
717717

718-
self.label_epi_rename_rule = QLabel(self.tab_setting)
719-
self.label_epi_rename_rule.setObjectName(u"label_epi_rename_rule")
718+
self.label_img_format = QLabel(self.tab_setting)
719+
self.label_img_format.setObjectName(u"label_img_format")
720720

721-
self.h_Layout_save_prefer.addWidget(self.label_epi_rename_rule)
721+
self.h_Layout_save_prefer.addWidget(self.label_img_format)
722722

723723
self.horizontalSpacer_14 = QSpacerItem(20, 20, QSizePolicy.Policy.Preferred, QSizePolicy.Policy.Minimum)
724724

@@ -1025,13 +1025,13 @@ def retranslateUi(self, MainWindow):
10251025
self.label_6.setText(QCoreApplication.translate("MainWindow", u"\u6587\u4ef6\u9644\u52a0\u4fe1\u606f\uff1a", None))
10261026
self.checkBox_exif_info.setText(QCoreApplication.translate("MainWindow", u"\u662f\u5426\u5728\u4fdd\u5b58\u6587\u4ef6\u5c5e\u6027\u4e2d\u8bb0\u5f55\u7ae0\u8282\u6807\u9898\u3001\u4f5c\u8005\u3001\u51fa\u7248\u793e\u7b49\u9644\u52a0\u4fe1\u606f", None))
10271027
self.checkBox_save_meta.setText(QCoreApplication.translate("MainWindow", u"\u662f\u5426\u521b\u5efa\u6f2b\u753b\u5143\u6570\u636e\u6587\u4ef6", None))
1028-
self.label_img_format.setText(QCoreApplication.translate("MainWindow", u"\u7ae0\u8282\u547d\u540d\u89c4\u5219\uff1a", None))
1028+
self.label_epi_rename_rule.setText(QCoreApplication.translate("MainWindow", u"\u7ae0\u8282\u547d\u540d\u89c4\u5219\uff1a", None))
10291029
self.comboBox_epi_rename_rule.setItemText(0, QCoreApplication.translate("MainWindow", u"\u77ed\u6807\u9898+\u957f\u6807\u9898", None))
10301030
self.comboBox_epi_rename_rule.setItemText(1, QCoreApplication.translate("MainWindow", u"\u5e8f\u53f7+\u957f\u6807\u9898", None))
10311031
self.comboBox_epi_rename_rule.setItemText(2, QCoreApplication.translate("MainWindow", u"\u5e8f\u53f7+\u77ed\u6807\u9898+\u957f\u6807\u9898", None))
10321032
self.comboBox_epi_rename_rule.setItemText(3, QCoreApplication.translate("MainWindow", u"3\u4f4d\u5e8f\u53f7+\u77ed\u6807\u9898+\u957f\u6807\u9898", None))
10331033

1034-
self.label_epi_rename_rule.setText(QCoreApplication.translate("MainWindow", u"\u4e0b\u8f7d\u56fe\u7247\u683c\u5f0f\uff1a", None))
1034+
self.label_img_format.setText(QCoreApplication.translate("MainWindow", u"\u8bf7\u6c42\u56fe\u7247\u683c\u5f0f\uff1a", None))
10351035
self.comboBox_img_format.setItemText(0, QCoreApplication.translate("MainWindow", u"\u539f\u59cb\u683c\u5f0f", None))
10361036
self.comboBox_img_format.setItemText(1, QCoreApplication.translate("MainWindow", u"\u5168\u5c3a\u5bf8jpg", None))
10371037
self.comboBox_img_format.setItemText(2, QCoreApplication.translate("MainWindow", u"\u5168\u5c3a\u5bf8webp", None))

src/ui/SettingUI.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ def _(button: QRadioButton, checked: bool) -> None:
402402
if checked:
403403
self.mainGUI.updateConfig("save_method", button.text())
404404
self.mainGUI.signal_information_box.emit(
405-
"修改成功!重新解析章节后生效"
405+
f"修改成功!重新解析章节后生效"
406406
)
407407

408408
for i in range(self.mainGUI.h_Layout_groupBox_save_method.count()):
@@ -560,12 +560,12 @@ def _(rename_rule: str) -> None:
560560
############################################################
561561

562562
def init_img_format_setting(self) -> None:
563-
"""绑定下载图片格式设置"""
563+
"""绑定请求图片格式设置"""
564564
img_format_list = {
565565
"default": "原始格式",
566-
"10000jpg": "全尺寸jpg",
567-
"10000webp": "全尺寸webp",
568-
"10000avif": "全尺寸avif",
566+
"jpg": "全尺寸jpg",
567+
"webp": "全尺寸webp",
568+
"avif": "全尺寸avif",
569569
"1700jpg": "1700宽jpg",
570570
"1400jpg": "1400宽jpg",
571571
"1100jpg": "1100宽jpg",
@@ -582,6 +582,17 @@ def init_img_format_setting(self) -> None:
582582

583583
def _(img_format: str) -> None:
584584
self.mainGUI.updateConfig("img_format", reversed_img_format_list[img_format])
585+
self.mainGUI.signal_information_box.emit(
586+
f"已成功切换图片质量至 [{img_format}]!重新解析章节后生效\n"
587+
f"注意!此设置对Biliplus不一定有效"
588+
)
589+
if self.mainGUI.getConfig("save_method") == "PDF" and (
590+
img_format.endswith("webp")
591+
or img_format.endswith("avif")
592+
):
593+
self.mainGUI.signal_message_box.emit(
594+
f"请注意!PDF格式保存时,非JPG格式文件会被二次压缩为JPG编码存入PDF",
595+
)
585596

586597
self.mainGUI.comboBox_img_format.currentTextChanged.connect(_)
587598

@@ -596,6 +607,10 @@ def init_hash_check_setting(self) -> None:
596607
self.mainGUI.updateConfig("hash_check", True)
597608

598609
def _(checked: bool) -> None:
610+
if not checked:
611+
self.mainGUI.signal_message_box.emit(
612+
f"请注意!图片下载完整性校验已取消,可能会造成缺页与其它预料之外的严重问题!",
613+
)
599614
self.mainGUI.updateConfig("hash_check", checked)
600615

601616
self.mainGUI.checkBox_hash_check.toggled.connect(_)

0 commit comments

Comments
 (0)