chore: 项目更名为 SceneMarshal

- README/脚本注释/LICENSE/图标文件名统一改名
- 右键菜单注册项改为 SceneMarshal / SceneMarshalArchive
- media_archive 支持 SCENEMARSHAL_* 环境变量(保留旧变量兼容)
- README 补充 preflight/字幕/字体/归档等实际能力与 check 用法
This commit is contained in:
ali
2026-11-19 12:21:42 +08:00
parent ed59d4d280
commit e66d082f31
10 changed files with 49 additions and 34 deletions
+1 -1
View File
@@ -219,7 +219,7 @@ If you develop a new program, and you want it to be of the greatest possible use
To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found.
SceneRename SceneMarshal
Copyright (C) 2026 ali Copyright (C) 2026 ali
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+30 -15
View File
@@ -1,6 +1,6 @@
# 🎬 SceneRename # 🎬 SceneMarshal
<img src="assets/scenerename.png" width="112" alt="SceneRename logo"> <img src="assets/scenemarshal.png" width="112" alt="SceneMarshal logo">
![Python Version](https://img.shields.io/badge/python-3.11%2B-blue.svg) ![Python Version](https://img.shields.io/badge/python-3.11%2B-blue.svg)
![Docker Ready](https://img.shields.io/badge/Docker-Ready-2496ED.svg?logo=docker&logoColor=white) ![Docker Ready](https://img.shields.io/badge/Docker-Ready-2496ED.svg?logo=docker&logoColor=white)
@@ -8,17 +8,25 @@
## 项目简介 ## 项目简介
SceneRename 是一款专注于高阶本地流媒体库自动化整理与刮削的 Python 强驱动工具,尤其适合部署在 Home Lab 的 NAS 或 Debian 服务器环境。项目通过智能解析目录与文件名,不仅能精准联动 TMDB 补全元数据并执行重命名,还深度集成了 4K REMUX 场景化打标、内置广告元数据抹除、以及高精度的 SRT 外挂字幕转换。 SceneMarshal 是一套面向 Home Lab 的**媒体入库流水线**:下载目录里的片源在入库前先做**兼容性体检**(能否在电视/手机上直传、哪些只能转码),再完成结构化命名、TMDB 元数据补全、内嵌字幕与字体抽取、广告元数据抹除,最后按分类归档进媒体库并联动 Jellyfin。
秉持轻量化与高可移植性的设计哲学,SceneRename 专为 Docker 容器化环境进行了深度适配,通过严格的防撞认主机制、幂等性校验以及守护进程,致力于为您打造一个纯净、规范的自动化家庭影院媒体流水线。 设计上坚持轻量与可移植:全部逻辑围绕 `ffmpeg` / `ffprobe` / `mkvtoolnix` 构建,运行在 Docker 容器内,通过严格的防撞认主、幂等校验与阶段化任务队列,保证重复执行也安全。
## 核心能力
* **入库前体检(Preflight)**:按设备能力判定 `READY`(直传)/ `PREP`(轻量预处理)/ `TRANSCODE`(服务端转码可播)/ `BLOCKED`(播不了),输出可筛选的 xlsx 报告;
* **规范化命名**:解析目录结构、联动 TMDB、生成 `剧名.SxxExx.年份.分辨率.来源.编码.音轨` 规范名与 `[tmdbid-xxx]` 目录;
* **字幕与字体**:内嵌 ASS 原样导出、文本字幕转外挂 SRT、字体附件抽取(`<Season>/fonts/`);
* **分类归档**:按 TMDB 语言/类型建议目标分类,同盘 rename 原子移动并触发 Jellyfin 刷新。
## 技术栈 ## 技术栈
* **核心语言**: Python 3.11 * **核心语言**: Python 3.11
* **网络交互**: `requests`, `urllib3`(内置针对 TMDB API 的自定义重试防雪崩机制) * **网络交互**: `requests`, `urllib3`(内置针对 TMDB API 的自定义重试防雪崩机制)
* **系统监听**: `watchdog`(构建毫秒级响应的异步目录守护系统) * **系统监听**: `watchdog`(构建毫秒级响应的异步目录守护系统)
* **字幕工程**: `pysubs2`(纯 Python 驱动的 `.ass`/`.ssa` 特效洗白与标准化格式转换,极大增强跨平台能力) * **字幕工程**: `pysubs2`(`.ass`/`.ssa` 洗白与格式转换)+ `ffmpeg`(ASS 原样抽取)
* **媒体探针**: 现阶段底层依赖 `ffmpeg` / `ffprobe` 与 `mkvpropedit` 进行无损流操作。 * **媒体探针**: 底层依赖 `ffmpeg` / `ffprobe` 与 `mkvtoolnix`(`mkvpropedit` / `mkvextract`)进行无损流操作
* **体检报告**: `openpyxl`(xlsx,冻结首行、可筛选、只保留最近 N 份)
## 快速开始 ## 快速开始
@@ -32,8 +40,8 @@ SceneRename 是一款专注于高阶本地流媒体库自动化整理与刮削
```bash ```bash
# 获取源码 # 获取源码
git clone [https://gitea.hraulein.com/ali/SceneRename.git](https://gitea.hraulein.com/ali/SceneRename.git) git clone [https://gitea.hraulein.com/ali/SceneMarshal.git](https://gitea.hraulein.com/ali/SceneMarshal.git)
cd SceneRename cd SceneMarshal
# 安装纯 Python 依赖包 # 安装纯 Python 依赖包
pip install -r requirements.txt pip install -r requirements.txt
@@ -45,7 +53,7 @@ pip install -r requirements.txt
初次运行将在根目录生成 `config.ini`: 初次运行将在根目录生成 `config.ini`:
```bash ```bash
python src/main.py python media/src/main.py
``` ```
*提示:请在自动生成的 `config.ini` 中补全 TMDB API 密钥,并可按需调整 1080P/4K 的 REMUX 判定码率阈值及不需要扫描的黑名单目录。* *提示:请在自动生成的 `config.ini` 中补全 TMDB API 密钥,并可按需调整 1080P/4K 的 REMUX 判定码率阈值及不需要扫描的黑名单目录。*
@@ -57,29 +65,36 @@ python src/main.py
**1. 目录守护模式 (Watch Daemon)** 静默监听挂载目录,检测到媒体文件落盘并稳定后,自动触发全链路整理流水线。 **1. 目录守护模式 (Watch Daemon)** 静默监听挂载目录,检测到媒体文件落盘并稳定后,自动触发全链路整理流水线。
```bash ```bash
python src/main.py watch -p /volume1/downloads python media/src/main.py watch -p /volume1/downloads
``` ```
**2. 手动干预全量重构** 交互式扫描媒体目录,支持复杂的季号推断,并在物理变更前进行任务预览与二次确认。 **2. 手动干预全量重构** 交互式扫描媒体目录,支持复杂的季号推断,并在物理变更前进行任务预览与二次确认。
```bash ```bash
python src/main.py auto -p /volume1/media/TV_Shows python media/src/main.py auto -p /volume1/media/TV_Shows
``` ```
**3. 强制类型降维打击** 应对诸如 SP 花絮等极其不规范的命名,跳过正则猜测,强制指定处理逻辑。 **3. 强制类型降维打击** 应对诸如 SP 花絮等极其不规范的命名,跳过正则猜测,强制指定处理逻辑。
```bash ```bash
python src/main.py auto -p "/volume1/media/Unknown_Videos" --force-type tv python media/src/main.py auto -p "/volume1/media/Unknown_Videos" --force-type tv
``` ```
**4. 纯净手术刀模式** 不改变任何文件路径,仅提取/转换内置字幕,或暴力抹除视频标题中的广告关键词。 **4. 纯净手术刀模式** 不改变任何文件路径,仅提取/转换内置字幕,或暴力抹除视频标题中的广告关键词。
```bash ```bash
python src/main.py extract-subs -p /volume1/downloads/raw python media/src/main.py extract-subs -p /volume1/downloads/raw
python src/main.py clean-ads -p /volume1/downloads/raw python media/src/main.py clean-ads -p /volume1/downloads/raw
```
**5. 入库前体检** 只判定、不落盘:对每个视频给出 `READY / PREP / TRANSCODE / BLOCKED`,输出可筛选的 xlsx 报告。
```bash
python media/src/main.py check -p /volume1/media
``` ```
@@ -109,7 +124,7 @@ python src/main.py clean-ads -p /volume1/downloads/raw
**Copyright:** Copyright (C) 2026 ali **Copyright:** Copyright (C) 2026 ali
**Repository:** https://gitea.hraulein.com/ali/SceneRename.git **Repository:** https://gitea.hraulein.com/ali/SceneMarshal.git
**Version:** 1.0 **Version:** 1.0

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

+10 -10
View File
@@ -1,7 +1,7 @@
#Requires -Version 7.0 #Requires -Version 7.0
<# <#
.SYNOPSIS .SYNOPSIS
把本机 SceneRename 源码部署到 N100 的运行副本。 把本机 SceneMarshal 源码部署到 N100 的运行副本。
.DESCRIPTION .DESCRIPTION
默认(源码同步): 默认(源码同步):
@@ -53,12 +53,12 @@ function Assert-Agent {
} }
function Invoke-RemoteScript([string]$Body) { function Invoke-RemoteScript([string]$Body) {
$local = Join-Path ([IO.Path]::GetTempPath()) ("scenerename-remote-{0}.sh" -f [guid]::NewGuid().ToString('N').Substring(0, 8)) $local = Join-Path ([IO.Path]::GetTempPath()) ("SceneMarshal-remote-{0}.sh" -f [guid]::NewGuid().ToString('N').Substring(0, 8))
[IO.File]::WriteAllText($local, $Body, [Text.UTF8Encoding]::new($false)) [IO.File]::WriteAllText($local, $Body, [Text.UTF8Encoding]::new($false))
try { try {
& scp @SshOpts -q $local "${Remote}:/tmp/scenerename-deploy.sh" & scp @SshOpts -q $local "${Remote}:/tmp/SceneMarshal-deploy.sh"
if ($LASTEXITCODE -ne 0) { throw 'scp 上传远端脚本失败' } if ($LASTEXITCODE -ne 0) { throw 'scp 上传远端脚本失败' }
& ssh @SshOpts $Remote 'bash /tmp/scenerename-deploy.sh' & ssh @SshOpts $Remote 'bash /tmp/SceneMarshal-deploy.sh'
if ($LASTEXITCODE -ne 0) { throw "远端脚本执行失败(exit $LASTEXITCODE)" } if ($LASTEXITCODE -ne 0) { throw "远端脚本执行失败(exit $LASTEXITCODE)" }
} }
finally { finally {
@@ -112,7 +112,7 @@ install_tool "$RemoteRepo/scripts/media_archive.py" /usr/local/bin/media-archive
"@ "@
} }
else { else {
$tgz = Join-Path ([IO.Path]::GetTempPath()) 'scenerename-sync.tgz' $tgz = Join-Path ([IO.Path]::GetTempPath()) 'SceneMarshal-sync.tgz'
Write-Host '▶ 打包 media/src ...' -ForegroundColor Cyan Write-Host '▶ 打包 media/src ...' -ForegroundColor Cyan
if (Test-Path -LiteralPath $tgz) { Remove-Item -LiteralPath $tgz -Force } if (Test-Path -LiteralPath $tgz) { Remove-Item -LiteralPath $tgz -Force }
& tar -czf $tgz -C $RepoRoot --exclude=__pycache__ --exclude='*.pyc' media/src scripts & tar -czf $tgz -C $RepoRoot --exclude=__pycache__ --exclude='*.pyc' media/src scripts
@@ -120,7 +120,7 @@ install_tool "$RemoteRepo/scripts/media_archive.py" /usr/local/bin/media-archive
Write-Host (" {0} KB" -f [math]::Round((Get-Item -LiteralPath $tgz).Length / 1KB, 1)) -ForegroundColor DarkGray Write-Host (" {0} KB" -f [math]::Round((Get-Item -LiteralPath $tgz).Length / 1KB, 1)) -ForegroundColor DarkGray
Write-Host '▶ 上传到 N100 ...' -ForegroundColor Cyan Write-Host '▶ 上传到 N100 ...' -ForegroundColor Cyan
& scp @SshOpts -q $tgz "${Remote}:/tmp/scenerename-sync.tgz" & scp @SshOpts -q $tgz "${Remote}:/tmp/SceneMarshal-sync.tgz"
if ($LASTEXITCODE -ne 0) { throw 'scp 上传失败' } if ($LASTEXITCODE -ne 0) { throw 'scp 上传失败' }
Invoke-RemoteScript @' Invoke-RemoteScript @'
@@ -128,9 +128,9 @@ set -euo pipefail
REPO=/home/ali/docker/tools/python REPO=/home/ali/docker/tools/python
cd "$REPO" cd "$REPO"
TS=$(date +%Y%m%d-%H%M%S) TS=$(date +%Y%m%d-%H%M%S)
mkdir -p /tmp/scenerename-backup mkdir -p /tmp/SceneMarshal-backup
tar -czf "/tmp/scenerename-backup/src-$TS.tar.gz" media/src tar -czf "/tmp/SceneMarshal-backup/src-$TS.tar.gz" media/src
tar -xzf /tmp/scenerename-sync.tgz -C "$REPO" tar -xzf /tmp/SceneMarshal-sync.tgz -C "$REPO"
find media/src -name '*.py' -exec chmod 644 {} + find media/src -name '*.py' -exec chmod 644 {} +
echo "=== 远端相对仓库 HEAD 的变更 ===" echo "=== 远端相对仓库 HEAD 的变更 ==="
CHANGED=$(git status --porcelain -- media/src | head -40 || true) CHANGED=$(git status --porcelain -- media/src | head -40 || true)
@@ -151,7 +151,7 @@ install_tool() {
} }
install_tool "$REPO/scripts/media-rename" /usr/local/bin/media-rename install_tool "$REPO/scripts/media-rename" /usr/local/bin/media-rename
install_tool "$REPO/scripts/media_archive.py" /usr/local/bin/media-archive install_tool "$REPO/scripts/media_archive.py" /usr/local/bin/media-archive
echo "备份: /tmp/scenerename-backup/src-$TS.tar.gz" echo "备份: /tmp/SceneMarshal-backup/src-$TS.tar.gz"
'@ '@
} }
} }
+4 -4
View File
@@ -1,7 +1,7 @@
#Requires -Version 7.0 #Requires -Version 7.0
<# <#
.SYNOPSIS .SYNOPSIS
在 Windows 资源管理器右键菜单里注册 SceneRename 的「重命名」「归档」两项。 在 Windows 资源管理器右键菜单里注册 SceneMarshal 的「重命名」「归档」两项。
.DESCRIPTION .DESCRIPTION
只写 HKCU(当前用户),不需要管理员权限,可随时用 uninstall-explorer-menu.ps1 移除。 只写 HKCU(当前用户),不需要管理员权限,可随时用 uninstall-explorer-menu.ps1 移除。
@@ -32,12 +32,12 @@ else {
} }
$repoRoot = Split-Path -Parent $PSScriptRoot $repoRoot = Split-Path -Parent $PSScriptRoot
$iconPath = Join-Path $repoRoot 'assets\scenerename.ico' $iconPath = Join-Path $repoRoot 'assets\SceneMarshal.ico'
if (-not (Test-Path -LiteralPath $iconPath)) { $iconPath = $pwsh } if (-not (Test-Path -LiteralPath $iconPath)) { $iconPath = $pwsh }
$actions = @( $actions = @(
@{ Key = 'SceneRename'; Text = 'SceneRename 重命名'; Action = 'rename' }, @{ Key = 'SceneMarshal'; Text = 'SceneMarshal 重命名'; Action = 'rename' },
@{ Key = 'SceneRenameArchive'; Text = 'SceneRename 归档'; Action = 'archive' } @{ Key = 'SceneMarshalArchive'; Text = 'SceneMarshal 归档'; Action = 'archive' }
) )
$locations = @( $locations = @(
+1 -1
View File
@@ -1,5 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# media-rename —— 宿主机代理,把参数透传进 python 容器执行 SceneRename # media-rename —— 宿主机代理,把参数透传进 python 容器执行 SceneMarshal
# #
# 用法: # 用法:
# media-rename # 处理当前目录 # media-rename # 处理当前目录
+1 -1
View File
@@ -1,7 +1,7 @@
#Requires -Version 7.0 #Requires -Version 7.0
<# <#
.SYNOPSIS .SYNOPSIS
在 Windows 本机直接触发 N100 上的 media-rename(SceneRename 流水线)。 在 Windows 本机直接触发 N100 上的 media-rename(SceneMarshal 流水线)。
.DESCRIPTION .DESCRIPTION
把本机的目标目录翻译成 N100 的 Linux 路径,再 `ssh -t` 调用服务端的 把本机的目标目录翻译成 N100 的 Linux 路径,再 `ssh -t` 调用服务端的
+1 -1
View File
@@ -27,7 +27,7 @@ import urllib.request
from pathlib import Path from pathlib import Path
def resolve_media_root(cfg: configparser.ConfigParser) -> Path: def resolve_media_root(cfg: configparser.ConfigParser) -> Path:
env = os.environ.get("SCENERENAME_MEDIA_ROOT") env = os.environ.get("SCENEMARSHAL_MEDIA_ROOT") or os.environ.get("SCENERENAME_MEDIA_ROOT")
if env: if env:
return Path(env) return Path(env)
raw = cfg.get("Archive", "media_root", fallback="").strip() if cfg.has_section("Archive") else "" raw = cfg.get("Archive", "media_root", fallback="").strip() if cfg.has_section("Archive") else ""
+1 -1
View File
@@ -11,7 +11,7 @@ param()
$ErrorActionPreference = 'Stop' $ErrorActionPreference = 'Stop'
$keyNames = @('SceneRename', 'SceneRenameArchive') $keyNames = @('SceneMarshal', 'SceneMarshalArchive')
$shells = @( $shells = @(
'HKCU:\Software\Classes\Directory\shell', 'HKCU:\Software\Classes\Directory\shell',
'HKCU:\Software\Classes\Directory\Background\shell', 'HKCU:\Software\Classes\Directory\Background\shell',