Skip to content

转写本地文件时在“更新索引”阶段崩溃:'NoneType' object has no attribute 'get' #100

Description

@gzq-myy

现象

运行 uv run bili2text tx ./local-video.mp4(本地文件)时,下载/转写本身正常完成,但在最后的“更新索引”阶段报错退出:

出错了: 'NoneType' object has no attribute 'get'

任务记录中失败在 indexing 阶段(register_transcript_result)。

根因

src/b2t/library.py 第 34 行:

title=result.metadata.get("download", {}).get("title") or result.source.display_name,

pipeline.py 第 87 行构造 metadata 时,本地文件(无下载步骤)下 download 键存在但值为 None

"download": downloaded.metadata if downloaded else None,

因此 .get("download", {}) 返回的是 None(键存在、值不为空 dict),随后在 None 上调用 .get("title") 即崩溃。转写 B 站链接(有 download 信息)时不触发,所以本地文件路径 100% 复现。

修复建议

index_existing_workspace 中已有的正确写法保持一致(第 116 行用的是 (data.get("download") or {})):

title=(result.metadata.get("download") or {}).get("title") or result.source.display_name,

环境

  • macOS (Apple Silicon), Python 3.12 (uv)
  • bili2text 0.3.0(main 分支,2026-08 拉取)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions