Module video_uploader.py

  1. from bilibili_api import video_uploader

Web 端视频上传。

VideoUploaderPage

分 P 对象

Functions

def __init__()

name type description
path str 视频流文件路径
title str 视频标题
description str, optional 视频简介. Defaults to “”.

async def get_size()

获取文件大小

Returns: int: 文件大小

class VideoUploaderEvents(Enum)

上传事件枚举

Events:

  • PRE_PAGE 上传分 P 前

  • PREUPLOAD 获取上传信息

  • PREUPLOAD_FAILED 获取上传信息失败

  • PRE_CHUNK 上传分块前

  • AFTER_CHUNK 上传分块后

  • CHUNK_FAILED 区块上传失败

  • PRE_PAGE_SUBMIT 提交分 P 前

  • PAGE_SUBMIT_FAILED 提交分 P 失败

  • AFTER_PAGE_SUBMIT 提交分 P 后

  • AFTER_PAGE 上传分 P 后

  • PRE_COVER 上传封面前

  • AFTER_COVER 上传封面后

  • COVER_FAILED 上传封面失败

  • PRE_SUBMIT 提交视频前

  • SUBMIT_FAILED 提交视频失败

  • AFTER_SUBMIT 提交视频后

  • COMPLETED 完成上传

  • ABORTED 用户中止

  • FAILED 上传失败

class VideoUploader(AsyncEvent)

上传视频

Functions

def __init__()

name type description
pages list[VideoUploaderPage] 分 P 列表
meta dict 视频信息
credential VideoUploaderCredential 凭据(注意,是 VideoUploaderCredential)
cover_path str 路径

meta 参数示例:

  1. {
  2. "act_reserve_create": "const int: 0",
  3. "copyright": "int, 投稿类型。1 自制,2 转载。",
  4. "source": "str: 视频来源。投稿类型为转载时注明来源,为原创时为空。",
  5. "cover": "str: 封面 URL",
  6. "desc": "str: 视频简介。",
  7. "desc_format_id": "const int: 0",
  8. "dynamic": "str: 动态信息。",
  9. "interactive": "const int: 0",
  10. "no_reprint": "int: 显示未经作者授权禁止转载,仅当为原创视频时有效。1 为启用,0 为关闭。",
  11. "open_elec": "int: 是否展示充电信息。1 为是,0 为否。",
  12. "origin_state": "const int: 0",
  13. "subtitles # 字幕设置": {
  14. "lan": "str: 字幕投稿语言,不清楚作用请将该项设置为空",
  15. "open": "int: 是否启用字幕投稿,1 or 0"
  16. },
  17. "tag": "str: 视频标签。使用英文半角逗号分隔的标签组。示例:标签 1,标签 1,标签 1",
  18. "tid": "int: 分区 ID。可以使用 channel 模块进行查询。",
  19. "title": "str: 视频标题",
  20. "up_close_danmaku": "bool: 是否关闭弹幕。",
  21. "up_close_reply": "bool: 是否关闭评论。",
  22. "up_selection_reply": "bool: 是否开启评论精选",
  23. "videos # 分 P 列表": [
  24. {
  25. "title": "str: 标题",
  26. "desc": "str: 简介",
  27. "filename": "str: preupload 时返回的 filename"
  28. }
  29. ],
  30. "dtime": "int?: 可选,定时发布时间戳(秒)"
  31. }

meta 保留字段:videos, cover

async def start()

开始上传

Returns: dict: 返回带有 bvid 和 aid 的字典。

async def abort()

中断上传

async def get_missions()

name type description
tid int, optional 分区 ID. Defaults to 0.
credential Credential, optional 凭据. Defaults to None.

获取活动信息

Returns: dict: API 调用返回结果