bgetlib is a bilibili API library.
pip install bgetlib
import bgetlib
from bgetlib.models import QualityOptions
bapi = bgetlib.BilibiliAPI("bilibili.com_cookies.txt")
# https://space.bilibili.com/36081646/favlist?fid=976082846
videos = bapi.get_favorites_all(976082846)
quality = QualityOptions()
for video in videos:
video_detail = bapi.get_video(video["id"])
for part in video_detail["pages"]:
bapi.save_stream(video_detail["aid"], part["cid"], quality, f"av{video['id']}-P{part['page']}.mp4")