Commit Graph

36 Commits

Author SHA1 Message Date
Yevhen Odynets 346369ca11 srrdb: harvest the srrDB search API into a separate SQLite database
New scope reading the API instead of scraping HTML: one search path per run,
passed raw through --single-uri, and the answer stored as-is into its own
SQLite file created from the embedded schema.

Command line: --single-uri carries the path after /v1/search/
(category:flac/date:today/page:1) and must name a category; --sleep sets the
pause between pages, with the config value as fallback. A day named on the
command line is always fetched again and its dump rewritten, so cron can
refresh today hourly and yesterday daily.

Date placeholders: date:auto walks backwards to the newest day in
[srrdb.floor..yesterday] that has no dump yet, closing holes instead of
declaring the archive covered. date:today, date:yesterday and date:tomorrow
stand for the neighbouring days. Today is never taken by the walk, because a
day still being filled would be frozen by its own dump after the first run.

Dumps are the cursor as well as the record, so a missing dump directory is an
error instead of "nothing harvested yet": a renamed, unmounted or mistyped
directory must not send the run silently back to the beginning. An empty day is
a normal result and is remembered as harvested; API warnings never are, and
they reach the exit code.

Writes go through one transaction, so a day lands completely or not at all.
group and category come from the release line and the search path; status, nfo,
content and synced_at stay NULL. srrdb.log.jsonl records one line per finished
run, srrdb.error_log.jsonl keeps failures and API warnings apart by a kind
field.

Also: the console command contract returns (string, error), so a failing scope
reaches the process exit code and cron can tell a failed run from a successful
one. config/scope/srrdb.yaml is untracked because its paths differ per host.
modernc.org/sqlite replaces the archived libsql client, which only ever talked
to a server. pkg/repository/srrdb.go is split by responsibility and covered by
table-driven tests.
2026-09-30 09:27:33 +03:00
Yevhen Odynets 332d143f1f change dump output for prescene 2026-09-29 08:17:11 +03:00
Yevhen Odynets f53a624004 chnage dump output to pretty 2026-09-27 01:59:03 +03:00
Yevhen Odynets 39aa8e2e81 fixed a new prescene layout 2026-09-27 01:12:52 +03:00
Yevhen Odynets 347f525801 releaseparser: Artist/Title boundary resolution + normalized Type field
Three-level core resolution with priority overrides → dictionaries/model → suspects:

1. dicts/overrides.txt (highest priority)
   Point fixes via exact lookup on Raw BEFORE the positional logic.
   Format: <original line> => artist | title. An override fixes
   Artist/Title and shifts the dictionary tail zone by the actual core
   length (overrideCoreLength, fallback 2 tokens).

2. dicts/artists.txt
   Whitelist of hyphenated artists (Iku-Turso, Post-Mortem, ...): a
   [0]-[1] hit → Artist = 2 tokens, Title = [2], tail zone shifted.
   One entry covers all releases of the artist automatically.

3. Suspected title continuation
   Unknown tokens between the title zone and the tail (followed later by
   dictionary markers) no longer pollute UnknownTokens; they go to a
   dedicated TitleExtra field + warning "suspected title continuation" —
   a reviewer hint that the core is probably longer than 2 tokens.
   Catalogue numbers (parenthesized tokens) are resolved with FIRST
   priority and never land in suspects.

Type field (normalized base release type):
- new normalization map dicts/types.txt (<Base> = variants):
  EP = EP, CDS, CDM, 7INCH_VINYL, CDEP, ..., REMASTERED_EP; Demo = ...;
  Split; Single; Compilation; Collaboration (curator-extendable)
- tokens matched against edition/source are additionally normalized to
  the base type (first match wins); edition.txt/source.txt untouched,
  Source stays raw
- TypeDistribution map[string]int added to GroupStats and the report
  (console/JSON)
- OST/INSTRUMENTAL are release traits, not types; excluded from the map

Tests: old cases updated to the new suspect semantics; acceptance tests
added for overrides (Milicia_Oscura-Anti-Cristo), artist dictionary
(Iku-Turso), the suspect section, Type normalization (CDEP → EP with
raw Source=CDEP, first-match-wins) and TypeDistribution.

go build / go vet / go test ./internal/releaseparser/... — all green.
2026-09-01 13:18:40 +03:00
Yevhen Odynets f2629f002c releaseparser: move group-agnostic parser to groups/, GB doc-blocks, per-group JSON reports
Generalise the parser: the MOONBLOOD group profile is gone, the parser and
its dictionaries are now group-agnostic under internal/releaseparser/groups.

Positional model:
- [0]=Artist, [1]=Title are fixed and never matched against dictionaries, so
  titles like "Split"/"Demo"/"De" are never eaten.
- [len-1]=Group is always read from the line, not from the query key.
- [len-2]=Year when it is a 4-digit 19xx|20xx token; otherwise the slot is
  resolved as a middle-zone token (e.g. FLAC is still picked up as format).
- The middle zone is resolved via case-insensitive dictionaries in the order
  format -> source -> bit-depth -> resolution -> edition -> language ->
  catalogue number; stored values keep their original case.

Catalogue numbers: any "(...)" token in the middle zone is a catalogue number
regardless of content (digits, roman numerals, dots, underscores, mixed case);
splitting never breaks tokens inside parentheses.

Dictionaries moved to internal/releaseparser/groups/resources/dicts and
embedded via go:embed; dead profile fields (Name, ExpectedTailOrder) removed;
profile comments rewritten in British English.

File-based AnalyzeGroup/TestParseMoonblood removed — titles now come from the
database (cmd/srrdb: srrdb <releaser>..., config/secret.yaml DSN).

Validation output (cmd/srrdb):
- tmp/releaseparser/<group>.json         — per-group parsed ParsedRelease records
- tmp/releaseparser/<releaser>.report.json — per-request aggregate (same as console)
- review_unknown_tokens.txt              — unknown/warning rows for manual review

Tests updated for the positional model; added
TestParseCatalogNumberWithDotAndRoman for (DYN.3140-2) and (GOWP_DCCCLXXXIX).
go build, go vet and go test all pass.
2026-09-01 11:28:19 +03:00
Yevhen Odynets feef080d80 fix(file) Remove Printline 2026-09-01 09:19:17 +03:00
Yevhen Odynets 736921ae0b cosmetic changes 2026-09-01 09:05:27 +03:00
Yevhen Odynets 31febb9f56 releaseparser: adopt fixed positional model, auto-detect catalogues, add GB doc-blocks
Parse releases with an explicit fixed positional model and document the
whole logic in British English doc-blocks.

Model:
- [0]=Artist, [1]=Title are fixed and never matched against dictionaries,
  so titles like "Split"/"Demo"/"De" are never eaten.
- [len-1]=Group is always read from the line, not from the query key.
- [len-2]=Year when it is a 4-digit 19xx|20xx token; otherwise the slot is
  resolved as a middle-zone token (e.g. FLAC still picked up as format).
- The middle zone is resolved via case-insensitive dictionaries in the order
  format -> source -> bit-depth -> resolution -> edition -> language ->
  catalogue number. Position within the zone is irrelevant.

Catalogue numbers:
- Any "(...)" token in the middle zone is a catalogue number regardless of
  content (digits, roman numerals, dots, underscores, mixed case). Removed
  the hasDigit requirement and character whitelist that rejected real
  catalogues like (DYN.3140-2) and (GOWP_DCCCLXXXIX).
- Splitting never breaks tokens inside parentheses.

Case handling: lookups are case-insensitive; stored values keep their
original case from the line.

Documentation: replaced Ukrainian comments in parser.go and analyzer.go with
British-English doc-blocks describing the model, tail resolution order,
catalogue rule and confidence scoring.

Tests:
- Add TestParseCatalogNumberWithDotAndRoman for (DYN.3140-2)/(GOWP_DCCCLXXXIX).
- Update case-insensitive, split-title, no-year and language expectations.
- go build, go vet and go test all pass.
2026-09-01 04:26:06 +03:00
Yevhen Odynets 3f3598c446 add nultie gpouring 2026-09-01 00:08:03 +03:00
Yevhen Odynets 1b2521d4ac refactored & audited, real analizer added 2026-08-31 22:24:38 +03:00
Yevhen Odynets e11c82bd76 Fixed rutracker after changing stucture of the atom file of theirs own 2026-08-31 20:24:07 +03:00
Yevhen Odynets fedb470da6 minor changes 2026-08-31 19:00:09 +03:00
Yevhen Odynets 167d98ac9c updated go version 2026-04-29 19:12:36 +03:00
Yevhen Odynets fcf98f20cb Merge branch 'master' of git.kplus.net.ua-yevhen:yevhen/resource-scraper 2026-01-18 01:27:48 +02:00
root 1565c066f7 Make install.sh executable 2026-01-18 01:27:29 +02:00
Yevhen Odynets 52fbcaebbf upgrade packages 2026-01-18 01:22:01 +02:00
Yevhen Odynets 0979bf5ad8 tuned default precene fetch 2026-01-18 01:07:51 +02:00
yevhen 8eeb962016 changed handlers summoning 2025-11-12 12:56:22 +02:00
yevhen c6d1a8d455 fixed mails moving 2025-10-28 13:36:53 +02:00
yevhen c8745e1f60 some mirror fixed 2025-10-28 12:59:54 +02:00
yevhen ac4b0ef47b added to ignore STONERD in prescene 2025-10-28 11:38:00 +02:00
yevhen 879b33d385 all fixed 2025-10-28 11:36:11 +02:00
yevhen 54aaa80f23 migrate to 1.25.3 2025-10-28 10:16:56 +02:00
yevhen a41ccec4a0 change modelu name to git.kplus.net.ua 2025-10-06 12:30:33 +03:00
yevhen b26c43ee4b change git imports 2025-10-06 12:28:15 +03:00
yevhen 1544b943fc cahnge git server and fixed time parsing 2025-10-06 12:21:22 +03:00
yevhen 970f6c2bfd change done folder 2025-03-04 11:39:56 +02:00
yevhen 1c17e73e2d stb config changed 2025-03-04 08:47:42 +02:00
yevhen 8dbae5f46b Merge branch 'feature/logging' into develop
logging feature finished
2025-03-03 09:41:46 +02:00
yevhen 4ca1cc45fd config rearranged 2025-03-03 09:37:42 +02:00
yevhen 203f834f65 upadted to 1.24.0; fixed stb and spiddped doubles in precene 2025-03-03 09:28:41 +02:00
yevhen 0ecf0ddec1 preset scraper added 2024-09-10 15:57:48 +03:00
yevhen bfdfc634e4 add config samples 2024-09-09 09:12:25 +03:00
yevhen e587e645fc add scraping the torrent topics rss files 2024-09-09 08:54:29 +03:00
yevhen 20c4f25c55 very first commit 2024-09-08 03:01:32 +03:00