mirror of
https://github.com/JoeanAmier/XHS-Downloader.git
synced 2025-12-26 04:48:05 +08:00
1. 移除 sec_ch_ua_platform 参数 2. 移除 sec_ch_ua 参数 3. 优化请求延时间隔 4. 优化并发下载功能 5. 修正英语翻译错误 6. 新增并发下载限制 7. 修正命令行模式错误 8. 简化数据请求头 Closes #86 Closes #87 Closes #93 Closes #98 Closes #105 Closes #109 Closes #110 Closes #140 Closes #152 Closes #154 Closes #157 Closes #159 Closes #160 Closes #162 Closes #164 Closes #165
35 lines
740 B
Python
35 lines
740 B
Python
from asyncio import sleep
|
|
from random import uniform
|
|
|
|
from rich import print
|
|
from rich.text import Text
|
|
|
|
from .static import INFO
|
|
|
|
|
|
def retry(function):
|
|
async def inner(self, *args, **kwargs):
|
|
if result := await function(self, *args, **kwargs):
|
|
return result
|
|
for _ in range(self.retry):
|
|
if result := await function(self, *args, **kwargs):
|
|
return result
|
|
return result
|
|
|
|
return inner
|
|
|
|
|
|
def logging(log, text, style=INFO):
|
|
string = Text(text, style=style)
|
|
if log:
|
|
log.write(string)
|
|
else:
|
|
print(string)
|
|
|
|
|
|
async def sleep_time(
|
|
min_time: int | float = 1,
|
|
max_time: int | float = 3,
|
|
):
|
|
await sleep(uniform(min_time, max_time))
|