made it smarter
This commit is contained in:
@@ -223,6 +223,11 @@ def process_file(filepath, log_category, lock_dir, log_dir, encoders, worker_id=
|
||||
|
||||
if shutdown_requested: return
|
||||
|
||||
# 0. Check if already processed in a previous run
|
||||
if common.is_already_processed(log_dir, filepath):
|
||||
update("Already Processed (Skipping)", "dim")
|
||||
return
|
||||
|
||||
# 1. Lock Check (Shared Storage)
|
||||
lock_file = common.acquire_lock(lock_dir, filepath)
|
||||
if not lock_file:
|
||||
@@ -402,6 +407,10 @@ def process_file(filepath, log_category, lock_dir, log_dir, encoders, worker_id=
|
||||
"original_metadata": info,
|
||||
"encoded_metadata": final_info_verified or final_info
|
||||
})
|
||||
|
||||
# Mark as processed to prevent re-encoding in future runs
|
||||
common.mark_processed(log_dir, filepath, chosen_codec, vmaf_score, final_savings)
|
||||
|
||||
update("Done", "green")
|
||||
if status_cb: status_cb(worker_id, filename, f"STATS:SAVED:{saved_bytes}", "green")
|
||||
else:
|
||||
@@ -430,6 +439,8 @@ def main():
|
||||
parser.add_argument("--skip-until", help="Skip all files alphabetically until this filename substring is found")
|
||||
parser.add_argument("--cpu-only", action="store_true", help="Force software encoding (CPU only)")
|
||||
parser.add_argument("--temp-dir", help="Override local temp directory")
|
||||
parser.add_argument("--av1-encoder", choices=["hw", "sw", "off"], default="hw", help="AV1 encoder: hw (hardware), sw (software), off (disable)")
|
||||
parser.add_argument("--hevc-encoder", choices=["hw", "sw", "off"], default="hw", help="HEVC encoder: hw (hardware), sw (software), off (disable)")
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.debug:
|
||||
@@ -464,19 +475,43 @@ def main():
|
||||
# 3. Scan & Queue
|
||||
tasks = []
|
||||
|
||||
# Skip-until filtering
|
||||
skip_until = args.skip_until
|
||||
skipping = bool(skip_until)
|
||||
skipped_count = 0
|
||||
|
||||
tv_path = Path(args.tv_dir)
|
||||
if tv_path.exists():
|
||||
print(f"Scanning TV: {tv_path}")
|
||||
files = list(tv_path.rglob("*.mkv")) + list(tv_path.rglob("*.mp4"))
|
||||
files.sort(key=lambda x: x.stat().st_size, reverse=True)
|
||||
for f in files: tasks.append((f, "tv_shows"))
|
||||
for f in files:
|
||||
if skipping:
|
||||
if skip_until.lower() in str(f).lower():
|
||||
skipping = False
|
||||
print(f" Found '{skip_until}' - resuming from here")
|
||||
else:
|
||||
skipped_count += 1
|
||||
continue
|
||||
tasks.append((f, "tv_shows"))
|
||||
|
||||
content_path = Path(args.content_dir)
|
||||
if content_path.exists():
|
||||
print(f"Scanning Content: {content_path}")
|
||||
files = list(content_path.rglob("*.mkv")) + list(content_path.rglob("*.mp4"))
|
||||
files.sort(key=lambda x: x.stat().st_size, reverse=True)
|
||||
for f in files: tasks.append((f, "content"))
|
||||
for f in files:
|
||||
if skipping:
|
||||
if skip_until.lower() in str(f).lower():
|
||||
skipping = False
|
||||
print(f" Found '{skip_until}' - resuming from here")
|
||||
else:
|
||||
skipped_count += 1
|
||||
continue
|
||||
tasks.append((f, "content"))
|
||||
|
||||
if skipped_count > 0:
|
||||
print(f" Skipped {skipped_count} files (--skip-until)")
|
||||
|
||||
if not tasks:
|
||||
print("No files found.")
|
||||
|
||||
Reference in New Issue
Block a user