新增视频/图文作品文件下载开关

This commit is contained in:
JoeanAmier
2024-04-13 13:25:31 +08:00
parent 3b2f1bda9e
commit ea349048c3
13 changed files with 134 additions and 21 deletions

View File

@@ -6,9 +6,11 @@ from textual.widgets import RichLog
from source.application import XHS
from source.module import (
ROOT,
ERROR,
)
from source.module import Settings
from source.module import Translate
from source.module import logging
from .about import About
from .index import Index
from .loading import Loading
@@ -54,6 +56,16 @@ class XHSDownloader(App):
self.install_screen(About(self.message), name="about")
self.install_screen(Record(self.APP, self.message), name="record")
await self.push_screen("index")
self.SETTINGS.check_keys(
self.parameter,
logging,
self.query_one(RichLog),
self.message("配置文件 settings.json 缺少必要的参数,请删除该文件,然后重新运行程序,自动生成默认配置文件!") +
f"\n{
">" *
50}",
ERROR,
)
async def action_settings(self):
async def save_settings(data: dict) -> None:

View File

@@ -107,7 +107,7 @@ class Index(Screen):
@work()
async def deal(self):
await self.app.push_screen("loading")
if any(await self.xhs.extract(self.url.value, True, log=self.tip)):
if any(await self.xhs.extract(self.url.value, True, log=self.tip, data=False, )):
self.url.value = ""
else:
self.tip.write(Text(self.message("下载小红书作品文件失败"), style=ERROR))

View File

@@ -46,7 +46,7 @@ class Monitor(Screen):
@work()
async def run_monitor(self):
await self.xhs.monitor(download=True, log=self.query_one(RichLog))
await self.xhs.monitor(download=True, log=self.query_one(RichLog), data=False, )
self.action_close()
def on_mount(self) -> None:

View File

@@ -27,6 +27,7 @@ class Setting(Screen):
super().__init__()
self.data = data
self.message = message
def compose(self) -> ComposeResult:
yield Header()
yield ScrollableContainer(
@@ -49,15 +50,17 @@ class Setting(Screen):
Label(self.message("请求数据失败时,重试的最大次数"), classes="params", ),
Input(str(self.data["max_retry"]), placeholder="5", type="integer", id="max_retry", ),
Container(
Label("", classes="params", ),
Label("", classes="params", ),
Checkbox(self.message("记录作品数据"), id="record_data", value=self.data["record_data"], ),
Checkbox(self.message("作品文件夹归档模式"), id="folder_mode", value=self.data["folder_mode"], ),
Checkbox(self.message("视频作品下载开关"), id="video_download", value=self.data["video_download"], ),
Checkbox(self.message("图文作品下载开关"), id="image_download", value=self.data["image_download"], ),
classes="horizontal-layout"),
Container(
Label(self.message("图片下载格式"), classes="params", ),
Label(self.message("程序语言"), classes="params", ),
classes="horizontal-layout",
),
Container(
Checkbox(self.message("记录作品数据"), id="record_data", value=self.data["record_data"], ),
Checkbox(self.message("作品文件夹归档模式"), id="folder_mode", value=self.data["folder_mode"], ),
Select.from_values(
("PNG", "WEBP"),
value=self.data["image_format"],
@@ -98,6 +101,8 @@ class Setting(Screen):
"image_format": self.query_one("#image_format").value,
"folder_mode": self.query_one("#folder_mode").value,
"language": self.query_one("#language").value,
"image_download": self.query_one("#image_download").value,
"video_download": self.query_one("#video_download").value,
})
@on(Button.Pressed, "#abandon")