From 0a753baea5bcbbf16192684dc33bed58c02e6bd5 Mon Sep 17 00:00:00 2001 From: darrell-k Date: Tue, 10 Dec 2024 16:53:17 +0000 Subject: [PATCH] classical genre processing - adjustments --- Slim/Control/Queries.pm | 10 +++++----- Slim/Music/Info.pm | 9 ++++++--- Slim/Schema.pm | 4 ++-- Slim/Schema/Genre.pm | 9 ++++++--- 4 files changed, 19 insertions(+), 13 deletions(-) diff --git a/Slim/Control/Queries.pm b/Slim/Control/Queries.pm index 36adc21187c..54e6a39d4f8 100644 --- a/Slim/Control/Queries.pm +++ b/Slim/Control/Queries.pm @@ -5527,8 +5527,11 @@ sub _songDataFromHash { # Special case for G (genres name) - include isClassical as well elsif ( $tag eq 'G' ) { - $returnHash{'genres'} = $res->{'genres'} if $res->{'genres'}; - $returnHash{'isClassical'} = $res->{'isClassical'}; + if ( $res->{'genres'} ) { + $returnHash{'genres'} = $res->{'genres'}; + my $isClassical = Slim::Schema::Genre->isMyClassicalGenre($res->{'genres'}, ','); + $returnHash{'isClassical'} = $isClassical if $isClassical; + } } # eg. the web UI is requesting some tags which are only available for remote tracks, @@ -6436,14 +6439,12 @@ sub _getTagDataForTracks { $genre_sth->execute; my %values; - my $isMyClassical = 0; while ( my ($id, $name, $track) = $genre_sth->fetchrow_array ) { my $genre_info = $values{$track} ||= {}; utf8::decode($name); $genre_info->{ids} .= $genre_info->{ids} ? ',' . $id : $id; $genre_info->{names} .= $genre_info->{names} ? ', ' . $name : $name; - $isMyClassical ||= Slim::Schema::Genre->isMyClassicalGenre($name); } my $want_names = $tags =~ /G/; @@ -6453,7 +6454,6 @@ sub _getTagDataForTracks { my $track = $results{$id}; $track->{genre_ids} = $genre_info->{ids} if $want_ids; $track->{genres} = $genre_info->{names} if $want_names; - $track->{isClassical} = $isMyClassical if $want_names; } } diff --git a/Slim/Music/Info.pm b/Slim/Music/Info.pm index 33fa0c9cb16..0ad25b1e1f1 100644 --- a/Slim/Music/Info.pm +++ b/Slim/Music/Info.pm @@ -1004,6 +1004,7 @@ $prefs->setChange( sub splitTag { my $tag = shift; + my $customSeparator = shift; # Handle Vorbis comments where the tag can be an array. if (ref($tag) eq 'ARRAY') { @@ -1018,15 +1019,17 @@ sub splitTag { my @splitTags = (); - if (!$_gotSplitList) { + if (!$_gotSplitList && !$customSeparator) { $_splitList = $prefs->get('splitList'); $_gotSplitList = 1; } + my $separator = $customSeparator || $_splitList; + # only bother if there are some characters in the pref - if ($_splitList) { + if ($separator) { - for my $splitOn (split(/\s+/, $_splitList),'\x00') { + for my $splitOn (split(/\s+/, $separator),'\x00') { my @temp = (); diff --git a/Slim/Schema.pm b/Slim/Schema.pm index c5740a7ca08..4f539b5b3b7 100644 --- a/Slim/Schema.pm +++ b/Slim/Schema.pm @@ -1764,6 +1764,8 @@ sub _newTrack { if ( _workRequired($deferredAttributes->{'GENRE'}) ) { $workID = $self->_createWork($deferredAttributes->{'WORK'}, $deferredAttributes->{'WORKSORT'}, $contributors->{'COMPOSER'}->[0], 1); } + else { + } ### Find artwork column values for the Track if ( !$columnValueHash{cover} && $columnValueHash{audio} ) { @@ -3306,8 +3308,6 @@ sub canFulltextSearch { sub _workRequired { if ( (defined $scanWorks ? $scanWorks : $prefs->get('worksScan')) == SCAN_WORKS_FOR_MY_CLASSICAL_GENRES ) { my $genres = shift; - # input will be an array if multiple genre tags - $genres = join(';', @$genres) if ref $genres eq 'ARRAY'; return Slim::Schema::Genre->isMyClassicalGenre($genres); } else { return defined $scanWorks ? $scanWorks : $prefs->get('worksScan'); diff --git a/Slim/Schema/Genre.pm b/Slim/Schema/Genre.pm index e42e9db6e5e..f40cfca7abe 100644 --- a/Slim/Schema/Genre.pm +++ b/Slim/Schema/Genre.pm @@ -13,6 +13,8 @@ use Slim::Utils::Prefs; my $myClassicalGenreMap; my $myClassicalGenreIds; +my $tagSeparator; +my $tagSeparatorLoaded; { my $class = __PACKAGE__; @@ -41,7 +43,7 @@ my $myClassicalGenreIds; sub loadMyClassicalGenreMap { my $prefs = preferences('server'); - %$myClassicalGenreMap = map {$_ => 1} split(/,\s*/, uc($prefs->get('myClassicalGenres'))); + %$myClassicalGenreMap = map {$_ => 1} split(/\s*,\s*/, uc($prefs->get('myClassicalGenres'))); if ( !%$myClassicalGenreMap ) { $myClassicalGenreIds = undef; return; @@ -61,8 +63,9 @@ sub isMyClassicalGenre { loadMyClassicalGenreMap() if !$myClassicalGenreMap; my $class = shift; my $genres = shift; - foreach (Slim::Music::Info::splitTag(uc($genres))) { - return 1 if %$myClassicalGenreMap{$_} + my $sep = shift; + foreach ( Slim::Music::Info::splitTag($genres, $sep) ) { + return 1 if %$myClassicalGenreMap{uc($_)} } return 0; }