Bugzilla – Bug 6126
Add scheduled MusicIP rescan/validate to Slimserver
Last modified: 2009-07-31 10:15:16 UTC
Slimserver already schedules a rescan of the music library to check for new music. I would like to enhance the MIP (formerly MMM) plugin to add some new settings. The feature would mimic the rescan.pl plug-in by having slimserver request that MIP first trigger the add new music function, using the slimserver music library location. Once adding new tracks is complete, the slimserver should trigger the validate tracks function. I think the MMM module would need to have the following new items added to the plugin setup menu: Rescan MMM Library Periodically: True/False Time to Rescan: time Time to wait after adding music to begin validation: # of minutes (unless MIP can signal or be polled to say if it is done adding?) I realize this could be functionality that the MMM could do itself or could be scheduled through CHRON or other OS scheduling utilities. However slimserver already has the scheduling functionality implemented and it could be helpful for users who aren't as familiar with scheduling things on their own.
This already exists. MusicIP has a setting for rescan interval. This checks for changes in the MIP library and triggers a rescan of MIP of there are changes.
I'm fairly certain that feature only exists in the GUI version of MIP, not the headless so it doesn't help me. I've begun asking at the MusicIP forum to be absolutely sure. I've put in a feature request for MusicIP to add this to Headless, but still think this could be done well in this plug-in. New features in headless MusicIP are often slow in coming and since it's not opensource, I can't do much more than ask nicely. I'm trying to give a stab at implementing this myself and submitting a patch, but progress is slow. I've never written in Perl or made a plug-in before. I think an adaptation of the Rescan.pl plug-in could get the job done.
We can't add features MIP isn't supporting. If it's available in their web UI, then you can use it from there. If it's not, we can't do this neither. That's rather an enhancement request for MIP.
From this link: http://forums.slimdevices.com/showthread.php?t=26854 (look down to item #7), you can see that although a single feature is not available in MIP, all the necessary steps are supported. What is needed is a scheduler. I can (and have) set this up on my box via the CRON scheduler and that works quite adequately. The issues I see is that using CRON is going to be very system dependent. Larger libraries or slower processors will require different time spacings for calling the 3 commands (add music, refresh library, validate library). On the other hand, if you do these 3 steps directly in the web UI, you can see that the page displays "Validating Tracks..." or "Adding Tracks...", so status information is available. It would be clever to have a SlimServer plugin trigger the first API call, then poll the MIP server every X minutes until it returns a "free" status, then trigger the next call, etc. I don't think this can be done via CRON. Yes, I'd rather this be done directly by MIP, but it's not open source so there isn't much I can do about that. I've asked for the feature from the developers and will continue asking for this and other features I'd like to see in Headless. In the meantime, this is one feature that could be done within SlimServer and I don't have to wait for the capable folks at MIP. I just have to learn how to implement it myself. Hopefully someone will benefit from it. Unfortunately I'm very new to perl and programming in SlimServer, so my learning curve has been painfully slow. Eventually I'll get it to work and I'll post a patch. If someone else can (and wants to) do it faster, I'd be thrilled. Someone who knows the MusicMagic and Rescan.pm plugins could probably hack this out in a fraction of the time it is taking me.
One way to get the status: $http = Slim::Player::Protocols::HTTP->new({ 'url' => "http://$MMSHost:$MMSport/api/getStatus", 'create' => 0, 'timeout' => 5, }) || return 0; if ( $log->is_info ) { $log->info("Got status: ", $http->content); } $http->content will be one of "analysing" "idle" or "adding". Not sure what you might get for refreshing. I expect that it will be "idle". So, won't work so nicely for cleaning out orphaned tracks, but should be ok for adding new ones. All the code you need should be in Slim/Plugin/MusicMagic/*.pm. Steal from that and edit Slim/Plugin/Rescan/Plugin.pm for the auto scan framework.
Will look at this post-7.0.
Reduce number of active targets for SC