Skip to content

Commit

Permalink
Merge pull request #1132 from darrell-k/variable-contributors
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelherger authored Aug 4, 2024
2 parents 0e700a6 + e35c8a5 commit abfd094
Show file tree
Hide file tree
Showing 7 changed files with 121 additions and 15 deletions.
1 change: 1 addition & 0 deletions Changelog9.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ <h2><a name="v9.0.0" id="v9.0.0"></a>Introducing... Lyrion Music Server Version
<li><a href="https://github.com/LMS-Community/slimserver/pull/930">Massive upgrade for Classical music lovers</a>: add support for Works, Performances, Disc Subtitles. Thanks a ton @darrel-k!</li>
<li><a href="https://github.com/LMS-Community/slimserver/issues/1095">#1095</a> - Link from online tracks and albums to local library (if possible).</li>
<li><a href="https://github.com/LMS-Community/slimserver/pull/1115">#1115</a> - Add option to show tracks from a given year, even if their album would be listed in a different year.</li>
<li><a href="https://github.com/LMS-Community/slimserver/pull/1132">#1115</a> - Allow user defined contributor roles.</li>
</ul>
<br />

Expand Down
3 changes: 2 additions & 1 deletion Slim/Menu/BrowseLibrary/Releases.pm
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ sub _releases {
# library_id:-1 is supposed to clear/override the global library_id
$_ && $_ !~ /(?:library_id\s*:\s*-1|remote_library)/
} @searchTags;
push @searchTags, "role_id:$menuRoles" if $menuRoles;

my @artistIds = grep /artist_id:/, @searchTags;
my $artistId;
Expand All @@ -51,7 +52,7 @@ sub _releases {
main::INFOLOG && $log->is_info && $log->info("$query ($index, $quantity): tags ->", join(', ', @searchTags));

# get the artist's albums list to create releases sub-items etc.
my $request = Slim::Control::Request->new( undef, [ $query, 0, MAX_ALBUMS, @searchTags ] );
my $request = Slim::Control::Request->new( undef, [ $query, 0, MAX_ALBUMS, @searchTags, 'role_id:'. $menuRoles ? $menuRoles : join(',',Slim::Schema::Contributor->contributorRoles) ] );
$request->execute();

$log->error($request->getStatusText()) if $request->isStatusError();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,25 @@
</table>
[% END %]

[% WRAPPER setting title="PLUGIN_EXTENDED_BROWSEMODES_TAGS" desc="PLUGIN_EXTENDED_BROWSEMODES_TAGS_DESC" %]
<table>
<tr>
<th>[% "PLUGIN_EXTENDED_BROWSEMODES_ROLE" | string %]</th>
<th>[% "PLUGIN_EXTENDED_BROWSEMODES_ROLE_TEXT" | string %]</th>
</tr>
[% FOREACH tag = customTags.keys.sort %]
<tr>
<td><input type="text" name="[% tag | html %]_tag" value="[% tag | html %]" class="stdedit"/></td>
<td><input type="text" name="[% tag | html %]_name" value="[% customTags.$tag.name | html %]" class="stdedit" style="width: 200px;"/></td>
</tr>
[% END %]
<tr>
<td><input type="text" name="new_tag" value="" class="stdedit"/></td>
<td><input type="text" name="new_name" value="" class="stdedit" style="width: 200px;"/></td>
</tr>
</table>
[% END %]

[% IF needsClient %]
<input type="hidden" name="pref_enableLosslessPreferred" value="[% prefs.pref_enableLosslessPreferred || 0 %]" />
<input type="hidden" name="pref_enableAudioBooks" value="[% prefs.pref_enableAudioBooks || 0 %]" />
Expand Down
38 changes: 38 additions & 0 deletions Slim/Plugin/ExtendedBrowseModes/Settings.pm
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,41 @@ sub handler {
my $serverPrefs = $class->getServerPrefs($client);

if ($params->{'saveSettings'}) {

my $serverPrefs = preferences('server');
my $currentRoles = $serverPrefs->get('userDefinedRoles');
my $customTags = {};
my $id = 21;
my $changed = 0;
foreach my $pref (keys %{$params}) {
if ($pref =~ /(.*)_tag$/) {
my $key = $1;
my $tag = uc($params->{$pref});

if ( $tag ) {
$customTags->{$tag} = {
name => $params->{$key . '_name'} || $tag,
id => $id,
};
if ( !$currentRoles->{$tag} || $currentRoles->{$tag}->{name} ne $customTags->{$tag}->{name} ) {
Slim::Utils::Strings::storeExtraStrings([{
strings => { EN => $customTags->{$tag}->{name}},
token => $tag,
}]) if !Slim::Utils::Strings::stringExists($tag);
$changed = 1;
}
$id++;
}
}
}
foreach my $old (keys %{$currentRoles}) {
$changed = 1 if !$customTags->{$old};
}

if ( $changed ) {
$serverPrefs->set('userDefinedRoles', $customTags);
}

my $menus = $prefs->get('additionalMenuItems');

for (my $i = 1; defined $params->{"id$i"}; $i++) {
Expand Down Expand Up @@ -192,6 +227,9 @@ sub getServerPrefs {}
sub beforeRender {
my ($class, $params, $client) = @_;

my $serverPrefs = preferences('server');
$params->{customTags} = $serverPrefs->get('userDefinedRoles');

$params->{libraries} = {};

if ($params->{'needsAudioBookUpdate'}) {
Expand Down
29 changes: 29 additions & 0 deletions Slim/Plugin/ExtendedBrowseModes/strings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -279,3 +279,32 @@ PLUGIN_EXTENDED_BROWSEMODES_AUTHORS
FR Auteurs
NL Schrijvers
SV Författare

PLUGIN_EXTENDED_BROWSEMODES_TAGS
EN User Defined Roles
DE Benutzerdefinierte Rollen
FR Rôles définis par l'utilisateur
ES Roles definidos por el usuario
NL Door de gebruiker gedefinieerde rollen

PLUGIN_EXTENDED_BROWSEMODES_TAGS_DESC
EN Tell LMS about any custom contributor role tags used in the music library. For example, SOLOIST, DRUMMER, PRODUCER, etc. These can then be used as Contributor Roles in the Additional Browse Modes above. They will also appear as categories when browsing albums or artists with Release Type grouping enabled. Changes here will trigger a rescan of the music library.
DE Informieren Sie LMS über alle benutzerdefinierten Rollen-Tags, die in der Musikbibliothek verwendet werden. Zum Beispiel SOLOIST, DRUMMER, PRODUCER, usw. Diese können dann als Mitwirkende Rollen in den zusätzlichen Suchmodi oben verwendet werden. Sie werden auch als Kategorien angezeigt, wenn Sie Alben oder Künstler mit aktivierter Gruppierung nach Veröffentlichungstyp durchsuchen. Änderungen hier lösen einen erneuten Scan der Musikbibliothek aus.
FR Indiquez à LMS toute étiquette de rôle de contributeur personnalisée utilisée dans la bibliothèque musicale. Par exemple, SOLOIST, DRUMMER, PRODUCER, etc. Ceux-ci peuvent ensuite être utilisés comme rôles de contributeur dans les modes de navigation supplémentaires ci-dessus. Ils apparaîtront également en tant que catégories lorsque vous parcourez des albums ou des artistes en activant le regroupement par type de publication. Les modifications apportées à ces catégories déclencheront une nouvelle analyse de la bibliothèque musicale.
ES Informe a LMS sobre cualquier etiqueta de rol de colaborador personalizada utilizada en la biblioteca musical. Por ejemplo, SOLISTA, BATERISTA, PRODUCTOR, etc. Estas etiquetas se pueden utilizar como roles de colaborador en los modos de exploración adicionales anteriores. También aparecerán como categorías al explorar álbumes o artistas con la agrupación Tipo de publicación activada. Los cambios que se realicen aquí provocarán una nueva exploración de la biblioteca musical.
NL Vertel LMS over alle aangepaste rollabels voor medewerkers die worden gebruikt in de muziekbibliotheek. Bijvoorbeeld SOLOIST, DRUMMER, PRODUCER, enz. Deze kunnen dan worden gebruikt als rollen voor medewerkers in de extra bladermodi hierboven. Ze verschijnen ook als categorieën wanneer u door albums of artiesten bladert met de Release Type groepering ingeschakeld. Als u hier wijzigingen aanbrengt, wordt de muziekbibliotheek opnieuw gescand.

PLUGIN_EXTENDED_BROWSEMODES_ROLE
EN Role tag
DE Rolle tag
FR Rôle tag
ES Role tag
NL Rol tag

PLUGIN_EXTENDED_BROWSEMODES_ROLE_TEXT
EN Display Text
DE Text anzeigen
FR Afficher le texte
ES Mostrar texto
NL Tekst weergeven

42 changes: 29 additions & 13 deletions Slim/Schema/Contributor.pm
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,15 @@ use Slim::Schema::ResultSet::Contributor;

use Slim::Utils::Log;
use Slim::Utils::Misc;
use Slim::Utils::Prefs;

my %contributorToRoleMap = (
'ARTIST' => 1,
'COMPOSER' => 2,
'CONDUCTOR' => 3,
'BAND' => 4,
'ALBUMARTIST' => 5,
'TRACKARTIST' => 6,
);
my %contributorToRoleMap;
my @contributorRoles;
my @contributorRoleIds;
my $totalContributorRoles;
my %roleToContributorMap;

my @contributorRoles = sort keys %contributorToRoleMap;
my @contributorRoleIds = values %contributorToRoleMap;
my $totalContributorRoles = scalar @contributorRoles;

my %roleToContributorMap = reverse %contributorToRoleMap;
initializeRoles();

{
my $class = __PACKAGE__;
Expand Down Expand Up @@ -63,6 +57,28 @@ my %roleToContributorMap = reverse %contributorToRoleMap;
$class->resultset_class('Slim::Schema::ResultSet::Contributor');
}

sub initializeRoles {
%contributorToRoleMap = (
'ARTIST' => 1,
'COMPOSER' => 2,
'CONDUCTOR' => 3,
'BAND' => 4,
'ALBUMARTIST' => 5,
'TRACKARTIST' => 6,
);
my $prefs = preferences('server');
if ( my $userDefinedRoles = $prefs->get('userDefinedRoles') ) {
while ( my($k, $v) = each (%$userDefinedRoles) ) {
$contributorToRoleMap{$k} = $v->{id};
}
}

@contributorRoles = sort keys %contributorToRoleMap;
@contributorRoleIds = values %contributorToRoleMap;
$totalContributorRoles = scalar @contributorRoles;
%roleToContributorMap = reverse %contributorToRoleMap;
}

sub contributorRoles {
return @contributorRoles;
}
Expand Down
4 changes: 3 additions & 1 deletion Slim/Utils/Prefs.pm
Original file line number Diff line number Diff line change
Expand Up @@ -394,9 +394,11 @@ sub init {

$prefs->setChange(
sub { Slim::Control::Request::executeRequest(undef, ['wipecache', $prefs->get('dontTriggerScanOnPrefChange') ? 'queue' : undef]) },
qw(splitList groupdiscs useTPE2AsAlbumArtist)
qw(splitList groupdiscs useTPE2AsAlbumArtist userDefinedRoles)
);

$prefs->setChange( sub { Slim::Schema::Contributor->initializeRoles() }, 'userDefinedRoles');

$prefs->setChange( sub { Slim::Utils::Misc::setPriority($_[1]) }, 'serverPriority');

$prefs->setChange( sub {
Expand Down

0 comments on commit abfd094

Please sign in to comment.