示例:上传视频

  1. from bilibili_api import sync, video_uploader
  2. async def main():
  3. credential = video_uploader.VideoUploaderCredential(account='账号', password='密码')
  4. await credential.login()
  5. # 具体请查阅相关文档
  6. meta = {
  7. "copyright": 1,
  8. "source": "",
  9. "desc": "desc",
  10. "desc_format_id": 0,
  11. "dynamic": "233",
  12. "interactive": 0,
  13. "open_elec": 1,
  14. "no_reprint": 1,
  15. "subtitles": {
  16. "lan": "",
  17. "open": 0
  18. },
  19. "tag": "标签1,标签2,标签3",
  20. "tid": 21,
  21. "title": "title",
  22. "up_close_danmaku": True,
  23. "up_close_reply": True
  24. }
  25. page = video_uploader.VideoUploaderPage(video_stream=open('video.mp4', 'rb'), title='test', description='', extension='mp4')
  26. uploader = video_uploader.VideoUploader([page], meta, credential, threads=1)
  27. @uploader.on("__ALL__")
  28. async def ev(data):
  29. print(data)
  30. await uploader.start()
  31. sync(main())