Skip to content

Commit 2a0a9d4

Browse files
author
Chen
committed
feat: 下载收藏夹时,将收藏夹内的视频放在一个大的文件夹,方便Jellyfin等软件可以识别为一个合集
1 parent f23c311 commit 2a0a9d4

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

app/bilibili.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ async def get_video_page_info(video_id: str) -> Optional[dict]:
7171

7272
@rate_limit()
7373
async def get_season_info(mid: str, season_id: str) -> Optional[List[dict]]:
74-
"""获取视频合集基本信息
74+
"""获取视频合集信息
7575
7676
Args:
7777
mid (str): 合集mid
@@ -273,8 +273,8 @@ async def download_video_pic(video_pic_download_url: str) -> bytes:
273273

274274

275275
@rate_limit()
276-
async def get_video_fav_id(media_id: str) -> dict:
277-
"""获取收藏夹视频列表
276+
async def get_fav_info(media_id: str) -> dict:
277+
"""获取收藏夹信息
278278
279279
Args:
280280
media_id (str): 收藏夹id
@@ -284,7 +284,7 @@ async def get_video_fav_id(media_id: str) -> dict:
284284
"""
285285
has_more = True
286286
page_num = 1
287-
result = []
287+
result = None
288288

289289
async with httpx.AsyncClient() as client:
290290
while True:
@@ -312,10 +312,12 @@ async def get_video_fav_id(media_id: str) -> dict:
312312
if response.get("code") != 0:
313313
return None
314314

315-
response = response["data"]
316-
result += response["medias"]
315+
if result is None:
316+
result = response["data"]
317+
else:
318+
result["medias"] += response["data"]["medias"]
317319

318-
has_more = response["has_more"]
320+
has_more = response["data"]["has_more"]
319321

320322
if not has_more:
321323
break

app/routes.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,14 +178,17 @@ async def add_fav(
178178

179179
media_id = search_result[0]
180180

181-
video_list_info = await bilibili.get_video_fav_id(media_id=media_id)
181+
fav_info = await bilibili.get_fav_info(media_id=media_id)
182+
video_list_info = fav_info["medias"]
183+
fav_name = fav_info["info"]["title"]
182184

183185
video_list = [
184186
Video(
185187
bvid=video.get("bvid"),
186188
pic=video.get("cover"),
187189
title=video.get("title"),
188190
aid=video.get("id"),
191+
belong=fav_name,
189192
)
190193
for video in video_list_info
191194
]

0 commit comments

Comments
 (0)