Skip to content

Commit

Permalink
perf: 修复douyin下载合集时合集链接无法识别的情况
Browse files Browse the repository at this point in the history
  • Loading branch information
Johnserf-Seed committed Apr 5, 2024
1 parent 4b81457 commit eb763eb
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions f2/apps/douyin/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
from f2.apps.douyin.utils import (
SecUserIdFetcher,
AwemeIdFetcher,
MixIdFetcher,
WebCastIdFetcher,
VerifyFpManager,
create_or_rename_user_folder,
Expand Down Expand Up @@ -888,10 +889,21 @@ async def handle_user_mix(self):
page_counts = self.kwargs.get("page_counts", 20)
max_counts = self.kwargs.get("max_counts")

aweme_id = await AwemeIdFetcher.get_aweme_id(self.kwargs.get("url"))
mix_data = await self.fetch_one_video(aweme_id)
sec_user_id = mix_data.get("sec_user_id")
mix_id = mix_data.get("mix_id")
# 先假定合集链接获取合集ID
try:
mix_id = await MixIdFetcher.get_mix_id(self.kwargs.get("url"))
async for aweme_data in self.fetch_user_mix_videos(mix_id, 0, 20, 1):
logger.info(_("正在从合集链接获取合集ID"))
sec_user_id = aweme_data.sec_user_id[0] # 注意这里是一个列表
except Exception as e:
logger.warning(
_("获取合集ID失败,尝试解析作品链接。错误信息:{0}").format(e)
)
# 如果获取失败,则假定作品链接获取作品ID
aweme_id = await AwemeIdFetcher.get_aweme_id(self.kwargs.get("url"))
aweme_data = await self.fetch_one_video(aweme_id)
sec_user_id = aweme_data.sec_user_id
mix_id = aweme_data.mix_id

async with AsyncUserDB("douyin_users.db") as db:
user_path = await self.get_or_add_user_data(self.kwargs, sec_user_id, db)
Expand Down

0 comments on commit eb763eb

Please sign in to comment.