Skip to content

Commit 3cb0e2f

Browse files
authored
Merge pull request #637 from Mirza-Samad-Ahmed-Baig/fix/bilibili-creator-videos
refactor(bilibili): process creator videos in batches
2 parents 66a68fb + 7edf3bc commit 3cb0e2f

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

media_platform/bilibili/core.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -290,16 +290,14 @@ async def get_creator_videos(self, creator_id: int):
290290
"""
291291
ps = 30
292292
pn = 1
293-
video_bvids_list = []
294293
while True:
295294
result = await self.bili_client.get_creator_videos(creator_id, pn, ps)
296-
for video in result["list"]["vlist"]:
297-
video_bvids_list.append(video["bvid"])
298-
if (int(result["page"]["count"]) <= pn * ps):
295+
video_bvids_list = [video["bvid"] for video in result["list"]["vlist"]]
296+
await self.get_specified_videos(video_bvids_list)
297+
if int(result["page"]["count"]) <= pn * ps:
299298
break
300299
await asyncio.sleep(random.random())
301300
pn += 1
302-
await self.get_specified_videos(video_bvids_list)
303301

304302
async def get_specified_videos(self, bvids_list: List[str]):
305303
"""

0 commit comments

Comments
 (0)