Skip to content

Browse albums by record label: initial version #1382

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: public/9.1
Choose a base branch
from

Conversation

darrell-k
Copy link
Contributor

Basic functionality to allow browsing albums by record label.

Copy link
Member

@michaelherger michaelherger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I started this review, expecting "basic functionality to allow browsing albums by record label". But after leaving some of my relatively unimportant nitpick comments I came to realise that code to actually browse albums by label is missing, right? You'll have to add label filtering on the album level. And implement the missing sub _labels etc. I therefore stop here and leave the reviews as they are. I know that this is not done yet. So here we go anyway...

Smart move to have added a label column more than a year ago 😉.

Is a single label good enough (I certainly hope so - but you never know)?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

serverstatusQuery && infoTotalQuery might need an update? They're missing eg. works, too

@@ -296,6 +296,7 @@ sub albumsQuery {
my $work = $request->getParam('work_id');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the tab after $work to fix the alignment. Now that's really important.


if (defined $contributorID) {

$sql .= 'JOIN contributor_album ON albums.id = contributor_album.contributor ';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please indent the first line by one more tab

my $libraryID = Slim::Music::VirtualLibraries->getRealId($request->getParam('library_id'));
my $tags = $request->getParam('tags') || '';

my $sql = 'SELECT distinct label FROM albums ';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't have an index on label yet. SQLite is fast, in particular with the usually not too big albums table. Therefore I'd say let's cheat that index in without bumping the database version. That way we don't require a full wipe & rescan, but those doing so anyway will still take advantage of the new index.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the preferred method?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just add it to schema_23_up.sql, where you've added the column.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I didn't know 'old' schema files would be run again.

Copy link
Member

@michaelherger michaelherger Apr 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, you're actually right 😞: we only wipe the tables during a wipe & rescan. I thought we'd drop the database and build from scratch. So that won't work - unless someone went to manually delete the file. I fear we'll need another migration file. Shouldn't hurt those coming from 9.0, but only those already on 9.1 (@frank1969b).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, you're actually right 😞: we only wipe the tables during a wipe & rescan. I thought we'd drop the database and build from scratch. So that won't work - unless someone went to manually delete the file. I fear we'll need another migration file. Shouldn't hurt those coming from 9.0, but only those already on 9.1 (@frank1969b).

We could do something like a "create index if doesn't exist" in server startup. Maybe a bit hacky.

Copy link
Member

@michaelherger michaelherger Apr 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just noticed that we don't have indexes extid for albums or contributors either. Not sure whether we use them. But eg. counting all albums where extid is not null takes a fraction of a second on a Pi4 with about 200 out of 1700 albums having an extid. Nothing compared to Frank's collection, of course. Would you know off the top of your head whether we ever query for albums or artists with/without extid? You might add them to the .sql files while we're at it...

Anyway: we could put such a hack in place for a few weeks. Should just not forget to remove it after a while Slim::Schema::init() might be a candidate. Maybe log a warning to remind us of the hack?


if ($valid && $tags ne 'CC') {

$sql .= 'ORDER BY 1 ';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow... hadn't known this shortcut. But... please use the column name for easier reading.

@darrell-k
Copy link
Contributor Author

I think you can already browse albums by label - that is pick the label and browse its albums?

Signed-off-by: darrell-k <[email protected]>
Signed-off-by: darrell-k <[email protected]>
@michaelherger
Copy link
Member

Don't know whether you have access to CoPilot on Github. Here's what it thinks about this PR:


Review and Observations

Strengths

New Feature Introduction:

The addition of record_label appears to be a meaningful enhancement, allowing users to filter and query albums by their associated labels. This could be a useful feature for users with large music collections.

Code Consistency:

The changes integrate well with the existing query framework (e.g., consistent use of $request->getParam, $w, and $p for SQL conditions and parameters).

Caching:

Caching in labelsQuery is a good optimization to minimize database queries during rescan operations.

Backward Compatibility:

Changes like adding label to the schema and extending queries appear to be non-breaking for existing functionality.

Potential Concerns

Database Schema Changes:

The changes introduce a new column label in the albums table. This requires a migration step to ensure the database schema is updated. It's unclear if this migration is handled separately.

Performance Impact:

The new labelsQuery and additional logic in albumsQuery may increase the complexity of SQL queries. For large datasets, this could lead to performance degradation unless properly indexed.

Testing:

No information is provided about tests for the new functionality. It's important to ensure that unit tests and integration tests cover edge cases and regressions.

New File Omission:

The contents of Slim/Menu/BrowseLibrary/Labels.pm are not included in the diff, making it difficult to review its implementation.

Error Handling:

In labelsQuery, if a database error occurs (e.g., invalid parameters or query execution failure), there doesn't appear to be specific error handling.

Suggestions

Database Migration:

Make sure migration scripts for adding the label column to the database are included and well-documented.

Indexing:

Ensure the new label field is indexed to optimize query performance.

Testing:

Add comprehensive tests for:

  • The new labelsQuery logic.
  • Changes to albumsQuery and infoTotalQuery.
  • Edge cases (e.g., invalid parameters, empty results).

Documentation:

Update any user-facing documentation to reflect the new functionality (e.g., how to use the record_label filter).

Code Comments:

Add comments to the new labelsQuery function for better maintainability.

@darrell-k
Copy link
Contributor Author

Statements that are (a) obvious, (b) miss the point, or (c) wrong. I have absolutely no time for AI.


foreach (@$items) {
$_->{'name'} = $_->{'record_label'};
$_->{'image'} = 'html/images/albums.png';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was surprised by the number of labels found in my (test) collection. Must be because many of those files come from users with extensive metadata 😁.

But looking at that list I was wondering... albums.png all over the place doesn't make sense IMHO. I'd prefer a text list only. Or did you consider adding support for label artwork?... Would require another schema change. Or some MAI work? I bet people caring about labels would recognise those logos.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought the same thing: a job for MAI if it's feasible. I just used album as a placeholder. For the top level menu icon, we could do with a label.png but I am certainly not the right person to be designing one. Maybe you could ask AI to come up with a record label icon in the style of LMS. If it does a good job, I might change my opinion of its usefulness 😂.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI has failed me (in the short time I tried).

Just in case you were considering a dedicated labels table, reserve a column for a logo ID...

@pascalberger
Copy link
Contributor

Is a single label good enough (I certainly hope so - but you never know)?

You for sure already know there is always this person with the most complicated setup. So here I'm with albums tagged with multiple labels :-)

@darrell-k
Copy link
Contributor Author

Is a single label good enough (I certainly hope so - but you never know)?

You for sure already know there is always this person with the most complicated setup. So here I'm with albums tagged with multiple labels :-)

How so? A release by definition is by a single record label, I would have thought. I know it's sometimes complicated where there may be different imprints or even different labels in different territories, but surely they would count as different albums?

If you can provide details of your use case, we can consider it.

@michaelherger
Copy link
Member

If you can provide details of your use case, we can consider it.

You better try to talk @pascalberger out of it 😂. I think this will increase complexity a lot for what seems like an extremely esoteric use case...

@pascalberger
Copy link
Contributor

pascalberger commented Apr 26, 2025

If you can provide details of your use case, we can consider it.

You better try to talk @pascalberger out of it 😂. I think this will increase complexity a lot for what seems like an extremely esoteric use case...

I think it depends on what you consider a label. Following the definition used by e.g. Discogs, releases with multiple labels is very common.

E.g.

Same for MusicBrainz (e.g. https://musicbrainz.org/release/cb230074-a468-4012-9900-59268364f649)

@frank1969b
Copy link

Thanks for tagging me. I will keep an eye sehen there is a build that smells Like full rescan ;-)

Personally - as someone from the "music industry" - I don't Tag Labels for nowadays it's the rightowner that counts and many well known artists keep them for theirselves and licence them for a Limited period only to a label. Further more in the past the UK and/or US Label were different from the German one
... and looking at compilations You may have a dozen Labels for one Song/Artist... So I think O won't test this but nice Feature though

@darrell-k
Copy link
Contributor Author

I suppose it comes down to the difference between an album and a release, although LMS often uses the terms interchangeably.

Yes an album can have many releases, sometimes on different labels, but I people would generally tag those releases as different albums, as the reason for possessing multiple versions (in a digital or digitized library) would be remastering/differences in the track list, etc. This is different to the world of physical media where collectors might be interested in different album covers, physical format, vinyl colour/weight etc.

At the risk of further opening the can of worms, what does Musicbrainz think? If catalogue number is an attribute of album, then that would support the album=release option.

@mikeysas
Copy link

mikeysas commented Apr 29, 2025

In each of the multiple label examples, they appear to be parent and subsidiary label or two subsidiaries from the same parent label. I guess the question here for @pascalberger and others is what is your use case for browsing by label and would you really want to browse by Virgin or Hut to find that Smashing Pumpkins album? How do you see yourself using Browse by Label in LMS? How will the Label tag be populated? Does Picard import that tag? I don't think I have seen a Label tag imported by mp3tag even with the extended MB webscript? Is limiting to one label per Album a problem for your use cases?

**EDIT: Correction to the above
mp3tag uses the tag PUBLISHER which is imported from MB. I don't know how it handles ones with two Publishers as I would have to go digging to see if I have such an example.
@darrell-k would you be including the PUBLISHER tag for this?

My Calissical collection is small, but I understand how Browse by Label would be useful for specific labels that have prolific Classical collections. Given I have an extensive Jazz collection, the thought of browsing by Blue Note for example is interesting and there are a few others that could be interesting. In other genres of music I could see browsing specific indie labels that have a thematic focus to create a playlist. But I personally would not use browse by label for a mega label like Virgin.

So the question here is keeping this simple and only supporting browse by the first label sufficient for most use cases. I think so, but it will mean that some will have to go through and clean up some Label tags if they have already been populated with multiple entries. Since Browse by Label should be put in the category of "Power Tagger" user is this really issue worth over complicating this for? And before you answer "yes, this must support multiple labels," consider that this requirement may delay or completely prevent Browse Label being implemented.

FYI - I am ok either way as I am not sure if and when I would take the time to go add Label tags to my music, but figured I would just share a perspective of realistic usage that sometimes gets lost in these conversations.

**EDIT: I guess I do have some labels tagged as Publisher so I would certainly check out the results to see if it is useful for me, but still not sure how much effort I would make to clean it up or how soon I would do that.

@audiomuze
Copy link

As one that partakes in "extreme tagging" I've just run a query on my tagging database and there are 5662 distinct labels in it, of which 345 contain a delimited string in the record, meaning there is more than one label tagged to the album. They've all come via Picard (overriding majority I imagine) or were already pre-populated when buying digital content.

label

Lichtdicht Records\\[PIAS] Germany
[PIAS]
[PIAS] Australia
[PIAS] LE LABEL
[PIAS] Le Label
[PIAS] Recordings
[PIAS] Recordings France
[PIAS] Recordings Germany
[PIAS] Recordings Holland
ECM New Series
ECM Records
ECM Records GmbH

If I ran the 5662 through string-grouper I'm pretty sure I could whittle the 5662 list down significantly, and it is something I would do, because having 8 different instances of [PIAS] or 3 different instances of ECM is not useful to me, whereas one would be would be because, like Blue Note, Frontier Records etc. they are a stable for similar genres and/or musicians.

As to whether multiple labels matter, probably not, but if it's simple to create a 1:many relationship without taxing performance then having something pop up under more than one label shouldn't be a big deal.

As with my comments on forum regarding Genres, being able to select numerous labels for browsing content e.g. Frontiers Music and Nuclear Blast is likely to reveal a richer pool of choice than either in isolation, much as being able to do the same for genres would.

@mikeysas
Copy link

mikeysas commented Apr 29, 2025

Interesting to note the lack of standards here....

MusicBrainz Picard uses Label
mp3tag uses Publisher

And as mentioned above mp3tag imports the label from MB as Publisher

@audiomuze
Copy link

audiomuze commented Apr 29, 2025

Interesting to note the lack of standards here....

MusicBrainz Picard uses Label mp3tag uses Publisher

And as mentioned above mp3tag imports the label from MB as Publisher

Music metadata has always been a mess, which is why it’s important for software like Lyrion to have an opinion (i.e. decide on how it will handle something that relies on metadata, implement it and publish it for users to opt in, or not, as the case may be). Absent that, progress is impossible.

@CDrummond
Copy link
Contributor

Currently when browsing "Record Label" an album list is shown, I'd like to change that for Material. However, it does not (currently) seem possible to use the "record_label:XXXX" as a filter. e.g. I'd like to be able to call ["artists", 0, 1000, "record_label:XXX"] to get an artist list associated with the record label - likewise "genres" and "years". Ideally I'd like to be able to navigate "My Music / Record Label" and then show within this list the list of other browse modes (so excluding "Record Label"). Then you could browse "My Music / Record Label / EMI / Years / 1990 / Genres / Hard Rock / Artists / XXX" To do this the various commands need to be able to filter on "record_label:" Is it planned to add this? Or will it only be possible to filter albums?

Is/will "record_label" be returned in the player status query? That way I can show this in the MAI track view.

Also, the browse mode label should be pluralised to match others - "Record Labels" not "Record Label".

@michaelherger
Copy link
Member

You forgot to filter the artists by their role on the given label and release type 🤯.

Poor @darrell-k who thought he was providing a nice little addition. It could all be done. But this will become a nightmare (not to mention a major effort).

Are people really that heavily into labels? Wow...

@darrell-k
Copy link
Contributor Author

I don't mind all the suggestions, after all, I did call this the "initial version" and was fully expecting requests for extra functionality. Also it seems worth implementing the many-to-many relationship with albums.

But those impatient for this need to pray for rain in the south of England, it's not looking good for you at the moment ;-)

@audiomuze
Copy link

But those impatient for this need to pray for rain in the south of England, it's not looking good for you at the moment ;-)

It’s England, give it an hour.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants