earshot-cli 0.8.1__tar.gz → 0.9.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. {earshot_cli-0.8.1 → earshot_cli-0.9.0}/PKG-INFO +1 -1
  2. {earshot_cli-0.8.1 → earshot_cli-0.9.0}/pyproject.toml +1 -1
  3. {earshot_cli-0.8.1 → earshot_cli-0.9.0}/src/earshot/cli.py +13 -4
  4. {earshot_cli-0.8.1 → earshot_cli-0.9.0}/tests/test_wizard.py +26 -0
  5. {earshot_cli-0.8.1 → earshot_cli-0.9.0}/.github/workflows/ci.yml +0 -0
  6. {earshot_cli-0.8.1 → earshot_cli-0.9.0}/.github/workflows/publish.yml +0 -0
  7. {earshot_cli-0.8.1 → earshot_cli-0.9.0}/.gitignore +0 -0
  8. {earshot_cli-0.8.1 → earshot_cli-0.9.0}/LICENSE +0 -0
  9. {earshot_cli-0.8.1 → earshot_cli-0.9.0}/README.md +0 -0
  10. {earshot_cli-0.8.1 → earshot_cli-0.9.0}/scripts/download_models.sh +0 -0
  11. {earshot_cli-0.8.1 → earshot_cli-0.9.0}/src/earshot/__init__.py +0 -0
  12. {earshot_cli-0.8.1 → earshot_cli-0.9.0}/src/earshot/auth.py +0 -0
  13. {earshot_cli-0.8.1 → earshot_cli-0.9.0}/src/earshot/capture.py +0 -0
  14. {earshot_cli-0.8.1 → earshot_cli-0.9.0}/src/earshot/compose.py +0 -0
  15. {earshot_cli-0.8.1 → earshot_cli-0.9.0}/src/earshot/config.py +0 -0
  16. {earshot_cli-0.8.1 → earshot_cli-0.9.0}/src/earshot/deliver.py +0 -0
  17. {earshot_cli-0.8.1 → earshot_cli-0.9.0}/src/earshot/extract.py +0 -0
  18. {earshot_cli-0.8.1 → earshot_cli-0.9.0}/src/earshot/hardsub.py +0 -0
  19. {earshot_cli-0.8.1 → earshot_cli-0.9.0}/src/earshot/live.py +0 -0
  20. {earshot_cli-0.8.1 → earshot_cli-0.9.0}/src/earshot/models.py +0 -0
  21. {earshot_cli-0.8.1 → earshot_cli-0.9.0}/src/earshot/subtitle.py +0 -0
  22. {earshot_cli-0.8.1 → earshot_cli-0.9.0}/src/earshot/transcribe.py +0 -0
  23. {earshot_cli-0.8.1 → earshot_cli-0.9.0}/src/earshot/transcribe_cloud.py +0 -0
  24. {earshot_cli-0.8.1 → earshot_cli-0.9.0}/tests/conftest.py +0 -0
  25. {earshot_cli-0.8.1 → earshot_cli-0.9.0}/tests/test_auth.py +0 -0
  26. {earshot_cli-0.8.1 → earshot_cli-0.9.0}/tests/test_compose.py +0 -0
  27. {earshot_cli-0.8.1 → earshot_cli-0.9.0}/tests/test_config.py +0 -0
  28. {earshot_cli-0.8.1 → earshot_cli-0.9.0}/tests/test_credential_lifecycle.py +0 -0
  29. {earshot_cli-0.8.1 → earshot_cli-0.9.0}/tests/test_deliver.py +0 -0
  30. {earshot_cli-0.8.1 → earshot_cli-0.9.0}/tests/test_deliver_api.py +0 -0
  31. {earshot_cli-0.8.1 → earshot_cli-0.9.0}/tests/test_do_deliver.py +0 -0
  32. {earshot_cli-0.8.1 → earshot_cli-0.9.0}/tests/test_extract.py +0 -0
  33. {earshot_cli-0.8.1 → earshot_cli-0.9.0}/tests/test_hardsub.py +0 -0
  34. {earshot_cli-0.8.1 → earshot_cli-0.9.0}/tests/test_live.py +0 -0
  35. {earshot_cli-0.8.1 → earshot_cli-0.9.0}/tests/test_me.py +0 -0
  36. {earshot_cli-0.8.1 → earshot_cli-0.9.0}/tests/test_subtitle.py +0 -0
  37. {earshot_cli-0.8.1 → earshot_cli-0.9.0}/tests/test_ua.py +0 -0
  38. {earshot_cli-0.8.1 → earshot_cli-0.9.0}/uv.lock +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: earshot-cli
3
- Version: 0.8.1
3
+ Version: 0.9.0
4
4
  Summary: 媒体剪藏:视频字幕/系统声听录/本地音频/硬字幕OCR 四路摄入,端侧转写 → Markdown → 投递知识库(默认 ExoMind,可插拔)
5
5
  Project-URL: Homepage, https://github.com/helloworldtang/earshot
6
6
  Project-URL: Repository, https://github.com/helloworldtang/earshot
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "earshot-cli"
3
- version = "0.8.1"
3
+ version = "0.9.0"
4
4
  description = "媒体剪藏:视频字幕/系统声听录/本地音频/硬字幕OCR 四路摄入,端侧转写 → Markdown → 投递知识库(默认 ExoMind,可插拔)"
5
5
  readme = "README.md"
6
6
  license = "MIT"
@@ -40,10 +40,13 @@ EXIT_NO_CONTENT = 2
40
40
 
41
41
  _LEVEL_BLOCKS = "▁▂▃▄▅▆▇█"
42
42
 
43
+ # 各摄入路线的默认 tag(与来源语义对齐,不再是清一色「旁听」);手动补投无来源,用通用词
44
+ DEFAULT_TAG_BY_SOURCE = {"listen": "旁听", "video": "视频字幕", "audio": "本地转写", "ocr": "硬字幕"}
45
+
43
46
 
44
47
  def _add_common(p: argparse.ArgumentParser) -> None:
45
48
  p.add_argument("--title", help="笔记标题(默认取首句截断)")
46
- p.add_argument("--tag", action="append", default=None, help="投递标签,可多次(默认 旁听)")
49
+ p.add_argument("--tag", action="append", default=None, help="投递标签,可多次(默认按来源定)")
47
50
  p.add_argument("--note", default="", help="来源备注,如「B站·xxx第3期」,写进脚注")
48
51
  p.add_argument("--engine", choices=["local", "server"], default="local", help="转写引擎(默认 local 端侧)")
49
52
  p.add_argument(
@@ -154,7 +157,7 @@ def _run_pipeline(
154
157
 
155
158
  segments = add_punctuation(segments) # 无标点转写(B站AI字幕)按时间轴补齐;已有标点自动跳过
156
159
  title = derive_title(segments, args.title)
157
- tags = args.tag if args.tag else ["旁听"]
160
+ tags = args.tag if args.tag else [DEFAULT_TAG_BY_SOURCE.get(meta.source, "剪藏")]
158
161
  paragraphs = ["".join(s.text for s in group) for group in group_paragraphs(segments, chapter_breaks=chapter_breaks)]
159
162
  md = render_markdown(meta, paragraphs, title)
160
163
 
@@ -444,6 +447,11 @@ def cmd_video(args: argparse.Namespace, settings: Settings) -> int:
444
447
  print(f"✗ {e}")
445
448
  return EXIT_FAIL
446
449
  print(f"→ {meta.title}(UP:{meta.uploader},字幕:{meta.subtitle_lang},{len(segments)} 段)")
450
+ if not segments:
451
+ # 字幕轨 0 条是正确事实(硬字幕烧在画面里),别让用户在这里空手而归——接住最常见的走错路
452
+ print("✗ 该视频无外挂字幕轨(疑似硬字幕烧录)")
453
+ print(f" → 可改走画面识别:earshot ocr {url}")
454
+ return EXIT_NO_CONTENT
447
455
  if not args.title:
448
456
  args.title = meta.title # 视频有正标题,优先于首句截断
449
457
  if not args.note:
@@ -553,7 +561,7 @@ def cmd_deliver(args: argparse.Namespace, settings: Settings) -> int:
553
561
  if not title:
554
562
  first = next((ln[2:].strip() for ln in md.splitlines() if ln.startswith("# ")), "")
555
563
  title = first or md_path.stem
556
- tags = args.tag if args.tag else ["旁听"]
564
+ tags = args.tag if args.tag else ["剪藏"] # 手动补投无来源信息,用通用 tag
557
565
  if args.deliver == "none":
558
566
  print("跳过投递(--deliver none)")
559
567
  return EXIT_OK
@@ -742,7 +750,8 @@ def main(argv: list[str] | None = None) -> int:
742
750
  if not _interactive():
743
751
  parser.print_help()
744
752
  return EXIT_FAIL
745
- choice = _prompt("earshot 模式 [1]视频字幕 [2]听录 [3]本地文件 [4]硬字幕OCR(回车=1;输入 q 退出)", default="1")
753
+ menu = "earshot 模式 [1]视频字幕 [2]听录 [3]本地音视频转写 [4]硬字幕OCR(回车=1;输入 q 退出)"
754
+ choice = _prompt(menu, default="1")
746
755
  if choice == "q":
747
756
  return EXIT_OK
748
757
  mapping = {"1": "video", "2": "listen", "3": "audio", "4": "ocr"}
@@ -1,11 +1,13 @@
1
1
  """交互向导单测:非 tty 的回退行为与裸 earshot 入口。"""
2
2
 
3
+ from datetime import datetime
3
4
  from pathlib import Path
4
5
 
5
6
  import pytest
6
7
 
7
8
  from earshot import cli
8
9
  from earshot.config import Settings
10
+ from earshot.transcribe import Segment
9
11
 
10
12
 
11
13
  def _settings() -> Settings:
@@ -79,3 +81,27 @@ def test_short_url_strips_tracking_and_truncates() -> None:
79
81
  assert cli._short_url(long_q) == "https://www.bilibili.com/video/BV16qpF64E6V/"
80
82
  assert cli._short_url("https://" + "a" * 100).endswith("…")
81
83
  assert len(cli._short_url("https://" + "a" * 100)) == 61
84
+
85
+
86
+ def test_video_no_subtitle_tracks_hints_ocr(monkeypatch: pytest.MonkeyPatch, capsys) -> None: # type: ignore[no-untyped-def]
87
+ """字幕轨 0 条(硬字幕)时不能空手而归:给出可执行的 ocr 改走指引。"""
88
+ from earshot.subtitle import VideoMeta
89
+
90
+ meta = VideoMeta(title="硬字幕视频", uploader="u", duration_s=1.0, url="https://b23.tv/x", subtitle_lang="")
91
+ monkeypatch.setattr(cli, "fetch_video_note", lambda _url, _cookies: (meta, []))
92
+ args = cli.build_parser().parse_args(["video", "https://b23.tv/x", "-y"])
93
+ rc = cli.cmd_video(args, _settings())
94
+ out = capsys.readouterr().out
95
+ assert rc == cli.EXIT_NO_CONTENT
96
+ assert "earshot ocr https://b23.tv/x" in out
97
+
98
+
99
+ def test_run_pipeline_default_tag_follows_source(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None:
100
+ """默认 tag 按摄入路线走(video→视频字幕),不再清一色「旁听」。"""
101
+ captured: dict[str, object] = {}
102
+ monkeypatch.setattr(cli, "_do_deliver", lambda *a: captured.update(tags=a[3]) or 0)
103
+ args = cli.build_parser().parse_args(["video", "https://x", "-y", "--out", str(tmp_path)])
104
+ meta = cli.NoteMeta(started_at=datetime.now(), duration_s=1.0, device="-", source="video", note="")
105
+ rc = cli._run_pipeline([Segment(0.0, 1.0, "内容")], meta, args, _settings())
106
+ assert rc == 0
107
+ assert captured["tags"] == ["视频字幕"]
File without changes
File without changes
File without changes
File without changes