Skip to content

Commit

Permalink
feat: 添加无法查看网页端weibo的异常处理 #223
Browse files Browse the repository at this point in the history
  • Loading branch information
Johnserf-Seed committed Jan 20, 2025
1 parent 5aba482 commit 6f6a719
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions f2/apps/weibo/dl.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ async def handler_download(
# 检查微博是否有图片
if (
self.weibo_data_dict.get("weibo_pic_num") == 0
and weibo_data_dict.get("weibo_pic_ids") == None
and weibo_data_dict.get("is_video") == "11"
):
await self.download_video()
Expand All @@ -119,6 +120,10 @@ async def handler_download(
return

async def download_video(self):
if not self.weibo_data_dict.get("playback_list"):
logger.warning(_("{0} 该微博无法下载,视频走丢了").format(self.weibo_id))
return

logger.debug(
_("清晰度列表:{0},码率列表:{1}").format(
self.weibo_data_dict.get("quality_list"),
Expand Down Expand Up @@ -157,6 +162,12 @@ async def download_desc(self):
)

async def download_images(self):
if not self.weibo_data_dict.get("weibo_pic_ids"):
logger.warning(
_("{0} 该微博无法下载,需要在微博客户端查看").format(self.weibo_id)
)
return

for i, image_url in enumerate(self.weibo_data_dict.get("weibo_pic_ids", [])):
image_name = f"{format_file_name(self.kwargs.get('naming'), self.weibo_data_dict)}_image_{i + 1}"
image_url = WeiboAPIEndpoints.LARGEST + f"/{image_url}"
Expand Down

0 comments on commit 6f6a719

Please sign in to comment.