修复批量下载功能

This commit is contained in:
JoeamAmier
2023-09-09 17:38:41 +08:00
parent 8e66c1d293
commit 81b4b390ef
4 changed files with 11 additions and 6 deletions

View File

@@ -9,6 +9,7 @@
<li>下载小红书图文/视频作品文件</li> <li>下载小红书图文/视频作品文件</li>
<li>自动跳过已存在的作品文件</li> <li>自动跳过已存在的作品文件</li>
<li>作品文件完整性处理机制</li> <li>作品文件完整性处理机制</li>
<li>批量下载小红书作品文件</li>
</ul> </ul>
<h1>📸 程序截图</h1> <h1>📸 程序截图</h1>
<br> <br>

View File

@@ -44,7 +44,7 @@ def main():
xhs = XHS(**Settings().run()) xhs = XHS(**Settings().run())
if ids := Batch().read_txt(): if ids := Batch().read_txt():
for i in ids: for i in ids:
xhs.extract(i, download=True) xhs.extract(i.rstrip('\n'), download=True)
else: else:
while True: while True:
if url := input("请输入小红书作品链接:"): if url := input("请输入小红书作品链接:"):

View File

@@ -20,11 +20,12 @@ class Explore:
def __extract_data(self, data: dict) -> dict: def __extract_data(self, data: dict) -> dict:
result = {} result = {}
self.__extract_interact_info(result, data) if data:
self.__extract_tags(result, data) self.__extract_interact_info(result, data)
self.__extract_info(result, data) self.__extract_tags(result, data)
self.__extract_time(result, data) self.__extract_info(result, data)
self.__extract_user(result, data) self.__extract_time(result, data)
self.__extract_user(result, data)
return result return result
@staticmethod @staticmethod

View File

@@ -56,6 +56,9 @@ class XHS:
if not html: if not html:
return {} return {}
data = self.explore.run(html) data = self.explore.run(html)
if not data:
print(f"获取作品数据失败: {url}")
return {}
if data["作品类型"] == "视频": if data["作品类型"] == "视频":
self.__get_video(data, html, download) self.__get_video(data, html, download)
else: else: