diff --git a/README.md b/README.md index 68ce041..feaa5bc 100644 --- a/README.md +++ b/README.md @@ -58,11 +58,11 @@
  • 运行 main.py 即可使用
  • 🕹 用户脚本

    -

    如果您的浏览器安装了 Tampermonkey 浏览器扩展程序,可以添加 用户脚本,无需下载即可体验!

    -

    使用 XHS-Downloader 用户脚本批量获取作品链接,搭配 XHS-Downloader 程序可以实现批量下载无水印作品文件!

    +

    如果您的浏览器安装了 Tampermonkey 浏览器扩展程序,可以添加 用户脚本,无需下载安装即可体验项目功能!

    +

    提示:可以使用 XHS-Downloader 用户脚本批量提取网页上的作品链接,搭配 XHS-Downloader 程序即可实现批量下载无水印作品文件!

    脚本功能

    -XHS-Downloader 是我个人独立维护的一个开源项目,鉴于个人精力有限,请理解项目进展可能较为缓慢,我会尽力保持更新和维护,以确保项目的稳定性和功能的不断改进。 -

    -

    如果您通过 Email 联系我,我可能无法及时查看并回复信息,我会尽力在七天内回复您的邮件;如果有紧急事项或需要更快的回复,请通过其他方式与我联系,谢谢理解!

    如果您对抖音 / TikTok 感兴趣,可以了解一下我的另一个开源项目 TikTokDownloader

    diff --git a/source/TUI/app.py b/source/TUI/app.py index d3d28ff..7aab79e 100644 --- a/source/TUI/app.py +++ b/source/TUI/app.py @@ -35,3 +35,6 @@ class XHSDownloader(App): async def action_settings(self): await self.push_screen("setting") + + async def action_back(self): + await self.push_screen("index") diff --git a/source/TUI/setting.py b/source/TUI/setting.py index ffbc064..40382ac 100644 --- a/source/TUI/setting.py +++ b/source/TUI/setting.py @@ -15,9 +15,13 @@ class Setting(Screen): "static/css/setting.tcss") BINDINGS = [ Binding(key="q", action="quit", description="退出程序"), + Binding(key="b", action="back", description="返回首页"), ] def compose(self) -> ComposeResult: yield Header() - yield Label("我是设置页") + yield Label("我是设置页,敬请期待!") yield Footer() + + def on_mount(self) -> None: + self.title = "程序设置" diff --git a/source/application/Downloader.py b/source/application/Downloader.py index 1771320..b4f2424 100644 --- a/source/application/Downloader.py +++ b/source/application/Downloader.py @@ -12,7 +12,11 @@ __all__ = ['Download'] class Download: CONTENT_TYPE_MAP = { - "quicktime": "mov", + "image/png": "png", + "image/jpeg": "jpg", + "image/webp": "webp", + "application/octet-stream": "", + "video/quicktime": "mov", } def __init__(self, manager: Manager, ): @@ -50,7 +54,7 @@ class Download: try: async with self.session.get(url, proxy=self.proxy) as response: suffix = self.__extract_type( - response.headers.get("Content-Type", "")) or format_ + response.headers.get("Content-Type")) or format_ temp = self.temp.joinpath(name) file = path.joinpath(name).with_suffix(f".{suffix}") if self.manager.is_exists(file): @@ -87,5 +91,4 @@ class Download: @classmethod def __extract_type(cls, content: str) -> str: - return "" if content == "application/octet-stream" else cls.CONTENT_TYPE_MAP.get( - s := content.split("/")[-1], s) + return cls.CONTENT_TYPE_MAP.get(content, "") diff --git a/source/module/__init__.py b/source/module/__init__.py index 071ba6d..ca53528 100644 --- a/source/module/__init__.py +++ b/source/module/__init__.py @@ -24,6 +24,7 @@ from .static import ( from .tools import ( retry, logging, + wait, ) __all__ = [ @@ -50,4 +51,5 @@ __all__ = [ "COOKIE", "retry", "logging", + "wait", ] diff --git a/source/module/tools.py b/source/module/tools.py index a6658ad..48ea6d3 100644 --- a/source/module/tools.py +++ b/source/module/tools.py @@ -1,8 +1,11 @@ +from asyncio import sleep +from random import randint + from rich.text import Text from .static import INFO -__all__ = ["retry", "logging"] +__all__ = ["retry", "logging", "wait"] def retry(function): @@ -23,3 +26,7 @@ def logging(log, text, style=INFO): log.write(string) else: print(string) + + +async def wait(): + await sleep(randint(15, 35) * 0.1)