align plugin with new architecture
Build and Push Docker Image / build (push) Failing after 15s

This commit is contained in:
Worph
2026-09-13 11:52:46 +02:00
parent da127f5185
commit 4d51289acc
15 changed files with 2643 additions and 272 deletions
+19 -46
View File
@@ -1,65 +1,38 @@
# MetaMesh Plugin: Subtitle
A MetaMesh plugin that processes subtitle files and links them to videos.
Links subtitle **sidecar** files to the video they sit next to, in both directions, and determines each sidecar's language.
## Description
## What counts as a sidecar
This plugin handles subtitle file processing:
`<video basename>.<ext>` or `<video basename>.<qualifiers>.<ext>` (case-insensitive), `<ext>` in `srt`, `ass`, `ssa`, `vtt`, where every qualifier is a language (`en`, `eng`, `fre`, `pt-BR`, `English`) or a flag (`forced`, `sdh`, `cc`, `hi`, `default`, `full`, `signs`, `songs`):
**For subtitle files (`.srt`, `.ass`, `.ssa`, `.vtt`):**
- Detects subtitle language using content analysis
- Finds sibling video files with matching names
- `Movie.srt`, `Movie.eng.srt`, `Movie.en.srt`, `Movie.fr.forced.srt` → sidecars of `Movie.mkv`
- `Movie.Extended.eng.srt` → not a sidecar of `Movie.mkv`
**For video files:**
- Discovers associated subtitle files in the same directory
Language: the qualifier when present, else a `franc-min` sniff of the subtitle text (timecodes and ASS markup stripped), else `und`. Codes are ISO 639-2/B (`fre`, `ger`, `chi`), normalised the same way meta-watch does. `hi` means hearing-impaired, not Hindi (use `hin`).
## Metadata Fields
## What it writes (METADATA_KEYS.md §8)
| Field | Description |
|-------|-------------|
| `subtitleLanguage` | Detected language of subtitle content |
| `linkedVideoName` | Name of associated video file |
| `subtitleFile/{ext}` | Associated subtitle filename by extension |
| Record | Key | Value |
|--------|-----|-------|
| video | `subtitles/<lang3>/<subCid>` | `"true"` |
| video | `subtitleLanguages/<lang3>` | `"true"` (not for `und`) |
| subtitle | `videos/<videoCid>` | `"true"` |
| subtitle | `subtitleLanguage` | `<lang3>` (not for `und`) |
## Dependencies
Each run writes its own record in full and the other record only if it already exists, so the result is the same whichever file the watcher processes first. Writes are one `PATCH` of only-new keys; a failed write fails the task. Legacy comma-joined `subtitles` / `videos` scalars are migrated to the key-set.
- Requires `file-info` plugin to run first
## File access
## Configuration
WebDAV only (the container has no `/files` mount): directory listing, size and bytes come from the meta-core that drove the task (`/urls` → `webdavUrlInternal`; `WEBDAV_URL` overrides). CIDs are midhash256 computed from one ≤1 MiB Range read.
No configuration required.
## API Endpoints
| Endpoint | Method | Description |
|----------|--------|-------------|
| `/health` | GET | Health check |
| `/manifest` | GET | Plugin manifest |
| `/configure` | POST | Update configuration |
| `/process` | POST | Process a file |
## Running Locally
## Tests
```bash
npm install
npm run build
npm start
pnpm install && (cd node_modules/@metazla/filename-tools && pnpm install && pnpm run build) && pnpm test
./test.sh # in Docker
```
## Docker
```bash
docker build -t metamesh-plugin-subtitle .
docker run -p 8080:8080 metamesh-plugin-subtitle
```
## Environment Variables
| Variable | Default | Description |
|----------|---------|-------------|
| `PORT` | `8080` | HTTP server port |
| `HOST` | `0.0.0.0` | HTTP server host |
## License
MIT