Implement duplicate resolution strategy by quality and enhance related documentation

- Updated `duplicate_resolve.py` to introduce a new strategy for keeping files based on quality, considering resolution, source, codec, and size.
- Enhanced `planner.py` to utilize the new quality-based strategy during plan generation, updating quarantine reasons accordingly.
- Modified `README.md` to document the new `plan.duplicate_keep` options, including `by_quality`, and provided detailed descriptions of each strategy.
- Added unit tests in `test_duplicate_resolve.py` to validate the new quality-based resolution logic.
- Updated `analysis.json` and `plan.json` with new timestamps and IDs to reflect recent changes.

These updates improve the Video Library Manager's ability to handle duplicate files more effectively, ensuring users retain the highest quality versions.
This commit is contained in:
windyboy
2026-02-11 08:44:48 +08:00
parent 79f5ddf1f5
commit 1f55eab304
9 changed files with 297 additions and 20 deletions
+8 -3
View File
@@ -133,7 +133,11 @@ This creates `plan.json` with:
- **Human summary** (中文): short narrative for quick review
- **Metadata**: when using `--analysis`, duplicate groups considered and completeness gaps
Duplicate keep strategy is configurable in `~/.vlm/config.yaml` under `plan.duplicate_keep` (`by_reputation`, `first_seen`, or `manual`). Default is `by_reputation` (prefer external rating; fallback to first-seen).
Duplicate keep strategy is configurable in `~/.vlm/config.yaml` under `plan.duplicate_keep`:
- `by_quality` - Prefer highest quality (resolution > source > codec > file size). Best for automatic duplicate resolution.
- `by_reputation` - Prefer external rating (TMDB); fallback to first-seen. Default.
- `first_seen` - Keep the first file in each duplicate group.
- `manual` - Do not generate quarantine operations; duplicates are listed in analysis only.
**Review the plan** by opening `plan.json` in your editor, or read the human summary when you run `vlm execute`. You can edit the plan JSON if needed.
@@ -406,7 +410,8 @@ log_level: "INFO"
# Plan behavior (e.g. when using vlm plan --analysis)
plan:
# Duplicate keep strategy: "by_reputation" (default), "first_seen", or "manual"
# Duplicate keep strategy: "by_quality", "by_reputation" (default), "first_seen", or "manual"
# by_quality: resolution > source (BluRay > WEB-DL) > codec (x265 > x264) > file size
duplicate_keep: "by_reputation"
# Category mappings (directory name to category)
@@ -762,7 +767,7 @@ src/vlm/
├── io.py # JSON/CSV load/save, load_analysis_json, plan/analysis input helpers
├── utils.py # UTC time, format_size, etc.
├── analysis.py # Completeness and duplicate detection
├── duplicate_resolve.py # Duplicate group keep-index (by_reputation, first_seen, manual)
├── duplicate_resolve.py # Duplicate group keep-index (by_quality, by_reputation, first_seen, manual)
├── planner.py # Execution plan generation (optionally consumes analysis)
├── executor.py # File operations and rollback
├── quarantine.py # Quarantine management