Skip to content

Commit

Permalink
#879 Add support for release type information in the music library
Browse files Browse the repository at this point in the history
- store `release type` info in database
- add support to create "Extended Browse Modes" based on the release type
- add setting to ignore release type information (to behave as before the change)
- add setting to ignore certain types from the "Album" browse menu
- add new `W` tag to relevant queries
  • Loading branch information
mherger committed Oct 12, 2023
1 parent 0ea69ab commit ba4e305
Show file tree
Hide file tree
Showing 19 changed files with 285 additions and 99 deletions.
27 changes: 27 additions & 0 deletions HTML/EN/html/docs/cli-api.html
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ <h4 id="jsonrpc">jsonrpc.js</h4>

<h3 id="Changelog">Changelog</h3>

<h4 id="8.4">Changes starting from Squeezebox Server 8.4</h4>
<ul>
<li>Added support for release types to <a href="#albums">albums</a>, and <a href="#titles">titles</a> queries.</li>
</ul>

<h4 id="8.2">Changes starting from Squeezebox Server 8.2</h4>
<ul>
<li>Added query to figure out whether fulltext search is enabled or not (<a href="#fulltextsearch">fulltextsearch</a>).</li>
Expand Down Expand Up @@ -3923,6 +3928,17 @@ <h3 id="DB">
1 if this album is a compilation.
</td>
</tr>
<tr>
<td>
W
</td>
<td>
&nbsp;&nbsp;release_type
</td>
<td>
The release type of an album, eg. "album", "ep", etc.
</td>
</tr>
<tr>
<td>
a
Expand Down Expand Up @@ -5094,6 +5110,17 @@ <h3 id="DB">
1 if the album this track belongs to is a compilation
</td>
</tr>
<tr>
<td>
<b>W</b>
</td>
<td>
release_type
</td>
<td>
The release type of the track's album, eg. "album", "ep", etc.
</td>
</tr>
<tr>
<td>
<b>d</b>
Expand Down
20 changes: 18 additions & 2 deletions HTML/EN/settings/server/behavior.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,27 @@
[% END %]
[% END %]

[% WRAPPER settingSection %]
[% WRAPPER settingGroup title="SETUP_RELEASE_TYPES" desc="SETUP_RELEASE_TYPES_DESC"%]
[% FOREACH releaseType IN release_types %]
<input type="checkbox" [% IF NOT releaseType.ignore %]checked="1"[% END %] class="stdedit" name="release_type_[% releaseType.id %]" id="release_type_[% releaseType.id %]" value="1" />
<label for="release_type_[% releaseType.id %]" class="stdlabel">[% releaseType.title %]</label>[% IF loop.last; ""; ELSE; "<br/>"; END %]
[% END %]
[% END %]

[% WRAPPER settingGroup title="" desc=""%]
<select class="stdedit" name="pref_ignoreReleaseTypes" id="ignoreReleaseTypes">
<option [% IF NOT prefs.pref_ignoreReleaseTypes %]selected [% END %]value="0">[% 'SETUP_IGNORE_RELEASE_TYPES_0' | string %]</option>
<option [% IF prefs.pref_ignoreReleaseTypes %]selected [% END %]value="1">[% 'SETUP_IGNORE_RELEASE_TYPES_1' | string %]</option>
</select>
[% END %]
[% END %]

[% WRAPPER setting title="SETUP_NOGENREFILTER" desc="SETUP_NOGENREFILTER_DESC"%]
<select class="stdedit" name="pref_noGenreFilter" id="noGenreFilter">

<option [% IF NOT prefs.pref_noGenreFilter %]selected [% END %]value="0">[% 'SETUP_NOGENREFILTER_0' | string %]</option>
<option [% IF prefs.pref_noGenreFilter%]selected [% END %]value="1">[% 'SETUP_NOGENREFILTER_1' | string %]</option>
<option [% IF prefs.pref_noGenreFilter %]selected [% END %]value="1">[% 'SETUP_NOGENREFILTER_1' | string %]</option>

</select>
[% END %]
Expand All @@ -65,7 +81,7 @@
<select class="stdedit" name="pref_noRoleFilter" id="noRoleFilter">

<option [% IF NOT prefs.pref_noRoleFilter %]selected [% END %]value="0">[% 'SETUP_NOROLEFILTER_0' | string %]</option>
<option [% IF prefs.pref_noRoleFilter%]selected [% END %]value="1">[% 'SETUP_NOROLEFILTER_1' | string %]</option>
<option [% IF prefs.pref_noRoleFilter %]selected [% END %]value="1">[% 'SETUP_NOROLEFILTER_1' | string %]</option>

</select>
[% END %]
Expand Down
Empty file added SQL/SQLite/schema_22_down.sql
Empty file.
2 changes: 2 additions & 0 deletions SQL/SQLite/schema_22_up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE albums ADD release_type varchar(64);
CREATE INDEX albumsReleaseTypeIndex ON albums (release_type);
Empty file added SQL/mysql/schema_22_down.sql
Empty file.
2 changes: 2 additions & 0 deletions SQL/mysql/schema_22_up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE albums ADD release_type varchar(64);
CREATE INDEX albumsReleaseTypeIndex ON albums (release_type);
25 changes: 0 additions & 25 deletions SQL/slimservice/slimservice-sqlite.sql

This file was deleted.

29 changes: 29 additions & 0 deletions Slim/Control/Queries.pm
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ sub albumsQuery {
my $trackID = $request->getParam('track_id');
my $albumID = $request->getParam('album_id');
my $roleID = $request->getParam('role_id');
my $releaseType = $request->getParam('release_type');
my $libraryID = Slim::Music::VirtualLibraries->getRealId($request->getParam('library_id'));
my $year = $request->getParam('year');
my $sort = $request->getParam('sort') || ($roleID ? 'artistalbum' : 'album');
Expand Down Expand Up @@ -475,6 +476,12 @@ sub albumsQuery {
push @{$p}, $libraryID;
}

if (defined $releaseType) {
my @releaseTypes = split(',', $releaseType);
push @{$w}, 'albums.release_type IN (' . join(', ', map {'?'} @releaseTypes) . ')';
push @{$p}, @releaseTypes;
}

if (defined $year) {
push @{$w}, 'albums.year = ?';
push @{$p}, $year;
Expand Down Expand Up @@ -527,6 +534,11 @@ sub albumsQuery {
$c->{'albums.compilation'} = 1;
}

my $wantsReleaseTypes = !$prefs->get('ignoreReleaseTypes');
if ( $tags =~ /W/ && $wantsReleaseTypes ) {
$c->{'albums.release_type'} = 1;
}

if ( $tags =~ /E/ ) {
$c->{'albums.extid'} = 1;
}
Expand Down Expand Up @@ -735,6 +747,7 @@ sub albumsQuery {
$tags =~ /i/ && $request->addResultLoopIfValueDefined($loopname, $chunkCount, 'disc', $c->{'albums.disc'});
$tags =~ /q/ && $request->addResultLoopIfValueDefined($loopname, $chunkCount, 'disccount', $c->{'albums.discc'});
$tags =~ /w/ && $request->addResultLoopIfValueDefined($loopname, $chunkCount, 'compilation', $c->{'albums.compilation'});
$tags =~ /W/ && $request->addResultLoopIfValueDefined($loopname, $chunkCount, 'release_type', $wantsReleaseTypes ? $c->{'albums.release_type'} : 'ALBUM');
$tags =~ /E/ && $request->addResultLoopIfValueDefined($loopname, $chunkCount, 'extid', $c->{'albums.extid'});
$tags =~ /X/ && $request->addResultLoopIfValueDefined($loopname, $chunkCount, 'album_replay_gain', $c->{'albums.replay_gain'});
$tags =~ /S/ && $request->addResultLoopIfValueDefined($loopname, $chunkCount, 'artist_id', $contributorID || $c->{'albums.contributor'});
Expand Down Expand Up @@ -4796,6 +4809,7 @@ my %tagMap = (
'q' => ['disccount', '', 'album', 'discc'], #->album.discc
'J' => ['artwork_track_id', 'COVERART', 'album', 'artwork'], #->album.artwork
'C' => ['compilation', 'COMPILATION', 'album', 'compilation'], #->album.compilation
'W' => ['release_type', 'RELEASETYPE', 'album', 'release_type'], #->album.release_type
'X' => ['album_replay_gain', 'ALBUMREPLAYGAIN', 'album', 'replay_gain'], #->album.replay_gain

'G' => ['genres', 'GENRE', 'genres', 'name'], #->genre_track->genres.name
Expand Down Expand Up @@ -4843,6 +4857,7 @@ my %colMap = (
I => 'tracks.samplesize',
u => 'tracks.url',
w => 'tracks.lyrics',
W => 'albums.release_type',
x => sub { $_[0]->{'tracks.remote'} ? 1 : 0 },
c => 'tracks.coverid',
H => 'tracks.channels',
Expand Down Expand Up @@ -4962,6 +4977,7 @@ sub _songData {
$remoteMeta->{y} = $remoteMeta->{year};
$remoteMeta->{T} = $remoteMeta->{samplerate};
$remoteMeta->{I} = $remoteMeta->{samplesize};
$remoteMeta->{W} => $remoteMeta->{releasetype}
}
}

Expand Down Expand Up @@ -5540,6 +5556,11 @@ sub _getTagDataForTracks {
$c->{'albums.compilation'} = 1;
};

$tags =~ /W/ && do {
$join_albums->();
$c->{'albums.release_type'} = 1;
};

$tags =~ /X/ && do {
$join_albums->();
$c->{'albums.replay_gain'} = 1;
Expand Down Expand Up @@ -5645,6 +5666,8 @@ sub _getTagDataForTracks {
my %results;
my @resultOrder;

my $ignoreReleaseTypes = $tags =~ /W/ && $prefs->get('ignoreReleaseTypes');

while ( $sth->fetch ) {
if (!$ids_only) {
utf8::decode( $c->{'tracks.title'} ) if exists $c->{'tracks.title'};
Expand All @@ -5658,6 +5681,12 @@ sub _getTagDataForTracks {
my $id = $c->{'tracks.id'};

$results{ $id } = { map { $_ => $c->{$_} } keys %{$c} };

# if user doesn't want to distinguish release types, just return ALBUMS for all of them
if ($ignoreReleaseTypes) {
$results{ $id }->{'albums.release_type'} = 'ALBUM';
}

push @resultOrder, $id;
}

Expand Down
3 changes: 2 additions & 1 deletion Slim/Formats/FLAC.pm
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ my %tagMapping = (
'MUSICBRAINZ_ALBUMARTISTID' => 'MUSICBRAINZ_ALBUMARTIST_ID',
'MUSICBRAINZ_ALBUMID' => 'MUSICBRAINZ_ALBUM_ID',
'MUSICBRAINZ_ALBUMSTATUS' => 'MUSICBRAINZ_ALBUM_STATUS',
'MUSICBRAINZ_ALBUMTYPE' => 'MUSICBRAINZ_ALBUM_TYPE',
'MUSICBRAINZ_ALBUMTYPE' => 'RELEASETYPE', # https://picard-docs.musicbrainz.org/en/appendices/tag_mapping.html#id32
'MUSICBRAINZ_ALBUM_TYPE' => 'RELEASETYPE',
'MUSICBRAINZ_ARTISTID' => 'MUSICBRAINZ_ARTIST_ID',
'MUSICBRAINZ_TRACKID' => 'MUSICBRAINZ_ID',
'MUSICBRAINZ_TRMID' => 'MUSICBRAINZ_TRM_ID',
Expand Down

0 comments on commit ba4e305

Please sign in to comment.