fix: 修复代码逻辑错误

修正英语项目说明

BREAKING CHANGE: 恢复内置延时机制
This commit is contained in:
JoeanAmier
2024-12-22 15:15:08 +08:00
parent f5e9bc306d
commit 10a09b4c0b
6 changed files with 53 additions and 36 deletions

View File

@@ -255,13 +255,12 @@ class XHS:
if not data:
logging(log, _("{0} 提取数据失败").format(i), ERROR)
return {}
match data["作品类型"]:
case _("视频"):
self.__extract_video(data, namespace)
case _("图文"):
self.__extract_image(data, namespace)
case _:
data["下载地址"] = []
if data["作品类型"] == _("视频"):
self.__extract_video(data, namespace)
elif data["作品类型"] == _("图文"):
self.__extract_image(data, namespace)
else:
data["下载地址"] = []
await self.__download_files(data, download, index, log, bar)
logging(log, _("作品处理完成:{0}").format(i))
await sleep_time()

View File

@@ -71,25 +71,24 @@ class Download:
bar,
) -> tuple[Path, list[Any]]:
path = self.__generate_path(name)
match type_:
case _("视频"):
tasks = self.__ready_download_video(
urls,
path,
name,
log,
)
case _("图文"):
tasks = self.__ready_download_image(
urls,
lives,
index,
path,
name,
log,
)
case _:
raise ValueError
if type_ == _("视频"):
tasks = self.__ready_download_video(
urls,
path,
name,
log,
)
elif type_ == _("图文"):
tasks = self.__ready_download_image(
urls,
lives,
index,
path,
name,
log,
)
else:
raise ValueError
tasks = [
self.__download(
url,

View File

@@ -8,7 +8,9 @@ __all__ = ['Explore']
class Explore:
time_format = "%Y-%m-%d_%H:%M:%S"
explore_type = {"video": _("视频"), "normal": _("图文")}
def __init__(self):
self.explore_type = {"video": _("视频"), "normal": _("图文")}
def run(self, data: Namespace) -> dict:
return self.__extract_data(data)

View File

@@ -1,5 +1,5 @@
# from asyncio import sleep
# from random import uniform
from asyncio import sleep
from random import uniform
from rich import print
from rich.text import Text
@@ -28,8 +28,7 @@ def logging(log, text, style=INFO):
async def sleep_time(
min_time: int | float = 1,
max_time: int | float = 3,
min_time: int | float = 0.5,
max_time: int | float = 1.5,
):
pass
# await sleep(uniform(min_time, max_time))
await sleep(uniform(min_time, max_time))