[Slim-Checkins] r12799 - /trunk/server/Slim/Buttons/XMLBrowser.pm
andy at svn.slimdevices.com
andy at svn.slimdevices.com
Thu Aug 30 12:01:56 PDT 2007
Author: andy
Date: Thu Aug 30 12:01:56 2007
New Revision: 12799
URL: http://svn.slimdevices.com?rev=12799&view=rev
Log:
Fix type=search support on Jive, handle command items
Modified:
trunk/server/Slim/Buttons/XMLBrowser.pm
Modified: trunk/server/Slim/Buttons/XMLBrowser.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Buttons/XMLBrowser.pm?rev=12799&r1=12798&r2=12799&view=diff
==============================================================================
--- trunk/server/Slim/Buttons/XMLBrowser.pm (original)
+++ trunk/server/Slim/Buttons/XMLBrowser.pm Thu Aug 30 12:01:56 2007
@@ -354,7 +354,9 @@
sub gotOPML {
my ($client, $url, $opml, $params) = @_;
- # If there's a command we need to run, run it (used by Pandora)
+ # If there's a command we need to run, run it. This is used in various
+ # places to trigger actions from an OPML result, such as to start playing
+ # a new Pandora radio station
if ( $opml->{'command'} ) {
my @p = split / /, $opml->{'command'};
$client->execute( \@p );
@@ -1193,7 +1195,7 @@
return;
}
- $log->debug("Asynchronously fetching feed - will be back!");
+ $log->debug("Asynchronously fetching feed $feed - will be back!");
Slim::Formats::XML->getFeedAsync(
\&_cliQuery_done,
\&_cliQuery_error,
@@ -1216,6 +1218,7 @@
my $request = $params->{'request'};
my $query = $params->{'query'};
my $expires = $params->{'expires'};
+ my $timeout = $params->{'timeout'};
# my $forceTitle = $params->{'forceTitle'};
my $isItemQuery = my $isPlaylistCmd = 0;
@@ -1236,7 +1239,7 @@
# menu/jive mgmt
my $menuMode = defined $menu;
-
+
# select the proper list of items
my @index = ();
@@ -1273,7 +1276,12 @@
# current cached feed
if ( $subFeed->{'type'} ne 'audio' && defined $subFeed->{'url'} && !$subFeed->{'fetched'}) {
- $log->debug("Asynchronously fetching subfeed - will be back!");
+ # Rewrite the URL if it was a search request
+ if ( $subFeed->{type} eq 'search' ) {
+ $subFeed->{url} =~ s/{QUERY}/$search/g;
+ }
+
+ $log->debug("Asynchronously fetching subfeed " . $subFeed->{url} . " - will be back!");
Slim::Formats::XML->getFeedAsync(
\&_cliQuerySubFeed_done,
@@ -1288,7 +1296,8 @@
'currentIndex' => \@crumbIndex,
'request' => $request,
'query' => $query,
- 'expires' => $expires
+ 'expires' => $expires,
+ 'timeout' => $timeout,
},
);
return;
@@ -1344,7 +1353,7 @@
if ($valid) {
- my $loopname = $menuMode?'item_loop':'loop_loop';
+ my $loopname = $menuMode ? 'item_loop' : 'loop_loop';
my $cnt = 0;
$request->addResult('offset', $start) if $menuMode;
@@ -1553,17 +1562,29 @@
$request->addResultLoop($loopname, $cnt, 'text', $hash{'name'} || $hash{'title'});
+ my $params = {};
+ my $id = $hash{id};
+
if ( $item->{type} ne 'text' ) {
- my $id = $hash{id};
- my $params = {
+ $params = {
item_id => "$id", #stringify, make sure it's a string
};
-
- $request->addResultLoop( $loopname, $cnt, 'params', $params );
}
if ( $item->{type} eq 'search' ) {
- $params->{search} = '__INPUT__';
+ #$params->{search} = '__INPUT__';
+
+ # XXX: bug in Jive, this should really be handled by the base go action
+ my $actions = {
+ go => {
+ cmd => [ $query, 'items' ],
+ params => {
+ item_id => "$id",
+ menu => $query,
+ search => '__TAGGEDINPUT__',
+ },
+ },
+ };
my $input = {
len => 3,
@@ -1572,10 +1593,13 @@
},
};
+ $request->addResultLoop( $loopname, $cnt, 'actions', $actions );
$request->addResultLoop( $loopname, $cnt, 'input', $input );
}
-
+ if ( scalar keys %{$params} ) {
+ $request->addResultLoop( $loopname, $cnt, 'params', $params );
+ }
}
else {
$request->setResultLoopHash($loopname, $cnt, \%hash);
@@ -1596,6 +1620,15 @@
sub _cliQuerySubFeed_done {
my ( $feed, $params ) = @_;
+ # If there's a command we need to run, run it. This is used in various
+ # places to trigger actions from an OPML result, such as to start playing
+ # a new Pandora radio station
+ if ( $feed->{command} ) {
+ my @p = split / /, $feed->{command};
+ my $client = $params->{request}->client();
+ $client->execute( \@p );
+ }
+
# insert the sub-feed data into the original feed
my $parent = $params->{'parent'};
my $subFeed = $parent;
More information about the checkins
mailing list