feat(api): SHA-256 and Chromaprint fingerprints for the library (M5.5)
A background Fingerprinter runs after every scan and at startup, one file at a time, filling media_files.sha256 and track_fingerprints (fpcalc raw, first 120 s). Without fpcalc only SHA-256 is computed and files stay queued for Chromaprint. Changing a file's content resets its prints. Similarity() compares raw prints with a ±80-point alignment search; it is the basis for duplicate detection in the upload queue. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ed063d3763
commit
9b50038bb4
9 files changed
+406
-6
No files matched your search
@@ -0,0 +1,19 @@
|
||||
-- +goose Up
|
||||
-- Отпечатки файлов библиотеки для проверки дублей при загрузке (docs/uploads.md#4-проверка-на-дубли):
|
||||
-- полный SHA-256 — в media_files.sha256, акустический Chromaprint — здесь.
|
||||
ALTER TABLE media_files ADD COLUMN fingerprinted_at timestamptz;
|
||||
CREATE INDEX media_files_fingerprint_todo_idx ON media_files (id) WHERE fingerprinted_at IS NULL;
|
||||
|
||||
CREATE TABLE track_fingerprints (
|
||||
file_id uuid PRIMARY KEY REFERENCES media_files(id) ON DELETE CASCADE,
|
||||
duration_ms int NOT NULL,
|
||||
fingerprint int[] NOT NULL, -- raw-отпечаток fpcalc (uint32 как int4)
|
||||
fp_prefix bigint NOT NULL -- первые 64 бита — грубый индекс для отбора кандидатов
|
||||
);
|
||||
CREATE INDEX track_fingerprints_prefix_idx ON track_fingerprints (fp_prefix);
|
||||
CREATE INDEX track_fingerprints_duration_idx ON track_fingerprints (duration_ms);
|
||||
|
||||
-- +goose Down
|
||||
DROP TABLE track_fingerprints;
|
||||
DROP INDEX media_files_fingerprint_todo_idx;
|
||||
ALTER TABLE media_files DROP COLUMN fingerprinted_at;
|
||||
Reference in new issue
Block a user