Files
Media_Scripts/quickprocessreport.py
2025-06-26 05:52:43 +02:00

41 lines
1.1 KiB
Python

import csv
def process_row(row):
# Skip if accepted column already has a value
if row['accepted'].strip():
return
# Skip if required fields are missing
try:
size_ratio = float(row['size_ratio'])
ssim_score = float(row['ssim_score'])
except (ValueError, TypeError):
return
# Check if audio and subtitles match
if row['audio_match'] != 'O' or row['subs_match'] != 'O':
row['accepted'] = 'x'
return
# Apply acceptance rules
if size_ratio < 0.7 and ssim_score > 0.99:
row['accepted'] = 'o'
elif size_ratio < 0.7 and ssim_score > 0.95:
row['accepted'] = 'r'
else:
row['accepted'] = 'x'
# Read and process the CSV
with open('av1_quality_report.csv', 'r') as f:
reader = csv.DictReader(f)
rows = list(reader)
# Process each row
for row in rows:
process_row(row)
# Write updated data back to CSV
with open('av1_quality_report.csv', 'w', newline='') as f:
writer = csv.DictWriter(f, fieldnames=reader.fieldnames)
writer.writeheader()
writer.writerows(rows)