Author: mherger
Date: Wed Nov 2 04:14:57 2011
New Revision: 33643
URL: http://svn.slimdevices.com/slim?rev=33643&view=rev
Log:
Bug: 17696
Description: add a custom command to control a MOG radio's diversity
Modified:
7.7/trunk/server/Slim/Plugin/MOG/Plugin.pm
7.7/trunk/server/Slim/Plugin/MOG/ProtocolHandler.pm
Modified: 7.7/trunk/server/Slim/Plugin/MOG/Plugin.pm
URL: http://svn.slimdevices.com/slim/7.7/trunk/server/Slim/Plugin/MOG/Plugin.pm?rev=33643&r1=33642&r2=33643&view=diff
==============================================================================
--- 7.7/trunk/server/Slim/Plugin/MOG/Plugin.pm (original)
+++ 7.7/trunk/server/Slim/Plugin/MOG/Plugin.pm Wed Nov 2 04:14:57 2011
@@ -19,7 +19,6 @@
sub initPlugin {
my $class = shift;
-
Slim::Player::ProtocolHandlers->registerHandler(
mog => 'Slim::Plugin::MOG::ProtocolHandler'
);
@@ -28,6 +27,10 @@
qr|squeezenetwork\.com.*/api/mog/|,
sub { $class->_pluginDataFor('icon') }
);
+
+ # add custom commands to control radio's diversity
+ Slim::Control::Request::addDispatch(['mog', 'radiodiversity', '_diversity'],
+ [0, 1, 1, \&Slim::Plugin::MOG::ProtocolHandler::setRadioDiversity]);
if ( main::WEBUI ) {
# Add a function to view trackinfo in the web
Modified: 7.7/trunk/server/Slim/Plugin/MOG/ProtocolHandler.pm
URL: http://svn.slimdevices.com/slim/7.7/trunk/server/Slim/Plugin/MOG/ProtocolHandler.pm?rev=33643&r1=33642&r2=33643&view=diff
==============================================================================
--- 7.7/trunk/server/Slim/Plugin/MOG/ProtocolHandler.pm (original)
+++ 7.7/trunk/server/Slim/Plugin/MOG/ProtocolHandler.pm Wed Nov 2 04:14:57 2011
@@ -527,7 +527,7 @@
my ($trackId, $radioId) = getIds($url);
if ( $radioId ) {
- main::DEBUGLOG && $log->debug( "Need to queue up new MOG Radio tracks..." );
+ main::DEBUGLOG && $log->debug( "Need to queue up new MOG Radio tracks... $radioId" );
my $pos = Slim::Player::Source::playingSongIndex($client);
@@ -542,6 +542,40 @@
_getRadioTracks($client, $radioId, MAX_RADIO_QUEUE - $length);
}
}
+}
+
+# set diversity of the currently playing radio station
+sub setRadioDiversity {
+ my $request = shift;
+ my $client = $request->client();
+
+ $log->error($client);
+ return unless defined $client;
+
+ # ignore if user is not using Pandora
+ my $song = $client->playingSong() || return;
+ my $url = $song->currentTrack()->url;
+
+ my ($trackId, $radioId) = getIds($url);
+ my $diversity = $request->getParam('_diversity') || 0;
+
+ $radioId =~ s/([at].+v)(\d+)/$1$diversity/;
+
+ # only continue if we're actually playing a radio station
+ return unless $trackId && $radioId;
+
+ # remove queued tracks
+ my $pos = Slim::Player::Source::playingSongIndex($client);
+ my $length = Slim::Player::Playlist::count($client);
+
+ $pos++;
+ while ($length-- > $pos) {
+ $client->execute([ 'playlist', 'delete', $pos ]);
+ }
+
+ _getRadioTracks($client, $radioId, 10);
+
+ $request->setStatusDone();
}
sub trackInfoURL {
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.