Skip to content

Commit

Permalink
doc+conftest+add edition
Browse files Browse the repository at this point in the history
  • Loading branch information
azuline committed Apr 26, 2024
1 parent 9e424e7 commit 28553e7
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 10 deletions.
30 changes: 26 additions & 4 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,17 +113,29 @@ 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)
VALUES ('r1' , 'Techno' , 1)
, ('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)
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
37 changes: 32 additions & 5 deletions docs/METADATA_TOOLS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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" },
Expand Down Expand Up @@ -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
Expand Down
10 changes: 9 additions & 1 deletion docs/TEMPLATES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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]
Expand Down
24 changes: 24 additions & 0 deletions rose/cache.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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;

Expand Down

0 comments on commit 28553e7

Please sign in to comment.