mirror of
https://github.com/JoeanAmier/XHS-Downloader.git
synced 2026-03-22 06:57:16 +08:00
fix: 修复代码逻辑错误
修正英语项目说明 BREAKING CHANGE: 恢复内置延时机制
This commit is contained in:
22
README_EN.md
22
README_EN.md
@@ -283,8 +283,8 @@ async def example():
|
|||||||
<tr>
|
<tr>
|
||||||
<td align="center">name_format</td>
|
<td align="center">name_format</td>
|
||||||
<td align="center">str</td>
|
<td align="center">str</td>
|
||||||
<td align="center">Format for content file names. Separate fields with spaces. Supported fields: <code>collects</code>, <code>comments</code>, <code>shares</code>, <code>likes</code>, <code>tags</code>, <code>ID</code>, <code>title</code>, <code>description</code>, <code>type</code>, <code>publish_time</code>, <code>last_update_time</code>, <code>author_nickname</code>, <code>author_id</code></td>
|
<td align="center"><sup><a href="#fields">1</a></sup>Format of works file name, separated by spaces between fields, supports fields: <code>收藏数量</code>、<code>评论数量</code>、<code>分享数量</code>、<code>点赞数量</code>、<code>作品标签</code>、<code>作品ID</code>、<code>作品标题</code>、<code>作品描述</code>、<code>作品类型</code>、<code>发布时间</code>、<code>最后更新时间</code>、<code>作者昵称</code>、<code>作者ID</code></td>
|
||||||
<td align="center"><code>publish_time author_nickname title</code></td>
|
<td align="center"><code>发布时间 作者昵称 作品标题</code></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td align="center">user_agent</td>
|
<td align="center">user_agent</td>
|
||||||
@@ -372,6 +372,24 @@ async def example():
|
|||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
<div id="fields">
|
||||||
|
<p>name_format instructions (Currently only supports Chinese values) :</p>
|
||||||
|
<ul>
|
||||||
|
<li><code>收藏数量</code>: Number of Collections</li>
|
||||||
|
<li><code>评论数量</code>: Number of Comments</li>
|
||||||
|
<li><code>分享数量</code>: Number of Shares</li>
|
||||||
|
<li><code>点赞数量</code>: Number of Likes</li>
|
||||||
|
<li><code>作品标签</code>: Works Tags</li>
|
||||||
|
<li><code>作品ID</code>: Works ID</li>
|
||||||
|
<li><code>作品标题</code>: Works Title</li>
|
||||||
|
<li><code>作品描述</code>: Works Description</li>
|
||||||
|
<li><code>作品类型</code>: Works Type</li>
|
||||||
|
<li><code>发布时间</code>: Publish Time</li>
|
||||||
|
<li><code>最后更新时间</code>: Last Updated Time</li>
|
||||||
|
<li><code>作者昵称</code>: Author Nickname</li>
|
||||||
|
<li><code>作者ID</code>: Author ID</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
<p><b>Additional Notes: The parameters <code>user_agent</code> examples are provided for reference; Strongly recommend setting according to actual browser information!</b></p>
|
<p><b>Additional Notes: The parameters <code>user_agent</code> examples are provided for reference; Strongly recommend setting according to actual browser information!</b></p>
|
||||||
<img src="static/screenshot/请求头示例图.png" alt="">
|
<img src="static/screenshot/请求头示例图.png" alt="">
|
||||||
<h1>🌐 Cookie</h1>
|
<h1>🌐 Cookie</h1>
|
||||||
|
|||||||
@@ -255,13 +255,12 @@ class XHS:
|
|||||||
if not data:
|
if not data:
|
||||||
logging(log, _("{0} 提取数据失败").format(i), ERROR)
|
logging(log, _("{0} 提取数据失败").format(i), ERROR)
|
||||||
return {}
|
return {}
|
||||||
match data["作品类型"]:
|
if data["作品类型"] == _("视频"):
|
||||||
case _("视频"):
|
self.__extract_video(data, namespace)
|
||||||
self.__extract_video(data, namespace)
|
elif data["作品类型"] == _("图文"):
|
||||||
case _("图文"):
|
self.__extract_image(data, namespace)
|
||||||
self.__extract_image(data, namespace)
|
else:
|
||||||
case _:
|
data["下载地址"] = []
|
||||||
data["下载地址"] = []
|
|
||||||
await self.__download_files(data, download, index, log, bar)
|
await self.__download_files(data, download, index, log, bar)
|
||||||
logging(log, _("作品处理完成:{0}").format(i))
|
logging(log, _("作品处理完成:{0}").format(i))
|
||||||
await sleep_time()
|
await sleep_time()
|
||||||
|
|||||||
@@ -71,25 +71,24 @@ class Download:
|
|||||||
bar,
|
bar,
|
||||||
) -> tuple[Path, list[Any]]:
|
) -> tuple[Path, list[Any]]:
|
||||||
path = self.__generate_path(name)
|
path = self.__generate_path(name)
|
||||||
match type_:
|
if type_ == _("视频"):
|
||||||
case _("视频"):
|
tasks = self.__ready_download_video(
|
||||||
tasks = self.__ready_download_video(
|
urls,
|
||||||
urls,
|
path,
|
||||||
path,
|
name,
|
||||||
name,
|
log,
|
||||||
log,
|
)
|
||||||
)
|
elif type_ == _("图文"):
|
||||||
case _("图文"):
|
tasks = self.__ready_download_image(
|
||||||
tasks = self.__ready_download_image(
|
urls,
|
||||||
urls,
|
lives,
|
||||||
lives,
|
index,
|
||||||
index,
|
path,
|
||||||
path,
|
name,
|
||||||
name,
|
log,
|
||||||
log,
|
)
|
||||||
)
|
else:
|
||||||
case _:
|
raise ValueError
|
||||||
raise ValueError
|
|
||||||
tasks = [
|
tasks = [
|
||||||
self.__download(
|
self.__download(
|
||||||
url,
|
url,
|
||||||
|
|||||||
@@ -8,7 +8,9 @@ __all__ = ['Explore']
|
|||||||
|
|
||||||
class Explore:
|
class Explore:
|
||||||
time_format = "%Y-%m-%d_%H:%M:%S"
|
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:
|
def run(self, data: Namespace) -> dict:
|
||||||
return self.__extract_data(data)
|
return self.__extract_data(data)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# from asyncio import sleep
|
from asyncio import sleep
|
||||||
# from random import uniform
|
from random import uniform
|
||||||
|
|
||||||
from rich import print
|
from rich import print
|
||||||
from rich.text import Text
|
from rich.text import Text
|
||||||
@@ -28,8 +28,7 @@ def logging(log, text, style=INFO):
|
|||||||
|
|
||||||
|
|
||||||
async def sleep_time(
|
async def sleep_time(
|
||||||
min_time: int | float = 1,
|
min_time: int | float = 0.5,
|
||||||
max_time: int | float = 3,
|
max_time: int | float = 1.5,
|
||||||
):
|
):
|
||||||
pass
|
await sleep(uniform(min_time, max_time))
|
||||||
# await sleep(uniform(min_time, max_time))
|
|
||||||
|
|||||||
@@ -7,4 +7,4 @@
|
|||||||
5. 重构项目翻译模块
|
5. 重构项目翻译模块
|
||||||
6. 更正英语语言代码
|
6. 更正英语语言代码
|
||||||
7. 优化文件下载功能
|
7. 优化文件下载功能
|
||||||
8. 移除内置延时机制
|
8. 降低内置延时机制
|
||||||
|
|||||||
Reference in New Issue
Block a user