mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 00:39:13 +00:00
feat(filters): skip duplicates (#1711)
* feat(filters): skip duplicates * fix: add interface instead of any * fix(filters): tonullint * feat(filters): skip dupes check month day * chore: cleanup * feat(db): set autoincrement id * feat(filters): add repack and proper to dupe profile * feat(filters): add default dupe profiles * feat(duplicates): check audio and website * feat(duplicates): update tests * feat(duplicates): add toggles on addform * feat(duplicates): fix sqlite upgrade path and initialize duplicate profiles * feat(duplicates): simplify sqlite upgrade avoiding temp table and unwieldy select. Besides, FK constraints are turned off anyway in #229. * feat(duplicates): change CheckIsDuplicateRelease treatment of PROPER and REPACK "Proper" and "Repack" are not parallel to the other conditions like "Title", so they do not belong as dedup conditions. "PROPER" means there was an issue in the previous release, and so a PROPER is never a duplicate, even if it replaces another PROPER. Similarly, "REPACK" means there was an issue in the previous release by that group, and so it is a duplicate only if we previously took a release from a DIFFERENT group. I have not removed Proper and Repack from the UI or the schema yet. * feat(duplicates): update postgres schema to match sqlite * feat(duplicates): fix web build errors * feat(duplicates): fix postgres errors * feat(filters): do leftjoin for duplicate profile * fix(filters): partial update dupe profile * go fmt `internal/domain/filter.go` * feat(duplicates): restore straightforward logic for proper/repack * feat(duplicates): remove mostly duplicate TV duplicate profiles Having one profile seems the cleanest. If somebody wants multiple resolutions then they can add Resolution to the duplicate profile. Tested this profile with both weekly episodic releases and daily show releases. * feat(release): add db indexes and sub_title * feat(release): add IsDuplicate tests * feat(release): update action handler * feat(release): add more tests for skip duplicates * feat(duplicates): check audio * feat(duplicates): add more tests * feat(duplicates): match edition cut and more * fix(duplicates): tests * fix(duplicates): missing imports * fix(duplicates): tests * feat(duplicates): handle sub_title edition and language in ui * fix(duplicates): tests * feat(duplicates): check name against normalized hash * fix(duplicates): tests * chore: update .gitignore to ignore .pnpm-store * fix: tests * fix(filters): tests * fix: bad conflict merge * fix: update release type in test * fix: use vendored hot-toast * fix: release_test.go * fix: rss_test.go * feat(duplicates): improve title hashing for unique check * feat(duplicates): further improve title hashing for unique check with lang * feat(duplicates): fix tests * feat(duplicates): add macros IsDuplicate and DuplicateProfile ID and name * feat(duplicates): add normalized hash match option * fix: headlessui-state prop warning * fix(duplicates): add missing year in daily ep normalize * fix(duplicates): check rejections len --------- Co-authored-by: ze0s <ze0s@riseup.net>
This commit is contained in:
parent
d153ac44b8
commit
4009554d10
49 changed files with 3792 additions and 743 deletions
|
@ -88,6 +88,39 @@ CREATE TABLE irc_channel
|
|||
UNIQUE (network_id, name)
|
||||
);
|
||||
|
||||
CREATE TABLE release_profile_duplicate
|
||||
(
|
||||
id SERIAL PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
protocol BOOLEAN DEFAULT FALSE,
|
||||
release_name BOOLEAN DEFAULT FALSE,
|
||||
hash BOOLEAN DEFAULT FALSE,
|
||||
title BOOLEAN DEFAULT FALSE,
|
||||
sub_title BOOLEAN DEFAULT FALSE,
|
||||
year BOOLEAN DEFAULT FALSE,
|
||||
month BOOLEAN DEFAULT FALSE,
|
||||
day BOOLEAN DEFAULT FALSE,
|
||||
source BOOLEAN DEFAULT FALSE,
|
||||
resolution BOOLEAN DEFAULT FALSE,
|
||||
codec BOOLEAN DEFAULT FALSE,
|
||||
container BOOLEAN DEFAULT FALSE,
|
||||
dynamic_range BOOLEAN DEFAULT FALSE,
|
||||
audio BOOLEAN DEFAULT FALSE,
|
||||
release_group BOOLEAN DEFAULT FALSE,
|
||||
season BOOLEAN DEFAULT FALSE,
|
||||
episode BOOLEAN DEFAULT FALSE,
|
||||
website BOOLEAN DEFAULT FALSE,
|
||||
proper BOOLEAN DEFAULT FALSE,
|
||||
repack BOOLEAN DEFAULT FALSE,
|
||||
edition BOOLEAN DEFAULT FALSE,
|
||||
language BOOLEAN DEFAULT FALSE
|
||||
);
|
||||
|
||||
INSERT INTO release_profile_duplicate (id, name, protocol, release_name, hash, title, sub_title, year, month, day, source, resolution, codec, container, dynamic_range, audio, release_group, season, episode, website, proper, repack, edition, language)
|
||||
VALUES (1, 'Exact release', 'f', 't', 't', 'f', 'f', 'f', 'f', 'f', 'f', 'f', 'f', 'f', 'f', 'f', 'f', 'f', 'f', 'f', 'f', 'f', 'f', 'f'),
|
||||
(2, 'Movie', 'f', 'f', 'f', 't', 'f', 't', 'f', 'f', 'f', 't', 'f', 'f', 'f', 'f', 'f', 'f', 'f', 'f', 'f', 'f', 'f', 'f'),
|
||||
(3, 'TV', 'f', 'f', 'f', 't', 'f', 't', 't', 't', 'f', 'f', 'f', 'f', 'f', 'f', 'f', 't', 't', 'f', 'f', 'f', 'f', 'f');
|
||||
|
||||
CREATE TABLE filter
|
||||
(
|
||||
id SERIAL PRIMARY KEY,
|
||||
|
@ -159,7 +192,9 @@ CREATE TABLE filter
|
|||
min_seeders INTEGER DEFAULT 0,
|
||||
max_seeders INTEGER DEFAULT 0,
|
||||
min_leechers INTEGER DEFAULT 0,
|
||||
max_leechers INTEGER DEFAULT 0
|
||||
max_leechers INTEGER DEFAULT 0,
|
||||
release_profile_duplicate_id INTEGER,
|
||||
FOREIGN KEY (release_profile_duplicate_id) REFERENCES release_profile_duplicate(id) ON DELETE SET NULL
|
||||
);
|
||||
|
||||
CREATE INDEX filter_enabled_index
|
||||
|
@ -270,9 +305,11 @@ CREATE TABLE "release"
|
|||
group_id TEXT,
|
||||
torrent_id TEXT,
|
||||
torrent_name TEXT,
|
||||
normalized_hash TEXT,
|
||||
size BIGINT,
|
||||
raw TEXT,
|
||||
title TEXT,
|
||||
sub_title TEXT,
|
||||
category TEXT,
|
||||
season INTEGER,
|
||||
episode INTEGER,
|
||||
|
@ -285,15 +322,18 @@ CREATE TABLE "release"
|
|||
container TEXT,
|
||||
hdr TEXT,
|
||||
audio TEXT,
|
||||
audio_channels TEXT,
|
||||
release_group TEXT,
|
||||
region TEXT,
|
||||
language TEXT,
|
||||
edition TEXT,
|
||||
cut TEXT,
|
||||
unrated BOOLEAN,
|
||||
hybrid BOOLEAN,
|
||||
proper BOOLEAN,
|
||||
repack BOOLEAN,
|
||||
website TEXT,
|
||||
media_processing TEXT,
|
||||
artists TEXT [] DEFAULT '{}' NOT NULL,
|
||||
type TEXT,
|
||||
format TEXT,
|
||||
|
@ -308,6 +348,7 @@ CREATE TABLE "release"
|
|||
freeleech_percent INTEGER,
|
||||
uploader TEXT,
|
||||
pre_time TEXT,
|
||||
other TEXT [] DEFAULT '{}' NOT NULL,
|
||||
filter_id INTEGER
|
||||
CONSTRAINT release_filter_id_fk
|
||||
REFERENCES filter
|
||||
|
@ -326,6 +367,81 @@ CREATE INDEX release_timestamp_index
|
|||
CREATE INDEX release_torrent_name_index
|
||||
ON "release" (torrent_name);
|
||||
|
||||
CREATE INDEX release_normalized_hash_index
|
||||
ON "release" (normalized_hash);
|
||||
|
||||
CREATE INDEX release_title_index
|
||||
ON "release" (title);
|
||||
|
||||
CREATE INDEX release_sub_title_index
|
||||
ON "release" (sub_title);
|
||||
|
||||
CREATE INDEX release_season_index
|
||||
ON "release" (season);
|
||||
|
||||
CREATE INDEX release_episode_index
|
||||
ON "release" (episode);
|
||||
|
||||
CREATE INDEX release_year_index
|
||||
ON "release" (year);
|
||||
|
||||
CREATE INDEX release_month_index
|
||||
ON "release" (month);
|
||||
|
||||
CREATE INDEX release_day_index
|
||||
ON "release" (day);
|
||||
|
||||
CREATE INDEX release_resolution_index
|
||||
ON "release" (resolution);
|
||||
|
||||
CREATE INDEX release_source_index
|
||||
ON "release" (source);
|
||||
|
||||
CREATE INDEX release_codec_index
|
||||
ON "release" (codec);
|
||||
|
||||
CREATE INDEX release_container_index
|
||||
ON "release" (container);
|
||||
|
||||
CREATE INDEX release_hdr_index
|
||||
ON "release" (hdr);
|
||||
|
||||
CREATE INDEX release_audio_index
|
||||
ON "release" (audio);
|
||||
|
||||
CREATE INDEX release_audio_channels_index
|
||||
ON "release" (audio_channels);
|
||||
|
||||
CREATE INDEX release_release_group_index
|
||||
ON "release" (release_group);
|
||||
|
||||
CREATE INDEX release_language_index
|
||||
ON "release" (language);
|
||||
|
||||
CREATE INDEX release_proper_index
|
||||
ON "release" (proper);
|
||||
|
||||
CREATE INDEX release_repack_index
|
||||
ON "release" (repack);
|
||||
|
||||
CREATE INDEX release_website_index
|
||||
ON "release" (website);
|
||||
|
||||
CREATE INDEX release_media_processing_index
|
||||
ON "release" (media_processing);
|
||||
|
||||
CREATE INDEX release_region_index
|
||||
ON "release" (region);
|
||||
|
||||
CREATE INDEX release_edition_index
|
||||
ON "release" (edition);
|
||||
|
||||
CREATE INDEX release_cut_index
|
||||
ON "release" (cut);
|
||||
|
||||
CREATE INDEX release_hybrid_index
|
||||
ON "release" (hybrid);
|
||||
|
||||
CREATE TABLE release_action_status
|
||||
(
|
||||
id SERIAL PRIMARY KEY,
|
||||
|
@ -1074,5 +1190,154 @@ CREATE TABLE list_filter
|
|||
|
||||
ALTER TABLE filter
|
||||
ADD COLUMN except_record_labels TEXT DEFAULT '';
|
||||
`,
|
||||
`CREATE TABLE release_profile_duplicate
|
||||
(
|
||||
id SERIAL PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
protocol BOOLEAN DEFAULT FALSE,
|
||||
release_name BOOLEAN DEFAULT FALSE,
|
||||
hash BOOLEAN DEFAULT FALSE,
|
||||
title BOOLEAN DEFAULT FALSE,
|
||||
sub_title BOOLEAN DEFAULT FALSE,
|
||||
year BOOLEAN DEFAULT FALSE,
|
||||
month BOOLEAN DEFAULT FALSE,
|
||||
day BOOLEAN DEFAULT FALSE,
|
||||
source BOOLEAN DEFAULT FALSE,
|
||||
resolution BOOLEAN DEFAULT FALSE,
|
||||
codec BOOLEAN DEFAULT FALSE,
|
||||
container BOOLEAN DEFAULT FALSE,
|
||||
dynamic_range BOOLEAN DEFAULT FALSE,
|
||||
audio BOOLEAN DEFAULT FALSE,
|
||||
release_group BOOLEAN DEFAULT FALSE,
|
||||
season BOOLEAN DEFAULT FALSE,
|
||||
episode BOOLEAN DEFAULT FALSE,
|
||||
website BOOLEAN DEFAULT FALSE,
|
||||
proper BOOLEAN DEFAULT FALSE,
|
||||
repack BOOLEAN DEFAULT FALSE,
|
||||
edition BOOLEAN DEFAULT FALSE,
|
||||
language BOOLEAN DEFAULT FALSE
|
||||
);
|
||||
|
||||
INSERT INTO release_profile_duplicate (id, name, protocol, release_name, hash, title, sub_title, year, month, day, source, resolution, codec, container, dynamic_range, audio, release_group, season, episode, website, proper, repack, edition, language)
|
||||
VALUES (1, 'Exact release', 'f', 't', 't', 'f', 'f', 'f', 'f', 'f', 'f', 'f', 'f', 'f', 'f', 'f', 'f', 'f', 'f', 'f', 'f', 'f', 'f', 'f'),
|
||||
(2, 'Movie', 'f', 'f', 'f', 't', 'f', 't', 'f', 'f', 'f', 't', 'f', 'f', 'f', 'f', 'f', 'f', 'f', 'f', 'f', 'f', 'f', 'f'),
|
||||
(3, 'TV', 'f', 'f', 'f', 't', 'f', 't', 't', 't', 'f', 'f', 'f', 'f', 'f', 'f', 'f', 't', 't', 'f', 'f', 'f', 'f', 'f');
|
||||
|
||||
ALTER TABLE filter
|
||||
ADD release_profile_duplicate_id INTEGER;
|
||||
|
||||
ALTER TABLE filter
|
||||
ADD CONSTRAINT filter_release_profile_duplicate_id_fk
|
||||
FOREIGN KEY (release_profile_duplicate_id) REFERENCES release_profile_duplicate (id)
|
||||
ON DELETE SET NULL;
|
||||
|
||||
ALTER TABLE "release"
|
||||
ADD normalized_hash TEXT;
|
||||
|
||||
ALTER TABLE "release"
|
||||
ADD sub_title TEXT;
|
||||
|
||||
ALTER TABLE "release"
|
||||
ADD COLUMN IF NOT EXISTS audio TEXT;
|
||||
|
||||
ALTER TABLE "release"
|
||||
ADD audio_channels TEXT;
|
||||
|
||||
ALTER TABLE "release"
|
||||
ADD IF NOT EXISTS language TEXT;
|
||||
|
||||
ALTER TABLE "release"
|
||||
ADD media_processing TEXT;
|
||||
|
||||
ALTER TABLE "release"
|
||||
ADD IF NOT EXISTS edition TEXT;
|
||||
|
||||
ALTER TABLE "release"
|
||||
ADD IF NOT EXISTS cut TEXT;
|
||||
|
||||
ALTER TABLE "release"
|
||||
ADD IF NOT EXISTS hybrid TEXT;
|
||||
|
||||
ALTER TABLE "release"
|
||||
ADD IF NOT EXISTS region TEXT;
|
||||
|
||||
ALTER TABLE "release"
|
||||
ADD IF NOT EXISTS other TEXT [] DEFAULT '{}' NOT NULL;
|
||||
|
||||
CREATE INDEX release_normalized_hash_index
|
||||
ON "release" (normalized_hash);
|
||||
|
||||
CREATE INDEX release_title_index
|
||||
ON "release" (title);
|
||||
|
||||
CREATE INDEX release_sub_title_index
|
||||
ON "release" (sub_title);
|
||||
|
||||
CREATE INDEX release_season_index
|
||||
ON "release" (season);
|
||||
|
||||
CREATE INDEX release_episode_index
|
||||
ON "release" (episode);
|
||||
|
||||
CREATE INDEX release_year_index
|
||||
ON "release" (year);
|
||||
|
||||
CREATE INDEX release_month_index
|
||||
ON "release" (month);
|
||||
|
||||
CREATE INDEX release_day_index
|
||||
ON "release" (day);
|
||||
|
||||
CREATE INDEX release_resolution_index
|
||||
ON "release" (resolution);
|
||||
|
||||
CREATE INDEX release_source_index
|
||||
ON "release" (source);
|
||||
|
||||
CREATE INDEX release_codec_index
|
||||
ON "release" (codec);
|
||||
|
||||
CREATE INDEX release_container_index
|
||||
ON "release" (container);
|
||||
|
||||
CREATE INDEX release_hdr_index
|
||||
ON "release" (hdr);
|
||||
|
||||
CREATE INDEX release_audio_index
|
||||
ON "release" (audio);
|
||||
|
||||
CREATE INDEX release_audio_channels_index
|
||||
ON "release" (audio_channels);
|
||||
|
||||
CREATE INDEX release_release_group_index
|
||||
ON "release" (release_group);
|
||||
|
||||
CREATE INDEX release_proper_index
|
||||
ON "release" (proper);
|
||||
|
||||
CREATE INDEX release_repack_index
|
||||
ON "release" (repack);
|
||||
|
||||
CREATE INDEX release_website_index
|
||||
ON "release" (website);
|
||||
|
||||
CREATE INDEX release_media_processing_index
|
||||
ON "release" (media_processing);
|
||||
|
||||
CREATE INDEX release_language_index
|
||||
ON "release" (language);
|
||||
|
||||
CREATE INDEX release_region_index
|
||||
ON "release" (region);
|
||||
|
||||
CREATE INDEX release_edition_index
|
||||
ON "release" (edition);
|
||||
|
||||
CREATE INDEX release_cut_index
|
||||
ON "release" (cut);
|
||||
|
||||
CREATE INDEX release_hybrid_index
|
||||
ON "release" (hybrid);
|
||||
`,
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue