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

Open Beginner friendly
#100 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
python
Domain
cli

Research direction

Start with src/b2t/library.py line 34 and compare its metadata handling with index_existing_workspace at line 116; pipeline.py line 87 explains the local-file metadata shape. Reproduce with uv run bili2text tx ./local-video.mp4, then verify the local transcription reaches the indexing stage without the NoneType error and records the expected display-name fallback.

Written by the indexing model from the issue text.

Description

现象

运行 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 拉取)
Dominant language
Python
Stars
1.9k
Forks
243
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from lanbinleo/bili2text

All issues in lanbinleo/bili2text

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.