Index: Slim/Music/Import.pm
===================================================================
--- Slim/Music/Import.pm (revision 21163)
+++ Slim/Music/Import.pm (working copy)
@@ -102,18 +102,6 @@
$args->{"logdir=$::logdir"} = 1;
}
- # Add in the various importer flags
- # TODO: rework to only access prefs IF Importer is active
- for my $importer (qw(iTunes MusicIP)) {
- my $prefs = preferences("plugin.".lc($importer));
-
- # TODO: one day we'll have to fully rename MusicMagic to MusicIP...
- if (Slim::Utils::PluginManager->isEnabled("Slim::Plugin::" . ($importer eq 'MusicIP' ? 'MusicMagic' : $importer) . "::Plugin") && $prefs->get(lc($importer))) {
-
- $args->{lc($importer)} = 1;
- }
- }
-
# Set scanner priority. Use the current server priority unless
# scannerPriority has been specified.
@@ -326,7 +314,7 @@
}
# Check Import scanners
- for my $importer (keys %Importers) {
+ for my $importer (_getSorteredImporters()) {
# Don't rescan the music folder again.
if ($importer eq $folderScanClass) {
@@ -342,6 +330,11 @@
next;
}
+ # Skip post scanning importers
+ if ($Importers{$importer}->{'postScan'}) {
+ next;
+ }
+
$class->runImporter($importer);
}
@@ -350,6 +343,23 @@
return 1;
}
+sub _getSorteredImporters {
+ my @keys = @_ || keys %Importers;
+
+ return sort {
+ if(exists $Importers{$a}->{'weight'} && exists $Importers{$b}->{'weight'}) {
+ return $Importers{$a}->{'weight'} <=> $Importers{$b}->{'weight'};
+ }elsif(exists $Importers{$a}->{'weight'}) {
+ return $Importers{$a}->{'weight'} <=> 50;
+ }elsif(exists $Importers{$b}->{'weight'}) {
+ return 50 <=> $Importers{$b}->{'weight'};
+ }else {
+ return 0;
+ }
+ } @keys;
+}
+
+
=head2 runScanPostProcessing( )
This is called by the scanner.pl helper program.
@@ -377,6 +387,21 @@
Slim::Music::Artwork->findArtwork;
+ # Check post scan Importers
+ for my $importer (_getSorteredImporters()) {
+
+ # Only run importers that implement post scanning functions.
+ if (!$Importers{$importer}->{'postScan'}) {
+
+ $log->debug("Skipping [$importer] - it doesn't implement post scanning!");
+
+ next;
+ }
+
+ $class->runImporter($importer);
+ }
+
+
# Remove and dangling references.
if ($class->cleanupDatabase) {
Index: Slim/Plugin/MusicMagic/install.xml
===================================================================
--- Slim/Plugin/MusicMagic/install.xml (revision 21163)
+++ Slim/Plugin/MusicMagic/install.xml (working copy)
@@ -4,6 +4,7 @@
2A25E5C4-036E-493F-890C-2BFC07944110
MUSICMAGIC
Slim::Plugin::MusicMagic::Plugin
+ Slim::Plugin::MusicMagic::Importer
1.0
MUSICMAGIC_DESC
Slim Devices/Logitech
Index: Slim/Plugin/iTunes/install.xml
===================================================================
--- Slim/Plugin/iTunes/install.xml (revision 21163)
+++ Slim/Plugin/iTunes/install.xml (working copy)
@@ -4,6 +4,7 @@
2A25E5C4-036E-493F-890C-2BFC07944110
ITUNES
Slim::Plugin::iTunes::Plugin
+ Slim::Plugin::iTunes::Importer
1.0
ITUNES_DESC
Slim Devices/Logitech
Index: Slim/Utils/PluginManager.pm
===================================================================
--- Slim/Utils/PluginManager.pm (revision 21163)
+++ Slim/Utils/PluginManager.pm (working copy)
@@ -65,7 +65,10 @@
sub init {
my $class = shift;
-
+ my $moduleType = shift || '';
+ my $useCache = shift;
+ $useCache = 1 if !defined($useCache);
+
# Bug 6196, Delay PAR loading to init phase so any temp directories
# are created as the proper user
require PAR;
@@ -79,7 +82,7 @@
$cacheInvalid = 'plugins states are not defined';
- } elsif ( -r $class->pluginCacheFile ) {
+ } elsif ( -r $class->pluginCacheFile && $useCache) {
$class->loadPluginCache;
@@ -109,7 +112,7 @@
$log->warn("Reparsing plugin manifests - $cacheInvalid");
- $class->readInstallManifests($manifestFiles);
+ $class->readInstallManifests($manifestFiles, $moduleType);
} else {
@@ -118,7 +121,7 @@
$class->runPendingOperations;
}
- $class->enablePlugins;
+ $class->enablePlugins($moduleType);
$cacheInfo = {
'version' => CACHE_VERSION,
@@ -127,7 +130,9 @@
'mtimesum'=> $sum,
};
- $class->writePluginCache;
+ if($useCache) {
+ $class->writePluginCache;
+ }
}
sub pluginCacheFile {
@@ -200,12 +205,13 @@
sub readInstallManifests {
my $class = shift;
my $files = shift;
+ my $moduleType = shift;
$plugins = {};
for my $file (@{$files}) {
- my ($pluginName, $installManifest) = $class->_parseInstallManifest($file);
+ my ($pluginName, $installManifest) = $class->_parseInstallManifest($file,$moduleType);
if (!defined $pluginName) {
@@ -223,6 +229,7 @@
sub _parseInstallManifest {
my $class = shift;
my $file = shift;
+ my $moduleType = shift;
my $installManifest = eval { XMLin($file) };
@@ -233,7 +240,7 @@
return undef;
}
- my $pluginName = $installManifest->{'module'};
+ my $pluginName = $installManifest->{$moduleType.'module'};
$installManifest->{'basedir'} = dirname($file);
@@ -243,6 +250,9 @@
return ($file, $installManifest);
}
+ elsif (!defined $pluginName) {
+ return (undef,$installManifest);
+ }
if (!$class->checkPluginVersion($installManifest)) {
@@ -347,7 +357,7 @@
my $max = $manifest->{'targetApplication'}->{'maxVersion'};
# Didn't match the version? Next..
- if (!Slim::Utils::Versions->checkVersion($::VERSION, $min, $max)) {
+ if ($::VERSION && !Slim::Utils::Versions->checkVersion($::VERSION, $min, $max)) {
return 0;
}
@@ -357,6 +367,7 @@
sub enablePlugins {
my $class = shift;
+ my $moduleType = shift || '';
my @incDirs = ();
my @loaded = ();
@@ -366,7 +377,7 @@
my $manifest = $plugins->{$name};
# Skip plugins with no perl module.
- next unless $manifest->{'module'};
+ next unless $manifest->{$moduleType.'module'};
# Skip plugins that can't be loaded.
if ($manifest->{'error'} ne 'INSTALLERROR_SUCCESS') {
@@ -394,7 +405,7 @@
$log->info("Enabling plugin: [$name]");
my $baseDir = $manifest->{'basedir'};
- my $module = $manifest->{'module'};
+ my $module = $manifest->{$moduleType.'module'};
my $loadModule = 0;
# Look for a lib dir that has a PAR file or otherwise.
@@ -450,10 +461,10 @@
}
}
- # Add any available HTML to TT's INCLUDE_PATH
+ # Add any available HTML to TT's INCLUDE_PATH if Slim::Web::HTTP is loaded
my $htmlDir = catdir($baseDir, 'HTML');
- if (-d $htmlDir) {
+ if (-d $htmlDir && Slim::Web::HTTP->can('addTemplateDirectory')) {
$log->debug("Adding HTML directory: [$htmlDir]");
Index: scanner.pl
===================================================================
--- scanner.pl (revision 21163)
+++ scanner.pl (working copy)
@@ -53,9 +53,10 @@
use Slim::Utils::Strings qw(string);
use Slim::Control::Request;
+
sub main {
- our ($rescan, $playlists, $wipe, $itunes, $musicip, $force, $cleanup, $prefsFile, $progress, $priority);
+ our ($rescan, $playlists, $wipe, $force, $cleanup, $prefsFile, $progress, $priority);
our ($quiet, $logfile, $logdir, $logconf, $debug, $help);
our $LogTimestamp = 1;
@@ -71,9 +72,6 @@
'rescan' => \$rescan,
'wipe' => \$wipe,
'playlists' => \$playlists,
- 'itunes' => \$itunes,
- 'musicip' => \$musicip,
- 'musicmagic' => \$musicmagic,
'prefsfile=s' => \$prefsFile,
# prefsdir parsed by Slim::Utils::Prefs
'progress' => \$progress,
@@ -87,10 +85,6 @@
'help' => \$help,
);
- if (defined $musicmagic && !defined $musicip) {
- $musicip = $musicmagic;
- }
-
Slim::Utils::Log->init({
'logconf' => $logconf,
'logdir' => $logdir,
@@ -99,7 +93,7 @@
'debug' => $debug,
});
- if ($help || (!$rescan && !$wipe && !$playlists && !$musicip && !$itunes && !scalar @ARGV)) {
+ if ($help || (!$rescan && !$wipe && !$playlists && !scalar @ARGV)) {
usage();
exit;
}
@@ -142,15 +136,8 @@
Slim::Music::MusicFolderScan->init;
}
- # Various importers - should these be hardcoded?
- if ($itunes) {
- initClass('Slim::Plugin::iTunes::Importer');
- }
+ Slim::Utils::PluginManager->init('import',0);
- if ($musicip) {
- initClass('Slim::Plugin::MusicMagic::Importer');
- }
-
#checkDataSource();
$log->info("SqueezeCenter done init...\n");
@@ -207,7 +194,6 @@
if ($wipe) {
Slim::Music::Import->resetImporters;
}
-
Slim::Music::Import->runScan;
};
}
@@ -288,7 +274,7 @@
sub usage {
print <
+Usage: $0 [debug options] [--rescan] [--wipe]
Command line options:
@@ -297,8 +283,6 @@
--rescan Look for new files since the last scan.
--wipe Wipe the DB and start from scratch
--playlists Only scan files in your playlistdir.
- --itunes Run the iTunes Importer.
- --musicip Run the MusicIP Importer.
--progress Show a progress bar of the scan.
--prefsdir Specify alternative preferences directory.
--priority set process priority from -20 (high) to 20 (low)
@@ -318,18 +302,6 @@
}
-sub initClass {
- my $class = shift;
-
- Slim::bootstrap::tryModuleLoad($class);
-
- if ($@) {
- logError("Couldn't load $class: $@");
- } else {
- $class->initPlugin;
- }
-}
-
sub cleanup {
# Make sure to flush anything in the database to disk.