From 28553e7c2dee057a8ead01310943de4d55134994 Mon Sep 17 00:00:00 2001 From: blissful Date: Fri, 26 Apr 2024 14:16:20 -0400 Subject: [PATCH] doc+conftest+add edition --- conftest.py | 30 ++++++++++++++++++++++++++---- docs/METADATA_TOOLS.md | 37 ++++++++++++++++++++++++++++++++----- docs/TEMPLATES.md | 10 +++++++++- rose/cache.sql | 24 ++++++++++++++++++++++++ 4 files changed, 91 insertions(+), 10 deletions(-) diff --git a/conftest.py b/conftest.py index 6faf178..5f5863f 100644 --- a/conftest.py +++ b/conftest.py @@ -113,10 +113,10 @@ def seeded_cache(config: Config) -> None: conn.executescript( f"""\ INSERT INTO releases - (id , source_path , cover_image_path , added_at , datafile_mtime, title , releasetype, releaseyear, compositionyear, catalognumber, disctotal, new , metahash) -VALUES ('r1', '{dirpaths[0]}', null , '0000-01-01T00:00:00+00:00', '999' , 'Release 1', 'album' , 2023 , null , null , 1 , false, '1') - , ('r2', '{dirpaths[1]}', '{imagepaths[0]}', '0000-01-01T00:00:00+00:00', '999' , 'Release 2', 'album' , 2021 , null , 'DG-001' , 1 , false, '2') - , ('r3', '{dirpaths[2]}', null , '0000-01-01T00:00:00+00:00', '999' , 'Release 3', 'album' , 2021 , 1780 , 'DG-002' , 1 , true , '3'); + (id , source_path , cover_image_path , added_at , datafile_mtime, title , releasetype, releaseyear, originalyear, compositionyear, catalognumber, edition , disctotal, new , metahash) +VALUES ('r1', '{dirpaths[0]}', null , '0000-01-01T00:00:00+00:00', '999' , 'Release 1', 'album' , 2023 , null , null , null , null , 1 , false, '1') + , ('r2', '{dirpaths[1]}', '{imagepaths[0]}', '0000-01-01T00:00:00+00:00', '999' , 'Release 2', 'album' , 2021 , 2019 , null , 'DG-001' , 'Deluxe', 1 , false, '2') + , ('r3', '{dirpaths[2]}', null , '0000-01-01T00:00:00+00:00', '999' , 'Release 3', 'album' , 2021 , null , 1780 , 'DG-002' , null , 1 , true , '3'); INSERT INTO releases_genres (release_id, genre , position) @@ -124,6 +124,18 @@ def seeded_cache(config: Config) -> None: , ('r1' , 'Deep House', 2) , ('r2' , 'Classical' , 1); +INSERT INTO releases_secondary_genres + (release_id, genre , position) +VALUES ('r1' , 'Rominimal' , 1) + , ('r1' , 'Ambient' , 2) + , ('r2' , 'Orchestral', 1); + +INSERT INTO releases_descriptors + (release_id, descriptor, position) +VALUES ('r1' , 'Warm' , 1) + , ('r1' , 'Hot' , 2) + , ('r2' , 'Wet' , 1); + INSERT INTO releases_labels (release_id, label , position) VALUES ('r1' , 'Silk Music' , 1) @@ -185,10 +197,14 @@ def seeded_cache(config: Config) -> None: , discnumber , releasetitle , releaseyear + , originalyear , compositionyear , catalognumber + , edition , releasetype , genre + , secondary_genre + , descriptor , label , releaseartist , trackartist @@ -200,16 +216,22 @@ def seeded_cache(config: Config) -> None: , process_string_for_fts(t.discnumber) AS discnumber , process_string_for_fts(r.title) AS releasetitle , process_string_for_fts(r.releaseyear) AS releaseyear + , process_string_for_fts(r.originalyear) AS originalyear , process_string_for_fts(r.compositionyear) AS compositionyear , process_string_for_fts(r.catalognumber) AS catalognumber + , process_string_for_fts(r.edition) AS edition , process_string_for_fts(r.releasetype) AS releasetype , process_string_for_fts(COALESCE(GROUP_CONCAT(rg.genre, ' '), '')) AS genre + , process_string_for_fts(COALESCE(GROUP_CONCAT(rs.genre, ' '), '')) AS secondary_genre + , process_string_for_fts(COALESCE(GROUP_CONCAT(rd.descriptor, ' '), '')) AS descriptor , process_string_for_fts(COALESCE(GROUP_CONCAT(rl.label, ' '), '')) AS label , process_string_for_fts(COALESCE(GROUP_CONCAT(ra.artist, ' '), '')) AS releaseartist , process_string_for_fts(COALESCE(GROUP_CONCAT(ta.artist, ' '), '')) AS trackartist FROM tracks t JOIN releases r ON r.id = t.release_id LEFT JOIN releases_genres rg ON rg.release_id = r.id + LEFT JOIN releases_secondary_genres rs ON rs.release_id = r.id + LEFT JOIN releases_descriptors rd ON rd.release_id = r.id LEFT JOIN releases_labels rl ON rl.release_id = r.id LEFT JOIN releases_artists ra ON ra.release_id = r.id LEFT JOIN tracks_artists ta ON ta.track_id = t.id diff --git a/docs/METADATA_TOOLS.md b/docs/METADATA_TOOLS.md index e280140..b9e6515 100644 --- a/docs/METADATA_TOOLS.md +++ b/docs/METADATA_TOOLS.md @@ -37,15 +37,38 @@ title = "Mix & Match" new = false releasetype = "ep" releaseyear = 2017 +originalyear = 2017 compositionyear = -9999 genres = [ + "K-Pop", "Dance-Pop", "Future Bass", - "K-Pop", +] +secondary_genres = [ + "Electropop", + "Alternative R&B", + "Synthpop", +] +descriptors = [ + "melodic", + "energetic", + "female vocalist", + "sensual", + "love", + "playful", + "romantic", + "eclectic", + "lush", + "rhythmic", + "optimistic", + "warm", + "urban", + "uplifting", ] labels = [ - "BlockBerry Creative", + "BlockBerryCreative", ] +edition = "" catalognumber = "WMED0709" artists = [ { name = "LOOΠΔ ODD EYE CIRCLE", role = "main" }, @@ -294,14 +317,18 @@ The rules engine supports matching and acting on the following tags: - `releaseartist[djmixer]` - `releasetype` - `releaseyear` +- `originalyear` - `compositionyear` - `genre` +- `secondary_genre` +- `descriptor` - `label` - `catalognumber` +- `edition` -The `trackartist[*]`, `releaseartist[*]`, `genre`, and `label` tags are _multi-value_ tags, which -have a slightly different behavior from single-value tags for some of the actions. We'll explore -this difference in the [Actions](#actions) section. +The `trackartist[*]`, `releaseartist[*]`, `genre`, `secondary_genre`, `descriptor`, and `label` tags +are _multi-value_ tags, which have a slightly different behavior from single-value tags for some of +the actions. We'll explore this difference in the [Actions](#actions) section. For convenience, the rules parser also allows you to specify _tag aliases_ in place of the above tags, which expand to multiple tags when matching. The diff --git a/docs/TEMPLATES.md b/docs/TEMPLATES.md index 897dfe4..3b23454 100644 --- a/docs/TEMPLATES.md +++ b/docs/TEMPLATES.md @@ -78,14 +78,18 @@ Rosé provides the following template variables for releases: added_at: str # ISO8601 timestamp of when the release was added to the library. releasetitle: str releasetype: str # The type of the release (e.g. single, ep, etc). One of the enums as defined in TAGGING_CONVENTIONS.md. -releaseyear: int | None +releaseyear: int | None # The year of this edition of the release. +originalyear: int | None # The year of the first edition of the release. compositionyear: int | None # The year that the release was composed. Mainly of interest in classical music. new: bool # The "new"-ness of the release. See RELEASES.md for documentation on this feature. disctotal: int # The number of discs in the release. genres: list[str] parent_genres: list[str] # The parent genres of `genres`, excluding `genres`. +secondary_genres: list[str] # The secondary/minor genres. +parent_secondary_genres: list[str] # The parent genres of `secondary_genres`, excluding `secondary_genres`. labels: list[str] catalognumber: str | None +edition: str | None # The title of this edition of the release. releaseartists: ArtistMapping # All release artists: an object with 6 properties, each corresponding to one role. releaseartists.main: list[Artist] # The Artist object has a `name` property with the artist name. releaseartists.guest: list[Artist] @@ -118,12 +122,16 @@ trackartists.djmixer: list[Artist] releasetitle: str releasetype: str # The type of the track's release (e.g. single, ep, etc). releaseyear: int | None +originalyear: int | None # The year of the first edition of the release. compositionyear: int | None # The year that the release was composed. Mainly of interest in classical music. new: bool # The "new"-ness of the track's release. genres: list[str] parent_genres: list[str] # The parent genres of `genres`, excluding `genres`. +secondary_genres: list[str] # The secondary/minor genres. +parent_secondary_genres: list[str] # The parent genres of `secondary_genres`, excluding `secondary_genres`. labels: list[str] catalognumber: str | None +edition: str | None # The title of this edition of the release. releaseartists: ArtistMapping # All release artists: an object with 6 properties, each corresponding to one role. releaseartists.main: list[Artist] # The Artist object has a `name` property with the artist name. releaseartists.guest: list[Artist] diff --git a/rose/cache.sql b/rose/cache.sql index 34c9441..6c4b876 100644 --- a/rose/cache.sql +++ b/rose/cache.sql @@ -17,6 +17,7 @@ CREATE TABLE releases ( releaseyear INTEGER, originalyear INTEGER, compositionyear INTEGER, + edition TEXT, catalognumber TEXT, disctotal INTEGER NOT NULL, -- A sha256 of the release object, which can be used as a performant cache key. @@ -172,9 +173,13 @@ CREATE VIRTUAL TABLE rules_engine_fts USING fts5 ( , releasetitle , releasetype , releaseyear + , originalyear , compositionyear + , edition , catalognumber , genre + , secondary_genres + , descriptors , label , releaseartist , trackartist @@ -194,6 +199,18 @@ CREATE VIEW releases_view AS , GROUP_CONCAT(genre, ' ¬ ') AS genres FROM (SELECT * FROM releases_genres ORDER BY position) GROUP BY release_id + ), secondary_genres AS ( + SELECT + release_id + , GROUP_CONCAT(genre, ' ¬ ') AS genres + FROM (SELECT * FROM releases_secondary_genres ORDER BY position) + GROUP BY release_id + ), descriptors AS ( + SELECT + release_id + , GROUP_CONCAT(descriptor, ' ¬ ') AS descriptors + FROM (SELECT * FROM releases_descriptors ORDER BY position) + GROUP BY release_id ), labels AS ( SELECT release_id @@ -217,17 +234,24 @@ CREATE VIEW releases_view AS , r.title AS releasetitle , r.releasetype , r.releaseyear + , r.originalyear , r.compositionyear + , r.edition , r.catalognumber , r.disctotal , r.new , r.metahash , COALESCE(g.genres, '') AS genres + , COALESCE(s.secondary_genres, '') AS secondary_genres + , COALESCE(d.descriptors, '') AS descriptors , COALESCE(l.labels, '') AS labels , COALESCE(a.names, '') AS releaseartist_names , COALESCE(a.roles, '') AS releaseartist_roles FROM releases r LEFT JOIN genres g ON g.release_id = r.id + LEFT JOIN secondary_genres s ON s.release_id = r.id + LEFT JOIN descriptors d ON d.release_id = r.id + LEFT JOIN genres g ON g.release_id = r.id LEFT JOIN labels l ON l.release_id = r.id LEFT JOIN artists a ON a.release_id = r.id;