[Slim-Checkins] r12742 - in /trunk/server/Slim/Plugin: LMA/Plugin.pm Live365/Plugin.pm MP3tunes/Plugin.pm OPMLBased.pm Pandora/Plugin.pm Picks/Plugin.pm RhapsodyDirect/Plugin.pm RhapsodyDirect/strings.txt
andy at svn.slimdevices.com
andy at svn.slimdevices.com
Mon Aug 27 13:51:24 PDT 2007
Author: andy
Date: Mon Aug 27 13:51:24 2007
New Revision: 12742
URL: http://svn.slimdevices.com?rev=12742&view=rev
Log:
Make a new base class for OPML-based plugins, cuts down on a lot of duplicate code
Added:
trunk/server/Slim/Plugin/OPMLBased.pm
Modified:
trunk/server/Slim/Plugin/LMA/Plugin.pm
trunk/server/Slim/Plugin/Live365/Plugin.pm
trunk/server/Slim/Plugin/MP3tunes/Plugin.pm
trunk/server/Slim/Plugin/Pandora/Plugin.pm
trunk/server/Slim/Plugin/Picks/Plugin.pm
trunk/server/Slim/Plugin/RhapsodyDirect/Plugin.pm
trunk/server/Slim/Plugin/RhapsodyDirect/strings.txt
Modified: trunk/server/Slim/Plugin/LMA/Plugin.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Plugin/LMA/Plugin.pm?rev=12742&r1=12741&r2=12742&view=diff
==============================================================================
--- trunk/server/Slim/Plugin/LMA/Plugin.pm (original)
+++ trunk/server/Slim/Plugin/LMA/Plugin.pm Mon Aug 27 13:51:24 2007
@@ -5,109 +5,20 @@
# Load Live Music Archive data via an OPML file - so we can ride on top of the Podcast Browser
use strict;
-use base qw(Slim::Plugin::Base);
-
-use Slim::Buttons::Common;
-use Slim::Buttons::XMLBrowser;
-use Slim::Web::XMLBrowser;
-
-my $FEED = 'http://content.us.squeezenetwork.com:8080/lma/artists.opml';
-my $cli_next;
+use base qw(Slim::Plugin::OPMLBased);
sub initPlugin {
my $class = shift;
-
- Slim::Control::Request::addDispatch(['lma', 'items', '_index', '_quantity'], [0, 1, 1, \&cliQuery]);
- Slim::Control::Request::addDispatch(['lma', 'playlist', '_method' ], [1, 1, 1, \&cliQuery]);
-
- $cli_next = Slim::Control::Request::addDispatch(['radios', '_index', '_quantity' ], [0, 1, 1, \&cliRadiosQuery]);
-
- $class->SUPER::initPlugin();
+
+ $class->SUPER::initPlugin(
+ feed => 'http://content.us.squeezenetwork.com:8080/lma/artists.opml',
+ tag => 'lma',
+ menu => 'radio',
+ );
}
sub getDisplayName {
return 'PLUGIN_LMA_MODULE_NAME';
}
-sub setMode {
- my $class = shift;
- my $client = shift;
- my $method = shift;
-
- if ($method eq 'pop') {
-
- Slim::Buttons::Common::popMode($client);
- return;
- }
-
- # use INPUT.Choice to display the list of feeds
- my %params = (
- header => 'PLUGIN_LMA_LOADING',
- modeName => 'LMA Plugin',
- url => $FEED,
- title => $client->string(getDisplayName()),
- );
-
- Slim::Buttons::Common::pushMode($client, 'xmlbrowser', \%params);
-
- # we'll handle the push in a callback
- $client->modeParam('handledTransition', 1);
-}
-
-sub webPages {
- my $class = shift;
-
- my $title = getDisplayName();
- my $url = 'plugins/LMA/index.html';
-
- Slim::Web::Pages->addPageLinks('radio', { $title => $url });
-
- Slim::Web::HTTP::addPageFunction($url, sub {
-
- Slim::Web::XMLBrowser->handleWebIndex( {
- feed => $FEED,
- title => $title,
- args => \@_
- } );
- });
-}
-
-sub cliQuery {
- my $request = shift;
-
- Slim::Buttons::XMLBrowser::cliQuery('lma', $FEED, $request);
-}
-
-sub cliRadiosQuery {
- my $request = shift;
-
- my $menu = $request->getParam('menu');
-
- my $data;
- # what we want the query to report about ourself
- if (defined $menu) {
- $data = {
- 'text' => Slim::Utils::Strings::string(getDisplayName()), # nice name
- 'actions' => {
- 'go' => {
- 'cmd' => ['lma', 'items'],
- 'params' => {
- 'menu' => 'lma',
- },
- },
- },
- };
- }
- else {
- $data = {
- 'cmd' => 'lma', # cmd label
- 'name' => Slim::Utils::Strings::string(getDisplayName()), # nice name
- 'type' => 'xmlbrowser', # type
- };
- }
-
- # let our super duper function do all the hard work
- Slim::Control::Queries::dynamicAutoQuery($request, 'radios', $cli_next, $data);
-}
-
1;
Modified: trunk/server/Slim/Plugin/Live365/Plugin.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Plugin/Live365/Plugin.pm?rev=12742&r1=12741&r2=12742&view=diff
==============================================================================
--- trunk/server/Slim/Plugin/Live365/Plugin.pm (original)
+++ trunk/server/Slim/Plugin/Live365/Plugin.pm Mon Aug 27 13:51:24 2007
@@ -5,14 +5,11 @@
# Browse Live365 via SqueezeNetwork
use strict;
-use base qw(Slim::Plugin::Base);
+use base qw(Slim::Plugin::OPMLBased);
use Slim::Networking::SqueezeNetwork;
use Slim::Player::ProtocolHandlers;
use Slim::Plugin::Live365::ProtocolHandler;
-
-my $FEED = Slim::Networking::SqueezeNetwork->url( '/api/live365/opml' );
-my $cli_next;
sub initPlugin {
my $class = shift;
@@ -21,39 +18,15 @@
live365 => 'Slim::Plugin::Live365::ProtocolHandler'
);
- # XXX: CLI support
-
- $class->SUPER::initPlugin();
+ $class->SUPER::initPlugin(
+ feed => Slim::Networking::SqueezeNetwork->url('/api/live365/opml'),
+ tag => 'live365',
+ menu => 'radio',
+ );
}
sub getDisplayName {
return 'PLUGIN_LIVE365_MODULE_NAME';
}
-sub setMode {
- my ( $class, $client, $method ) = @_;
-
- if ($method eq 'pop') {
-
- Slim::Buttons::Common::popMode($client);
- return;
- }
-
- # use INPUT.Choice to display the list of feeds
- my %params = (
- header => 'PLUGIN_LIVE365_LOADING',
- modeName => 'Live365 Plugin',
- url => $FEED,
- title => $client->string(getDisplayName()),
- timeout => 35,
- );
-
- Slim::Buttons::Common::pushMode($client, 'xmlbrowser', \%params);
-
- # we'll handle the push in a callback
- $client->modeParam( 'handledTransition', 1 );
-}
-
-# XXX: CLI/Web support
-
1;
Modified: trunk/server/Slim/Plugin/MP3tunes/Plugin.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Plugin/MP3tunes/Plugin.pm?rev=12742&r1=12741&r2=12742&view=diff
==============================================================================
--- trunk/server/Slim/Plugin/MP3tunes/Plugin.pm (original)
+++ trunk/server/Slim/Plugin/MP3tunes/Plugin.pm Mon Aug 27 13:51:24 2007
@@ -5,49 +5,22 @@
# Browse MP3tunes via SqueezeNetwork
use strict;
-use base qw(Slim::Plugin::Base);
+use base qw(Slim::Plugin::OPMLBased);
use Slim::Networking::SqueezeNetwork;
-
-my $FEED = Slim::Networking::SqueezeNetwork->url( '/api/mp3tunes/opml' );
-my $cli_next;
sub initPlugin {
my $class = shift;
- # XXX: CLI support
-
- $class->SUPER::initPlugin();
+ $class->SUPER::initPlugin(
+ feed => Slim::Networking::SqueezeNetwork->url('/api/mp3tunes/opml'),
+ tag => 'mp3tunes',
+ menu => 'music_on_demand',
+ );
}
sub getDisplayName () {
return 'PLUGIN_MP3TUNES_MODULE_NAME';
}
-sub setMode {
- my ( $class, $client, $method ) = @_;
-
- if ($method eq 'pop') {
-
- Slim::Buttons::Common::popMode($client);
- return;
- }
-
- # use INPUT.Choice to display the list of feeds
- my %params = (
- header => 'PLUGIN_MP3TUNES_LOADING',
- modeName => 'MP3Tunes Plugin',
- url => $FEED,
- title => $client->string(getDisplayName()),
- timeout => 35,
- );
-
- Slim::Buttons::Common::pushMode($client, 'xmlbrowser', \%params);
-
- # we'll handle the push in a callback
- $client->modeParam( 'handledTransition', 1 );
-}
-
-# XXX: CLI/Web support
-
1;
Added: trunk/server/Slim/Plugin/OPMLBased.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Plugin/OPMLBased.pm?rev=12742&view=auto
==============================================================================
--- trunk/server/Slim/Plugin/OPMLBased.pm (added)
+++ trunk/server/Slim/Plugin/OPMLBased.pm Mon Aug 27 13:51:24 2007
@@ -1,0 +1,125 @@
+package Slim::Plugin::OPMLBased;
+
+# $Id$
+
+# Base class for all plugins that use OPML feeds
+
+use strict;
+use base 'Slim::Plugin::Base';
+
+my %cli_next = ();
+
+sub initPlugin {
+ my ( $class, %args ) = @_;
+
+ {
+ no strict 'refs';
+ *{$class.'::'.'feed'} = sub { $args{feed} };
+ *{$class.'::'.'tag'} = sub { $args{tag} };
+ *{$class.'::'.'menu'} = sub { $args{menu} };
+ }
+
+ my $cliQuery = sub {
+ my $request = shift;
+ Slim::Buttons::XMLBrowser::cliQuery( $args{tag}, $args{feed}, $request );
+ };
+
+ # CLI support
+ Slim::Control::Request::addDispatch(
+ [ $args{tag}, 'items', '_index', '_quantity' ],
+ [ 0, 1, 1, $cliQuery ]
+ );
+
+ Slim::Control::Request::addDispatch(
+ [ $args{tag}, 'playlist', '_method' ],
+ [ 1, 1, 1, $cliQuery ]
+ );
+
+ $cli_next{$class} = Slim::Control::Request::addDispatch(
+ [ 'radios', '_index', '_quantity' ],
+ [ 0, 1, 1, $class->cliRadiosQuery( $args{tag} ) ]
+ );
+
+ $class->SUPER::initPlugin();
+}
+
+sub setMode {
+ my ( $class, $client, $method ) = @_;
+
+ if ($method eq 'pop') {
+
+ Slim::Buttons::Common::popMode($client);
+ return;
+ }
+
+ # use INPUT.Choice to display the list of feeds
+ my $name = $class->getDisplayName();
+
+ my %params = (
+ header => $name,
+ modeName => $name,
+ url => $class->feed(),
+ title => $client->string( $name ),
+ timeout => 35,
+ );
+
+ Slim::Buttons::Common::pushMode( $client, 'xmlbrowser', \%params );
+
+ # we'll handle the push in a callback
+ $client->modeParam( handledTransition => 1 );
+}
+
+sub cliRadiosQuery {
+ my ( $class, $tag ) = @_;
+
+ return sub {
+ my $request = shift;
+
+ my $menu = $request->getParam('menu');
+
+ my $data;
+ # what we want the query to report about ourself
+ if (defined $menu) {
+ $data = {
+ text => Slim::Utils::Strings::string(getDisplayName()), # nice name
+ actions => {
+ go => {
+ cmd => [ $tag, 'items' ],
+ params => {
+ menu => $tag,
+ },
+ },
+ },
+ };
+ }
+ else {
+ $data = {
+ cmd => $tag,
+ name => Slim::Utils::Strings::string( $class->getDisplayName() ),
+ type => 'xmlbrowser',
+ };
+ }
+
+ # let our super duper function do all the hard work
+ Slim::Control::Queries::dynamicAutoQuery( $request, 'radios', $cli_next{$class}, $data );
+ };
+}
+
+sub webPages {
+ my $class = shift;
+
+ my $title = $class->getDisplayName();
+ my $url = 'plugins/' . $class->tag() . '/index.html';
+
+ Slim::Web::Pages->addPageLinks( $class->menu(), { $title => $url });
+
+ Slim::Web::HTTP::addPageFunction( $url, sub {
+ Slim::Web::XMLBrowser->handleWebIndex( {
+ feed => $class->feed(),
+ title => $title,
+ args => \@_
+ } );
+ } );
+}
+
+1;
Modified: trunk/server/Slim/Plugin/Pandora/Plugin.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Plugin/Pandora/Plugin.pm?rev=12742&r1=12741&r2=12742&view=diff
==============================================================================
--- trunk/server/Slim/Plugin/Pandora/Plugin.pm (original)
+++ trunk/server/Slim/Plugin/Pandora/Plugin.pm Mon Aug 27 13:51:24 2007
@@ -5,7 +5,7 @@
# Play Pandora via SqueezeNetwork
use strict;
-use base qw(Slim::Plugin::Base);
+use base qw(Slim::Plugin::OPMLBased);
use Slim::Networking::SqueezeNetwork;
use Slim::Plugin::Pandora::ProtocolHandler;
@@ -15,9 +15,6 @@
'defaultLevel' => $ENV{PANDORA_DEV} ? 'DEBUG' : 'WARN',
'description' => 'PLUGIN_PANDORA_MODULE_NAME',
});
-
-my $FEED = Slim::Networking::SqueezeNetwork->url( '/api/pandora/opml' );
-my $cli_next;
sub initPlugin {
my $class = shift;
@@ -30,43 +27,15 @@
Slim::Control::Request::addDispatch(['pandora', 'skipTrack'],
[0, 1, 1, \&skipTrack]);
- # CLI support
- Slim::Control::Request::addDispatch(['pandora', 'items', '_index', '_quantity'],
- [0, 1, 1, \&cliQuery]);
- Slim::Control::Request::addDispatch(['pandora', 'playlist', '_method' ],
- [1, 1, 1, \&cliQuery]);
- $cli_next=Slim::Control::Request::addDispatch(['radios', '_index', '_quantity' ],
- [0, 1, 1, \&cliRadiosQuery]);
-
- $class->SUPER::initPlugin();
+ $class->SUPER::initPlugin(
+ feed => Slim::Networking::SqueezeNetwork->url('/api/pandora/opml'),
+ tag => 'pandora',
+ menu => 'radio',
+ );
}
sub getDisplayName () {
return 'PLUGIN_PANDORA_MODULE_NAME';
-}
-
-sub setMode {
- my ( $class, $client, $method ) = @_;
-
- if ($method eq 'pop') {
-
- Slim::Buttons::Common::popMode($client);
- return;
- }
-
- # use INPUT.Choice to display the list of feeds
- my %params = (
- header => 'PLUGIN_PANDORA_MODULE_NAME',
- modeName => 'Pandora Plugin',
- url => $FEED,
- title => $client->string(getDisplayName()),
- timeout => 35,
- );
-
- Slim::Buttons::Common::pushMode($client, 'xmlbrowser', \%params);
-
- # we'll handle the push in a callback
- $client->modeParam( 'handledTransition', 1 );
}
sub skipTrack {
@@ -88,45 +57,4 @@
$client->execute(["playlist", "jump", "+1"]);
}
-# XXX: Web support
-
-# XXX: Move this into a super-class, Slim::Plugin::OPMLBased or something
-sub cliQuery {
- my $request = shift;
-
- Slim::Buttons::XMLBrowser::cliQuery('pandora', $FEED, $request);
-}
-
-sub cliRadiosQuery {
- my $request = shift;
-
- my $menu = $request->getParam('menu');
-
- my $data;
- # what we want the query to report about ourself
- if (defined $menu) {
- $data = {
- 'text' => Slim::Utils::Strings::string(getDisplayName()), # nice name
- 'actions' => {
- 'go' => {
- 'cmd' => ['pandora', 'items'],
- 'params' => {
- 'menu' => 'pandora',
- },
- },
- },
- };
- }
- else {
- $data = {
- 'cmd' => 'pandora', # cmd label
- 'name' => Slim::Utils::Strings::string(getDisplayName()), # nice name
- 'type' => 'xmlbrowser', # type
- };
- }
-
- # let our super duper function do all the hard work
- Slim::Control::Queries::dynamicAutoQuery($request, 'radios', $cli_next, $data);
-}
-
1;
Modified: trunk/server/Slim/Plugin/Picks/Plugin.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Plugin/Picks/Plugin.pm?rev=12742&r1=12741&r2=12742&view=diff
==============================================================================
--- trunk/server/Slim/Plugin/Picks/Plugin.pm (original)
+++ trunk/server/Slim/Plugin/Picks/Plugin.pm Mon Aug 27 13:51:24 2007
@@ -5,116 +5,20 @@
# Load Picks via an OPML file - so we can ride on top of the Podcast Browser
use strict;
-use base qw(Slim::Plugin::Base);
-
-use Slim::Buttons::Common;
-use Slim::Buttons::XMLBrowser;
-use Slim::Web::XMLBrowser;
-
-# use spilt version of picks opml so each level can be added as a favorite
-my $FEED = 'http://www.slimdevices.com/picks/split/picks.opml';
-my $cli_next;
+use base qw(Slim::Plugin::OPMLBased);
sub initPlugin {
my $class = shift;
-# |requires Client
-# | |is a Query
-# | | |has Tags
-# | | | |Function to call
-# C Q T F
- Slim::Control::Request::addDispatch(['picks', 'items', '_index', '_quantity'],
- [0, 1, 1, \&cliQuery]);
- Slim::Control::Request::addDispatch(['picks', 'playlist', '_method' ],
- [1, 1, 1, \&cliQuery]);
- $cli_next=Slim::Control::Request::addDispatch(['radios', '_index', '_quantity' ],
- [0, 1, 1, \&cliRadiosQuery]);
-
- $class->SUPER::initPlugin();
+ $class->SUPER::initPlugin(
+ feed => 'http://www.slimdevices.com/picks/split/picks.opml',
+ tag => 'picks',
+ menu => 'radio',
+ );
}
sub getDisplayName {
return 'PLUGIN_PICKS_MODULE_NAME';
}
-sub setMode {
- my $class = shift;
- my $client = shift;
- my $method = shift;
-
- if ($method eq 'pop') {
- Slim::Buttons::Common::popMode($client);
- return;
- }
-
- # use INPUT.Choice to display the list of feeds
- my %params = (
- header => 'PLUGIN_PICKS_LOADING_PICKS',
- modeName => 'Picks Plugin',
- url => $FEED,
- title => $client->string(getDisplayName()),
- );
-
- Slim::Buttons::Common::pushMode($client, 'xmlbrowser', \%params);
-
- # we'll handle the push in a callback
- $client->modeParam('handledTransition', 1)
-}
-
-sub cliQuery {
- my $request = shift;
-
- Slim::Buttons::XMLBrowser::cliQuery('picks', $FEED, $request);
-}
-
-sub cliRadiosQuery {
- my $request = shift;
-
- my $menu = $request->getParam('menu');
-
- my $data;
- # what we want the query to report about ourself
- if (defined $menu) {
- $data = {
- 'text' => Slim::Utils::Strings::string(getDisplayName()), # nice name
- 'actions' => {
- 'go' => {
- 'cmd' => ['picks', 'items'],
- 'params' => {
- 'menu' => 'picks',
- },
- },
- },
- };
- }
- else {
- $data = {
- 'cmd' => 'picks', # cmd label
- 'name' => Slim::Utils::Strings::string(getDisplayName()), # nice name
- 'type' => 'xmlbrowser', # type
- };
- }
-
- # let our super duper function do all the hard work
- Slim::Control::Queries::dynamicAutoQuery($request, 'radios', $cli_next, $data);
-}
-
-sub webPages {
- my $class = shift;
-
- my $title = getDisplayName();
- my $url = 'plugins/Picks/index.html';
-
- Slim::Web::Pages->addPageLinks('radio', { $title => $url });
-
- Slim::Web::HTTP::addPageFunction($url, sub {
-
- Slim::Web::XMLBrowser->handleWebIndex( {
- feed => $FEED,
- title => $title,
- args => \@_
- } );
- });
-}
-
1;
Modified: trunk/server/Slim/Plugin/RhapsodyDirect/Plugin.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Plugin/RhapsodyDirect/Plugin.pm?rev=12742&r1=12741&r2=12742&view=diff
==============================================================================
--- trunk/server/Slim/Plugin/RhapsodyDirect/Plugin.pm (original)
+++ trunk/server/Slim/Plugin/RhapsodyDirect/Plugin.pm Mon Aug 27 13:51:24 2007
@@ -5,7 +5,7 @@
# Browse Rhapsody Direct via SqueezeNetwork
use strict;
-use base qw(Slim::Plugin::Base);
+use base 'Slim::Plugin::OPMLBased';
use Slim::Networking::SqueezeNetwork;
use Slim::Plugin::RhapsodyDirect::ProtocolHandler;
@@ -17,9 +17,6 @@
'description' => 'PLUGIN_RHAPSODY_DIRECT_MODULE_NAME',
});
-my $FEED = Slim::Networking::SqueezeNetwork->url( '/api/rhapsody/opml' );
-my $cli_next;
-
sub initPlugin {
my $class = shift;
@@ -30,38 +27,16 @@
Slim::Networking::Slimproto::addHandler(
RPDS => \&Slim::Plugin::RhapsodyDirect::RPDS::rpds_handler
);
-
- # XXX: CLI support
- $class->SUPER::initPlugin();
+ $class->SUPER::initPlugin(
+ feed => Slim::Networking::SqueezeNetwork->url('/api/rhapsody/opml'),
+ tag => 'rhapsodydirect',
+ menu => 'music_on_demand',
+ );
}
sub getDisplayName () {
return 'PLUGIN_RHAPSODY_DIRECT_MODULE_NAME';
-}
-
-sub setMode {
- my ( $class, $client, $method ) = @_;
-
- if ($method eq 'pop') {
-
- Slim::Buttons::Common::popMode($client);
- return;
- }
-
- # use INPUT.Choice to display the list of feeds
- my %params = (
- header => 'PLUGIN_RHAPSODY_DIRECT_LOGGING_IN',
- modeName => 'Rhapsody Direect Plugin',
- url => $FEED,
- title => $client->string(getDisplayName()),
- timeout => 35,
- );
-
- Slim::Buttons::Common::pushMode($client, 'xmlbrowser', \%params);
-
- # we'll handle the push in a callback
- $client->modeParam( 'handledTransition', 1 );
}
sub handleError {
@@ -91,6 +66,4 @@
}
}
-# XXX: CLI/Web support
-
1;
Modified: trunk/server/Slim/Plugin/RhapsodyDirect/strings.txt
URL: http://svn.slimdevices.com/trunk/server/Slim/Plugin/RhapsodyDirect/strings.txt?rev=12742&r1=12741&r2=12742&view=diff
==============================================================================
--- trunk/server/Slim/Plugin/RhapsodyDirect/strings.txt (original)
+++ trunk/server/Slim/Plugin/RhapsodyDirect/strings.txt Mon Aug 27 13:51:24 2007
@@ -1,10 +1,5 @@
PLUGIN_RHAPSODY_DIRECT_MODULE_NAME
- DE Rhapsody
- EN Rhapsody
- ES Rhapsody
- FR Rhapsody
- IT Rhapsody
- NL Rhapsody
+ EN Rhapsody Direct
PLUGIN_RHAPSODY_DIRECT_ERROR
DE Rhapsody-Fehler
More information about the checkins
mailing list