@clipen/clipen-cli 1.0.0 → 1.0.1

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 (127) hide show
  1. package/README.md +60 -50
  2. package/package.json +7 -4
  3. package/pyproject.toml +18 -2
  4. package/requirements/dev.txt +2 -0
  5. package/src/clipen/__init__.py +1 -1
  6. package/src/clipen/analysis/__init__.py +7 -7
  7. package/src/clipen/analysis/artifacts.py +4 -10
  8. package/src/clipen/analysis/audio.py +10 -8
  9. package/src/clipen/analysis/evidence_service.py +345 -167
  10. package/src/clipen/analysis/image_similarity.py +5 -14
  11. package/src/clipen/analysis/keyframes.py +5 -17
  12. package/src/clipen/analysis/models.py +5 -7
  13. package/src/clipen/analysis/qwen_worker.py +19 -54
  14. package/src/clipen/analysis/resources.py +2 -1
  15. package/src/clipen/analysis/runtime.py +1 -3
  16. package/src/clipen/analysis/service.py +16 -48
  17. package/src/clipen/analysis/setup.py +11 -25
  18. package/src/clipen/analysis/setup_cli.py +5 -15
  19. package/src/clipen/analysis/storage.py +96 -278
  20. package/src/clipen/analysis/transcription.py +40 -82
  21. package/src/clipen/analysis/visual.py +109 -48
  22. package/src/clipen/annotations/__init__.py +5 -2
  23. package/src/clipen/annotations/models.py +1 -1
  24. package/src/clipen/annotations/storage.py +132 -84
  25. package/src/clipen/annotations/suggestions.py +3 -8
  26. package/src/clipen/asr_release.py +4 -11
  27. package/src/clipen/bootstrap.py +65 -54
  28. package/src/clipen/{planning/models.py → candidates.py} +29 -47
  29. package/src/clipen/cli.py +2 -2
  30. package/src/clipen/controller/app.py +401 -214
  31. package/src/clipen/controller/server.py +28 -38
  32. package/src/clipen/domain/__init__.py +1 -1
  33. package/src/clipen/domain/media_time.py +3 -10
  34. package/src/clipen/domain/timeline.py +45 -47
  35. package/src/clipen/domain/validation.py +0 -1
  36. package/src/clipen/editing/__init__.py +1 -1
  37. package/src/clipen/editing/agent_models.py +4 -11
  38. package/src/clipen/editing/agent_repository.py +391 -170
  39. package/src/clipen/editing/agent_tools.py +180 -99
  40. package/src/clipen/editing/alignment.py +92 -52
  41. package/src/clipen/editing/alignment_setup.py +118 -70
  42. package/src/clipen/editing/alignment_worker.py +11 -9
  43. package/src/clipen/editing/change_report.py +95 -38
  44. package/src/clipen/editing/compiler.py +0 -1
  45. package/src/clipen/editing/component_looks.py +58 -34
  46. package/src/clipen/editing/component_review.py +34 -38
  47. package/src/clipen/editing/coordinator.py +213 -90
  48. package/src/clipen/editing/editorial_review.py +217 -95
  49. package/src/clipen/editing/evidence_jobs.py +457 -200
  50. package/src/clipen/editing/history_changes.py +129 -68
  51. package/src/clipen/editing/music_choices.py +8 -5
  52. package/src/clipen/editing/production_catalog.py +573 -136
  53. package/src/clipen/editing/production_limits.py +43 -17
  54. package/src/clipen/editing/production_media.py +376 -167
  55. package/src/clipen/editing/production_preview.py +322 -129
  56. package/src/clipen/editing/production_progress.py +164 -69
  57. package/src/clipen/editing/production_requirements.py +106 -39
  58. package/src/clipen/editing/production_tools.py +1064 -462
  59. package/src/clipen/editing/program_audio.py +211 -81
  60. package/src/clipen/editing/program_direction.py +59 -25
  61. package/src/clipen/editing/program_story.py +83 -45
  62. package/src/clipen/editing/program_subtitles.py +194 -96
  63. package/src/clipen/editing/programme_review.py +98 -50
  64. package/src/clipen/editing/prompt_history.py +64 -27
  65. package/src/clipen/editing/recut.py +65 -25
  66. package/src/clipen/editing/refinement_references.py +176 -86
  67. package/src/clipen/editing/resolve_export.py +449 -218
  68. package/src/clipen/editing/resolve_titles.py +162 -105
  69. package/src/clipen/editing/skill_tools.py +530 -154
  70. package/src/clipen/editing/source_dialogue.py +177 -67
  71. package/src/clipen/editing/speech_coverage.py +42 -22
  72. package/src/clipen/editing/speech_quality.py +6 -1
  73. package/src/clipen/editing/tool_receipts.py +78 -32
  74. package/src/clipen/editing/versions.py +122 -64
  75. package/src/clipen/editing/visual_preview.py +157 -61
  76. package/src/clipen/editing/workbench.py +104 -42
  77. package/src/clipen/finishing/audio.py +69 -30
  78. package/src/clipen/finishing/catalog.py +176 -93
  79. package/src/clipen/finishing/models.py +1 -1
  80. package/src/clipen/finishing/renderer.py +33 -14
  81. package/src/clipen/mcp_editing/__main__.py +3 -1
  82. package/src/clipen/mcp_editing/server.py +77 -34
  83. package/src/clipen/media/__init__.py +3 -3
  84. package/src/clipen/media/discovery.py +7 -20
  85. package/src/clipen/media/models.py +7 -18
  86. package/src/clipen/media/preview.py +14 -24
  87. package/src/clipen/media/probe.py +16 -44
  88. package/src/clipen/media/service.py +6 -19
  89. package/src/clipen/media/storage.py +33 -81
  90. package/src/clipen/music_vocabulary.py +33 -4
  91. package/src/clipen/power.py +8 -3
  92. package/src/clipen/projects/__init__.py +1 -1
  93. package/src/clipen/projects/deletion.py +19 -32
  94. package/src/clipen/projects/finishing_schema.py +3 -1
  95. package/src/clipen/projects/models.py +2 -5
  96. package/src/clipen/projects/picker.py +13 -37
  97. package/src/clipen/projects/service.py +8 -24
  98. package/src/clipen/projects/storage.py +226 -246
  99. package/src/clipen/provider_registry.py +4 -2
  100. package/src/clipen/providers/account.py +86 -35
  101. package/src/clipen/providers/claude.py +59 -25
  102. package/src/clipen/providers/claude_editing.py +14 -7
  103. package/src/clipen/providers/codex.py +73 -118
  104. package/src/clipen/providers/codex_editing.py +2 -2
  105. package/src/clipen/providers/editing_agent.py +19 -17
  106. package/src/clipen/providers/recovery.py +7 -8
  107. package/src/clipen/rendering/cover.py +18 -5
  108. package/src/clipen/rendering/custom_components.py +167 -79
  109. package/src/clipen/rendering/custom_render.py +62 -41
  110. package/src/clipen/rendering/production_effects.py +77 -45
  111. package/src/clipen/rendering/program_components.py +134 -73
  112. package/src/clipen/rendering/program_creator.py +432 -277
  113. package/src/clipen/rendering/program_identities.py +277 -182
  114. package/src/clipen/rendering/program_motion.py +140 -95
  115. package/src/clipen/rendering/program_studio.py +175 -116
  116. package/src/clipen/rendering/program_styles.py +231 -145
  117. package/src/clipen/rendering/program_subtitles.py +71 -34
  118. package/src/clipen/rendering/renderer.py +150 -121
  119. package/src/clipen/rendering/storage.py +9 -22
  120. package/src/clipen/rendering/titles.py +193 -86
  121. package/src/clipen/skills/__init__.py +1 -0
  122. package/src/clipen/skills/catalog.py +151 -55
  123. package/src/clipen/skills/library.py +13 -7
  124. package/src/clipen/skills/package.py +46 -23
  125. package/src/clipen/skills/visual_styles.py +29 -18
  126. package/src/clipen/workspace.py +15 -44
  127. package/src/clipen/planning/__init__.py +0 -9
package/README.md CHANGED
@@ -1,80 +1,90 @@
1
- <div align="center">
1
+ <img width="1440" height="810" alt="Clipen 的九種剪輯樣板" src=".github/assets/templates.jpg" />
2
2
 
3
3
  # Clipen
4
4
 
5
- **讓 AI 幫你剪,讓你決定怎麼剪。**
5
+ 讓 AI 幫你剪,讓你決定怎麼剪。選一個剪輯樣板、交出自己的素材,Clipen 用你已經在用的 Claude Code 或 Codex 製作影片;看片時在畫面上記下想改的地方,AI 就照著改。
6
6
 
7
- 從剪輯樣板與自己的素材出發,讓 AI 製作影片,再透過審片注記調整作品。
7
+ 一切都在你的 Mac 上:素材不上傳,語音辨識在本機跑。
8
8
 
9
- [產品架構](ARCHITECTURE.md) · [MIT 授權](LICENSE) · [回報問題](https://github.com/IMGMANISME/clipen/issues)
9
+ ```bash
10
+ npx @clipen/clipen-cli
11
+ cd 要存放作品的資料夾
12
+ clipen claude # 或 clipen codex
13
+ ```
10
14
 
11
- </div>
15
+ [產品架構](ARCHITECTURE.md) · [回報問題](https://github.com/IMGMANISME/clipen/issues) · [npm](https://www.npmjs.com/package/@clipen/clipen-cli)
12
16
 
13
- ---
17
+ ## 剪輯樣板
14
18
 
15
- Clipen v1.0.0 是本機 AI 剪輯工作台。選擇剪輯樣板、提供素材與需求,使用 Codex
16
- 或 Claude 製作影片,再透過影片時間點與畫面元素記下修改要求,下載完成的影片。
19
+ 製作影片時先選一個樣板,再寫下這次想要的影片。樣板決定故事怎麼說、節奏、字幕與畫面設計;你寫的需求永遠優先。
17
20
 
18
- | 理解你的素材 | 樣板製作與審片修改 | 保留作品控制權 |
19
- | --- | --- | --- |
20
- | 分析畫面、聲音、逐字稿與參考風格。 | 選擇樣板與視覺風格,透過注記調整片段、字幕與聲音。 | 查看歷史版本、下載成片與剪輯資料。 |
21
+ 內建九種:旅遊 vlog、美食探店、日常 vlog、產品評測、活動紀錄、短影音精華、產品開箱、旅遊精華與產品 demo。
21
22
 
22
- 尚未提供獨立桌面安裝包。DaVinci Resolve 工程匯出尚未提供;目前可下載 Clipen 的剪輯資料。
23
+ - **加入自己的樣板。** 在作品首頁的「我的剪輯樣板」加入別人分享或自己做的樣板,所有工作區都能用。
24
+ - **只有文字和參考圖。** Clipen 不會執行樣板裡的任何程式;影片開始製作後,更新或移除樣板都不影響這支影片。
25
+ - **格式和 Agent Skills 相同。** 可以從 [`examples/skills/`](examples/skills) 的範例開始改。
23
26
 
24
- ## 安裝
27
+ ## 審片注記
25
28
 
26
- 需要 Apple 晶片(M 系列)的 Mac、[Node.js](https://nodejs.org) 18 以上,以及已登入的
27
- [Claude Code](https://claude.com/claude-code) 或 [Codex CLI](https://github.com/openai/codex)。
29
+ 邊看影片邊在時間點上留注記:要修改、拿掉、這樣可以、加強爆點、地點補充、聲音或其他。注記可以指向整個鏡頭,也可以指向某個字幕或畫面元件,送出後 AI 會逐筆處理。
28
30
 
29
- ```bash
30
- npx @clipen/clipen-cli
31
- ```
31
+ - **每次修改都有說明。** AI 改完要交代改了什麼、為什麼,並逐筆回覆每則注記是否處理。
32
+ - **不會隨便留下「未處理」。** 只有需要你決定或提供、或 Clipen 確實做不到的事才能留下,而且會帶到下一次修改。
33
+ - **版本隨時可回去。** 每次 AI 製作、手動修改和還原都會留下一個版本,可以看、可以下載。
34
+
35
+ ## 時間線與元件
36
+
37
+ 字卡、地點標示和其他畫面元件都在時間線上,可以直接拖曳、拉長,或移到另一軌疊在上面。
32
38
 
33
- 沒有 Python 3.10 以上時,Clipen 會下載一份固定版本的 Python,不會動到系統 Python,也不需要
34
- sudo。程式放在 `~/Library/Application Support/Clipen`,字型從原始來源下載並核對檢查碼,接著
35
- 安裝本機語音辨識模型(約 3 GB)與全域指令 `clipen`。沒有 Google Chrome 時會改裝 Chromium;
36
- 沒有 ffmpeg 時會提示安裝方式(`brew install ffmpeg`)。
39
+ - **元件外觀** 是一組字型與配色,AI 做的每個元件都要套用其中一組,風格才會一致。
40
+ - **內附 13 套字型**,包含中文、日文手寫與標題字體,在任何一台 Mac 上看起來都一樣。
41
+ - **手動修改** 文字、時間與外觀後,AI 下一次修改會保留你的調整。
37
42
 
38
- 安裝完成後開一個新的終端機視窗,進入要存放作品資料的目錄,再以 `clipen claude` 或
39
- `clipen codex` 啟動本機工作台(分別使用 Claude Code 或 Codex CLI 的登入與額度)。
40
- 之後要更新,再執行一次 `npx @clipen/clipen-cli@latest`。
43
+ ## 其他
41
44
 
42
- 從 source checkout 安裝時,改為執行 `./install`,其餘相同。
45
+ - 本機語音辨識產生逐字稿與字幕,素材不離開你的電腦
46
+ - 指定自己的配樂,AI 會依歌曲長度安排段落與淡入淡出
47
+ - 下載這一版影片(MP4)或 Clipen 的剪輯資料,也可以匯出到 DaVinci Resolve 繼續剪
48
+ - 作品存在該資料夾的 `.clipen` 子目錄,毛片留在原本的位置
49
+ - 只有在你從畫面上確認後才呼叫 AI,使用 Claude Code 或 Codex 自己的登入與額度
43
50
 
44
- ## 使用
51
+ ## 安裝
45
52
 
46
- Clipen 只會在該目錄的 `.clipen`
47
- 子目錄保存作品;毛片與參考作品仍留在使用者選取的位置。只有在使用者從 UI 確認
48
- 特定步驟後才呼叫 AI;不需要開啟 AI 對話或手動架設本機服務。
49
- 每次啟動都會先驗證該工作區內的作品;空工作區可直接進入 UI 建立第一個作品,
50
- 若作品資料損壞或無法識別則會停止啟動,且不會自行刪除或覆蓋資料。
53
+ 需要 Apple 晶片(M 系列)的 Mac、[Node.js](https://nodejs.org) 18 以上,以及已登入的 [Claude Code](https://claude.com/claude-code) 或 [Codex CLI](https://github.com/openai/codex)。
51
54
 
52
- 只有版本號、介面或一般程式碼更新時,可直接沿用已安裝的執行環境。依賴套件或安裝設定
53
- 變更、執行環境缺損時,啟動器才會提示重新安裝(`npx @clipen/clipen-cli` 或 `./install`);既有作品資料會保留。
55
+ `npx @clipen/clipen-cli` 會在沒有 Python 3.10 以上時下載一份固定版本的 Python,不動系統 Python,也不需要 sudo。程式放在 `~/Library/Application Support/Clipen`,字型從原始來源下載並核對檢查碼,接著安裝本機語音辨識模型(約 3 GB)與全域指令 `clipen`。沒有 Google Chrome 時會改裝 Chromium;沒有 ffmpeg 時會提示安裝方式(`brew install ffmpeg`)。
54
56
 
55
- ## 選一個剪輯樣板
57
+ | 指令 | 做什麼 |
58
+ | --- | --- |
59
+ | `clipen claude`/`clipen codex` | 在目前資料夾啟動工作台 |
60
+ | `npx @clipen/clipen-cli@latest` | 更新到最新版,作品資料保留 |
61
+ | `clipen uninstall` | 移除程式、語音模型與指令,保留作品、毛片與匯出檔案 |
56
62
 
57
- 製作影片時,在「AI 節目製作」頁選一個剪輯樣板,再寫下這次想要的影片。樣板決定故事怎麼說、
58
- 節奏、字幕與畫面設計;你寫的需求永遠優先。
63
+ 每次啟動都會先檢查這個資料夾裡的作品;作品資料損壞或無法辨識時會停止啟動,不會自行刪除或覆蓋。
59
64
 
60
- 除了內建樣板,也可以在作品首頁的「我的剪輯樣板」加入別人分享或自己做的樣板,所有工作區
61
- 都能使用。樣板只包含文字說明與參考圖,Clipen 不會執行裡面的任何程式;影片開始製作後,
62
- 之後更新或移除樣板都不影響這支影片。Codex 與 Claude 讀到的樣板內容相同。
65
+ ## 開發
63
66
 
64
- 想自己做樣板,可以參考 [`examples/skills/`](examples/skills) 的範例;格式和 Claude、
65
- Codex 使用的 Agent Skills 相同。
67
+ | 路徑 | 內容 |
68
+ | --- | --- |
69
+ | [`src/clipen`](src/clipen) | Python 後端:本機服務、素材分析、AI 製作工具與算圖 |
70
+ | [`apps/web`](apps/web) | 工作台介面(React + Vite) |
71
+ | [`bin/clipen.js`](bin/clipen.js) | `npx` 安裝器:準備 Python、程式與字型 |
72
+ | [`examples/skills`](examples/skills) | 自訂剪輯樣板的範例 |
73
+ | [`tests`](tests) | Python 與 npm 套件測試 |
66
74
 
67
- `clipen uninstall`(source checkout 為 `./uninstall`)會移除 Clipen runtime、本機語音模型、全域指令與 PATH 設定,但會
68
- 保留作品資料、毛片、參考作品與匯出檔案。
75
+ ```bash
76
+ ./install # 從原始碼安裝
77
+ PYTHONPATH=src:tests/python .venv/bin/python -m unittest discover -s tests/python
78
+ cd apps/web && npm run build && npm run lint && npm test
79
+ npm run release -- patch # 準備新版本:改版本號、重建、測試、發布試跑
80
+ ```
69
81
 
70
- 系統設計、資料權限、中斷恢復、`clean`/`reset` 與 Resolve 交付規則請見
71
- [產品架構基準](ARCHITECTURE.md)。
82
+ 系統設計、資料權限、中斷恢復與交付規則見 [產品架構基準](ARCHITECTURE.md)。
72
83
 
73
- 有想改善的剪輯情境,歡迎留下[問題或建議](https://github.com/IMGMANISME/clipen/issues)。
74
- 請勿附上私人素材、帳號憑證、逐字稿或本機完整路徑。
84
+ 有想改善的剪輯情境,歡迎留下[問題或建議](https://github.com/IMGMANISME/clipen/issues)。請勿附上私人素材、帳號憑證、逐字稿或本機完整路徑。
75
85
 
76
86
  ## 授權
77
87
 
78
- Clipen 以 [MIT 授權](LICENSE)開源。內附字型各自採用 SIL Open Font License,授權全文放在
79
- [`src/clipen/rendering/fonts/`](src/clipen/rendering/fonts),來源記錄在同一目錄的 `manifest.json`。
88
+ MIT © [GMAN](https://github.com/IMGMANISME)
80
89
 
90
+ 內附字型各自採用 SIL Open Font License,授權全文與來源在 [`src/clipen/rendering/fonts/`](src/clipen/rendering/fonts)。
package/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "@clipen/clipen-cli",
3
- "version": "1.0.0",
4
- "description": "Clipen:本機 AI 剪輯工作台",
3
+ "version": "1.0.1",
4
+ "description": "讓 AI 用 Claude Code 或 Codex 幫你剪影片,再用時間線上的審片注記修改",
5
5
  "keywords": [
6
6
  "video-editing",
7
7
  "ai",
8
- "claude",
8
+ "claude-code",
9
9
  "codex",
10
10
  "vlog",
11
+ "local-first",
11
12
  "cli"
12
13
  ],
13
14
  "homepage": "https://github.com/IMGMANISME/clipen#readme",
@@ -46,7 +47,9 @@
46
47
  "arm64"
47
48
  ],
48
49
  "scripts": {
49
- "test": "node --test tests/npm/"
50
+ "prepack": "npm --prefix apps/web run build 1>&2",
51
+ "test": "node --test tests/npm/",
52
+ "release": "node scripts/release.mjs"
50
53
  },
51
54
  "publishConfig": {
52
55
  "access": "public"
package/pyproject.toml CHANGED
@@ -4,11 +4,22 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "clipen"
7
- version = "1.0.0"
8
- description = "Local AI-assisted video editing workspace"
7
+ version = "1.0.1"
8
+ description = "Let AI cut your video with Claude Code or Codex, and review it with notes on the timeline"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
11
11
  license = { text = "MIT" }
12
+ authors = [{ name = "GMAN" }]
13
+ keywords = ["video-editing", "ai", "claude-code", "codex", "vlog", "local-first"]
14
+ classifiers = [
15
+ "Development Status :: 5 - Production/Stable",
16
+ "Environment :: MacOS X",
17
+ "Intended Audience :: End Users/Desktop",
18
+ "License :: OSI Approved :: MIT License",
19
+ "Operating System :: MacOS",
20
+ "Programming Language :: Python :: 3",
21
+ "Topic :: Multimedia :: Video :: Non-Linear Editor",
22
+ ]
12
23
  dependencies = [
13
24
  "cryptography==50.0.1",
14
25
  "jsonschema==4.26.0",
@@ -18,6 +29,11 @@ dependencies = [
18
29
  "uvicorn==0.52.4",
19
30
  ]
20
31
 
32
+ [project.urls]
33
+ Homepage = "https://github.com/IMGMANISME/clipen"
34
+ Issues = "https://github.com/IMGMANISME/clipen/issues"
35
+ npm = "https://www.npmjs.com/package/@clipen/clipen-cli"
36
+
21
37
  [tool.setuptools.packages.find]
22
38
  where = ["src"]
23
39
 
@@ -0,0 +1,2 @@
1
+ # Tools for working on Clipen itself; the app does not need them.
2
+ ruff==0.14.6
@@ -1,3 +1,3 @@
1
1
  """Clipen product package."""
2
2
 
3
- __version__ = "1.0.0"
3
+ __version__ = "1.0.1"
@@ -13,6 +13,7 @@ from .audio import (
13
13
  inspect_normalized_audio,
14
14
  project_samples_to_source,
15
15
  )
16
+ from .keyframes import AdaptiveKeyframeSelector, KeyframeCandidate, KeyframeSelection
16
17
  from .models import (
17
18
  ArtifactKind,
18
19
  ArtifactRecord,
@@ -23,7 +24,9 @@ from .models import (
23
24
  PreparationState,
24
25
  TimelineSegment,
25
26
  )
26
- from .keyframes import AdaptiveKeyframeSelector, KeyframeCandidate, KeyframeSelection
27
+ from .runtime import ManagedAnalysisRuntime
28
+ from .service import PreparationCoordinator, PreparationRecipe
29
+ from .setup import ASRSetupError, ASRSetupManager, ASRSetupState, ASRSetupStatus
27
30
  from .storage import (
28
31
  PreparationChunk,
29
32
  PreparationRepository,
@@ -31,16 +34,13 @@ from .storage import (
31
34
  PreparationTarget,
32
35
  PreparationWorkItem,
33
36
  )
34
- from .service import PreparationCoordinator, PreparationRecipe
35
- from .runtime import ManagedAnalysisRuntime
36
- from .setup import ASRSetupError, ASRSetupManager, ASRSetupState, ASRSetupStatus
37
37
  from .transcription import (
38
- Qwen3ASRAdapter,
39
38
  LocalModelSnapshot,
40
- TranscriptSegment,
41
- TranscriptWord,
39
+ Qwen3ASRAdapter,
42
40
  TranscriptionError,
43
41
  TranscriptionResult,
42
+ TranscriptSegment,
43
+ TranscriptWord,
44
44
  hash_model_directory,
45
45
  )
46
46
 
@@ -3,14 +3,14 @@
3
3
  from __future__ import annotations
4
4
 
5
5
  import hashlib
6
- from functools import wraps
7
6
  import json
8
7
  import os
9
- from pathlib import Path
10
8
  import re
11
9
  import secrets
12
10
  import stat
13
11
  import threading
12
+ from functools import wraps
13
+ from pathlib import Path
14
14
  from typing import Callable, Iterable, Mapping, TypeVar
15
15
 
16
16
  from clipen.filesystem import restrict_permissions
@@ -26,7 +26,6 @@ from .models import (
26
26
  validate_recipe_id,
27
27
  )
28
28
 
29
-
30
29
  _READ_SIZE = 1024 * 1024
31
30
  _BLOB_PATH = re.compile(r"artifacts/sha256/([0-9a-f]{2})/([0-9a-f]{64})\Z")
32
31
  _STORE_LOCKS_GUARD = threading.Lock()
@@ -228,9 +227,7 @@ class ArtifactStore:
228
227
  with self.projects.connect(project_id) as connection:
229
228
  live = {
230
229
  row["relative_path"]
231
- for row in connection.execute(
232
- "SELECT DISTINCT relative_path FROM artifacts"
233
- ).fetchall()
230
+ for row in connection.execute("SELECT DISTINCT relative_path FROM artifacts").fetchall()
234
231
  }
235
232
  project_root = self._project_root(project_id)
236
233
  removed = 0
@@ -239,10 +236,7 @@ class ArtifactStore:
239
236
  try:
240
237
  parent = candidate.parent.resolve(strict=True)
241
238
  expected_parent = project_root / "artifacts" / "sha256" / candidate.parent.name
242
- if (
243
- parent != expected_parent
244
- or candidate.is_symlink()
245
- ):
239
+ if parent != expected_parent or candidate.is_symlink():
246
240
  continue
247
241
  info = os.lstat(candidate)
248
242
  if not stat.S_ISREG(info.st_mode) or info.st_nlink != 1:
@@ -2,11 +2,8 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
- from dataclasses import dataclass
6
- from fractions import Fraction
7
5
  import math
8
6
  import os
9
- from pathlib import Path
10
7
  import re
11
8
  import shutil
12
9
  import signal
@@ -15,18 +12,19 @@ import subprocess
15
12
  import tempfile
16
13
  import threading
17
14
  import time
18
- from typing import Callable
19
15
  import wave
16
+ from dataclasses import dataclass
17
+ from fractions import Fraction
18
+ from pathlib import Path
19
+ from typing import Callable
20
20
 
21
+ from clipen.domain.media_time import Rational, SourceSpan
21
22
  from clipen.media import InventoryRoot, bounded_file_fingerprint
22
23
  from clipen.media.discovery import DiscoveryError, open_file_beneath
23
24
  from clipen.media.models import validate_relative_path
24
25
 
25
26
  from .resources import local_analysis_slot
26
27
 
27
- from .models import Rational, SourceSpan
28
-
29
-
30
28
  _VERSION_ID = re.compile(r"av_[0-9a-f]{32}\Z")
31
29
  _POLL_SECONDS = 0.05
32
30
  _MAX_CAPTURE_BYTES = 1024 * 1024
@@ -200,7 +198,11 @@ class FFmpegAudioAdapter:
200
198
  *,
201
199
  observed_output: Path | None = None,
202
200
  ) -> tuple[bytes, bytes, int]:
203
- with local_analysis_slot(cancel, lambda: AudioPreparationError("cancelled")), tempfile.TemporaryFile() as stdout_file, tempfile.TemporaryFile() as stderr_file:
201
+ with (
202
+ local_analysis_slot(cancel, lambda: AudioPreparationError("cancelled")),
203
+ tempfile.TemporaryFile() as stdout_file,
204
+ tempfile.TemporaryFile() as stderr_file,
205
+ ):
204
206
  deadline = time.monotonic() + self.timeout_seconds
205
207
  try:
206
208
  process = subprocess.Popen(