Skip to content

Commit 60c2cbc

Browse files
committed
Merge branch 'public/9.1' of https://github.com/SamInPgh/slimserver into public/9.1
2 parents 4107e60 + bb368b1 commit 60c2cbc

File tree

5 files changed

+98
-11
lines changed

5 files changed

+98
-11
lines changed

Changelog9.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ <h2><a name="v9.1.0" id="v9.1.0"></a>Version 9.1.0</h2>
88
<li>Optionally navigate playlists by folders, allowing you to organise your playlists hierarchically.</li>
99
<li>Implement an artist portrait picture handler. This will read images from folders where you've stored them under the artist's name, or from the artist folder in a typical artist/album/track hierarchy.</li>
1010
<li>Add a plugin to try to fetch artwork for radio stations which don't provide track artwork.</li>
11+
<li>Add new scan modes "album" and "track" to re-scan individual albums or tracks. Album scan is available from an album's Info menu.</li>
1112
<li><a href="https://github.com/LMS-Community/slimserver/pull/1425">#1425</a> - Add playlist drag and drop support to the Classic skin (thanks @oreillymj)</li>
1213
<li><a href="https://github.com/LMS-Community/slimserver/pull/1426">#1426</a> - add support for ListenBrainz to AudioScrobbler plugin (thanks @vysmaty & AI)</li>
1314
<li>Allow GETting the JSONRPC.js handler with a "request" parameter to simplify access by limited clients.</li>

Slim/Control/Commands.pm

Lines changed: 57 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use strict;
2828

2929
use Scalar::Util qw(blessed looks_like_number);
3030
use File::Spec::Functions qw(catfile);
31-
use File::Basename qw(basename);
31+
use File::Basename qw(basename dirname);
3232
use Digest::MD5 qw(md5_hex);
3333
use JSON::XS::VersionOneAndTwo;
3434

@@ -2684,10 +2684,18 @@ sub rescanCommand {
26842684
# get our parameters
26852685
my $originalMode;
26862686
my $mode = $originalMode = $request->getParam('_mode') || 'full';
2687-
my $singledir = $request->getParam('_singledir');
2687+
my $target = $request->getParam('_target');
2688+
my $singledir;
26882689

2689-
if ($singledir) {
2690-
$singledir = Slim::Utils::Misc::pathFromFileURL($singledir);
2690+
if ($mode =~ /album|track/) {
2691+
if (!$target) {
2692+
$log->error("Album or Tracks scan modes need an album or track ID.");
2693+
$request->setStatusBadDispatch();
2694+
return;
2695+
}
2696+
}
2697+
elsif ($target) {
2698+
$singledir = Slim::Utils::Misc::pathFromFileURL($target);
26912699

26922700
# don't run scan if newly added entry is disabled for all media types
26932701
if ( grep { /\Q$singledir\E/ } @{ Slim::Utils::Misc::getInactiveAudioDirs() }) {
@@ -2709,12 +2717,13 @@ sub rescanCommand {
27092717
}
27102718

27112719
# Bug 17358, if any plugin importers are enabled such as iTunes/MusicIP, run an old-style external rescan
2712-
# XXX Rewrite iTunes and MusicIP to support async rescan
2713-
my $importers = Slim::Music::Import->importers();
2714-
while ( my ($class, $config) = each %{$importers} ) {
2715-
if ( $class =~ /(?:Plugin|Slim::Music::VirtualLibraries)/ && $config->{use} ) {
2716-
$mode = 'external';
2717-
last;
2720+
if ($mode !~ /album|track/) {
2721+
my $importers = Slim::Music::Import->importers();
2722+
while ( my ($class, $config) = each %{$importers} ) {
2723+
if ( $class =~ /(?:Plugin|Slim::Music::VirtualLibraries)/ && $config->{use} ) {
2724+
$mode = 'external';
2725+
last;
2726+
}
27182727
}
27192728
}
27202729

@@ -2733,6 +2742,44 @@ sub rescanCommand {
27332742

27342743
Slim::Music::Import->launchScan(\%args);
27352744
}
2745+
elsif ($mode =~ /album|track/) {
2746+
# quick in-process scan of an individual object's (album or track) folder
2747+
my @tracks;
2748+
if ($mode eq 'track') {
2749+
my $track = Slim::Schema->rs('Track')->single( { id => $target } );
2750+
push @tracks, $track if $track;
2751+
}
2752+
elsif ($mode eq 'album') {
2753+
my $album = Slim::Schema->rs('Album')->single( { id => $target } );
2754+
push @tracks, $album->tracks if $album;
2755+
}
2756+
2757+
my $dbh = Slim::Schema->dbh;
2758+
my $sth = $dbh->prepare_cached('DELETE FROM scanned_files WHERE url = ?');
2759+
my @paths = Slim::Utils::Misc::uniq(
2760+
map {
2761+
# reset the track's timestamp so changes are certainly picked up
2762+
$_->timestamp(0);
2763+
$_->update;
2764+
2765+
# delete entry in scanned_files - otherwise rescan doesn't handle deletions for non-recursive scans
2766+
$sth->execute($_->url);
2767+
2768+
dirname(Slim::Utils::Misc::pathFromFileURL($_->url));
2769+
} @tracks
2770+
);
2771+
2772+
# need to delete the entry for the folder, too
2773+
foreach (@paths) {
2774+
$sth->execute(Slim::Utils::Misc::fileURLFromPath($_));
2775+
}
2776+
2777+
Slim::Utils::Scanner::Local->rescan(\@paths, {
2778+
no_async => 1,
2779+
types => 'audio',
2780+
recursive => 0,
2781+
} ) if scalar @paths;
2782+
}
27362783
else {
27372784
# In-process scan
27382785

Slim/Control/Request.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ sub init {
604604
addDispatch(['pref', '_prefname', '_newvalue'], [0, 0, 1, \&Slim::Control::Commands::prefCommand]);
605605
addDispatch(['remote', '?'], [1, 1, 0, \&Slim::Control::Queries::cursonginfoQuery]);
606606
addDispatch(['rescan', '?'], [0, 1, 0, \&Slim::Control::Queries::rescanQuery]);
607-
addDispatch(['rescan', '_mode', '_singledir'], [0, 0, 0, \&Slim::Control::Commands::rescanCommand]);
607+
addDispatch(['rescan', '_mode', '_target'], [0, 0, 0, \&Slim::Control::Commands::rescanCommand]);
608608
addDispatch(['rescanprogress'], [0, 1, 1, \&Slim::Control::Queries::rescanprogressQuery]);
609609
addDispatch(['restartserver'], [0, 0, 0, \&Slim::Control::Commands::stopServer]);
610610
addDispatch(['search', '_index', '_quantity'], [0, 1, 1, \&Slim::Control::Queries::searchQuery]);

Slim/Menu/AlbumInfo.pm

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,11 @@ sub registerDefaultInfoProviders {
124124
after => 'compilation',
125125
func => \&infoExternalId,
126126
) );
127+
128+
$class->registerInfoProvider( rescan => (
129+
after => 'bottom',
130+
func => \&rescanAlbum,
131+
) );
127132
}
128133

129134
sub menu {
@@ -568,6 +573,33 @@ sub addAlbum {
568573
};
569574
}
570575

576+
sub rescanAlbum {
577+
my ( $client, $url, $album ) = @_;
578+
579+
return unless blessed($album) && !$album->extid;
580+
581+
return {
582+
name => cstring($client, 'RESCAN_ALBUM'),
583+
type => 'link',
584+
passthrough => [ $album->id ],
585+
url => sub {
586+
my ( $client, $callback, undef, $albumId ) = @_;
587+
588+
return unless $albumId;
589+
590+
Slim::Control::Request::executeRequest(undef, [ 'rescan', 'album', $albumId ]);
591+
592+
$callback->( {
593+
type => 'text',
594+
nextWindow => 'parent',
595+
name => $client->string('RESCAN_ALBUM'),
596+
showBriefly => 1,
597+
} );
598+
},
599+
favourites => 0,
600+
};
601+
}
602+
571603
sub infoReplayGain {
572604
my ( $client, $url, $album ) = @_;
573605

strings.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6895,6 +6895,13 @@ SETUP_PLAYLISTRESCAN
68956895
SV Sök bara igenom spellistorna på nytt
68966896
ZH_CN 重新扫描播放表而已。
68976897

6898+
RESCAN_ALBUM
6899+
CS Znovu naskenovat album
6900+
DE Album neu einlesen
6901+
EN Rescan Album
6902+
FR Réanalyser l'album
6903+
NL Album opnieuw scannen
6904+
68986905
SETUP_AUTO_RESCAN
68996906
CS Automaticky detekovat změny
69006907
DA Registrer automatisk ændringer

0 commit comments

Comments
 (0)