feat: add acoustic dedupe pipeline and docker runtime
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
FORMAT_SCORE = {"flac": 100, "alac": 100, "wav": 100, "m4a": 60, "aac": 60, "ogg": 50, "opus": 50, "mp3": 40}
|
||||
|
||||
def score(row) -> int:
|
||||
value = FORMAT_SCORE.get((row["format"] or "").lower(), 0)
|
||||
value += int((row["bitrate"] or 0) * 0.1)
|
||||
if row["sample_rate"]:
|
||||
value += min(int(row["sample_rate"] / 1000), 20)
|
||||
if row["bit_depth"]:
|
||||
value += min(int(row["bit_depth"]), 32)
|
||||
return value
|
||||
|
||||
def is_version_conflict(a, b) -> bool:
|
||||
af = set((a["version_flags"] or "").split(","))
|
||||
bf = set((b["version_flags"] or "").split(","))
|
||||
return bool(af.symmetric_difference(bf))
|
||||
|
||||
def choose_winner(rows):
|
||||
def key(r):
|
||||
path = str(r["file_path"])
|
||||
admin = "/admin/" in path or path.endswith("/admin")
|
||||
return (-score(r), 0 if admin else 1, r["created_at"], path)
|
||||
return min(rows, key=key)
|
||||
Reference in New Issue
Block a user