[Slim-Checkins] r11389 - in /trunk/server: HTML/EN/html/docs/cli-api.html Slim/Control/Queries.pm Slim/Control/Request.pm

fred at svn.slimdevices.com fred at svn.slimdevices.com
Sat Feb 10 16:14:33 PST 2007


Author: fred
Date: Sat Feb 10 16:14:33 2007
New Revision: 11389

URL: http://svn.slimdevices.com?rev=11389&view=rev
Log:
Bug: 1323
Description: Year CLI query


Modified:
    trunk/server/HTML/EN/html/docs/cli-api.html
    trunk/server/Slim/Control/Queries.pm
    trunk/server/Slim/Control/Request.pm

Modified: trunk/server/HTML/EN/html/docs/cli-api.html
URL: http://svn.slimdevices.com/trunk/server/HTML/EN/html/docs/cli-api.html?rev=11389&r1=11388&r2=11389&view=diff
==============================================================================
--- trunk/server/HTML/EN/html/docs/cli-api.html (original)
+++ trunk/server/HTML/EN/html/docs/cli-api.html Sat Feb 10 16:14:33 2007
@@ -60,6 +60,8 @@
 </p>
 <ul>
 	<li>
+		Added the &quot;<a href="#years">years</a>&quot; query, to enable
+		Browse by Year functionality.
 	</li>
 </ul>
 
@@ -2306,6 +2308,9 @@
 		<strong><code><a href="#albums">albums</a></code></strong>
 	</li>
 	<li>
+		<strong><code><a href="#years">years</a></code></strong>
+	</li>
+	<li>
 		<strong><code><a href="#playlists">playlists</a></code></strong>
 	</li>
 	<li>
@@ -3091,6 +3096,105 @@
 
 
 <br>
+<p id="years">
+	<strong>
+		<code>
+			years
+			&lt;start&gt;
+			&lt;itemsPerResponse&gt;
+			&lt;taggedParameters&gt;
+		</code>
+	</strong>
+</p>
+<p>
+	The &quot;years&quot; query returns all years known by the server.
+</p>
+<p>
+	Accepted tagged parameters:
+</p>
+<table border="0" spacing="50">
+	<tr>
+		<td width="100">
+			<b>Tag</b>
+		</td>
+		<td>
+			<b>Description</b>
+		</td>
+	</tr>
+	<tr>
+		<td>
+			charset
+		</td>
+		<td>
+			Character set to use to return data. See 
+			<a href="#Notes">charset notes</a> above.
+		</td>
+	</tr>
+</table>
+<p>
+	Returned tagged parameters:
+</p>
+<table border="0" spacing="50">
+	<tr>
+		<td width="100">
+			<b>Tag</b>
+		</td>
+		<td>
+			<b>Description</b>
+		</td>
+	</tr>
+	<tr>
+		<td>
+			rescan
+		</td>
+		<td>
+			Returned with value 1 if the server is still scanning 
+			the database. The results may therefore be incomplete.
+			Not returned if no scan is in progress.
+		</td>
+	</tr>
+	<tr>
+		<td>
+			count
+		</td>
+		<td>
+			Number of results returned by the query. If no filter parameter is
+			present, this is the same value as returned by 
+			&quot;<a href="#info total genres ?">info total genres ?</a>&quot;.
+		</td>
+	</tr>
+	<tr>
+		<td>
+			<em>For each year:</em>
+		</td>
+		<td>
+		</td>
+	</tr>
+	<tr>
+		<td>
+			&nbsp;&nbsp;<b>year</b>
+		</td>
+		<td>
+			Year. Item delimiter.
+		</td>
+	</tr>
+</table>
+<p>
+	Example:
+</p>
+<blockquote> 
+	<p>
+  		Request: &quot;years 0 5&lt;LF&gt;&quot;
+  		<br>
+		Response: &quot;years 0 5 rescan:1 count:6 
+		year:1985 year:1987 year:1988 
+		year:2002 year:2003 year:2004
+		&lt;LF&gt;&quot;
+	</p>
+</blockquote>
+
+
+<br>
 <p id="playlists">
 	<strong>
 		<code>
@@ -3305,6 +3409,7 @@
 	</tr>
 </table>
 
+
 <br>
 <p id="playlists rename">
 	<strong>
@@ -3537,6 +3642,7 @@
 			playlist_id:22 title:Song url:file://...&lt;LF&gt;&quot;
 	</p>
 </blockquote>
+
 
 <br>
 <p id="songinfo">
@@ -5375,12 +5481,23 @@
   <p>Request: &quot;04:20:00:12:23:45 playlist repeat 0&lt;LF&gt;&quot;<br>Response: &quot;04:20:00:12:23:45 playlist repeat 0&lt;LF&gt;&quot;</p>
 </blockquote>
 
-<br><p id="playlistcontrol"><strong>
-	<code>&lt;playerid&gt; playlistcontrol &lt;taggedParameters&gt;</code>
-</strong></p>
-<p>The &quot;playlistcontrol&quot; command enables playlist operations using
-   IDs as returned by extended CLI queries (titles, artists, playlists, etc).</p>
-<p>Accepted tagged parameters:</p>
+<br>
+<p id="playlistcontrol">
+	<strong>
+		<code>
+			&lt;playerid&gt;
+			playlistcontrol
+			&lt;taggedParameters&gt;
+		</code>
+	</strong>
+</p>
+<p>
+	The &quot;playlistcontrol&quot; command enables playlist operations using IDs as returned by 
+	extended CLI queries (titles, artists, playlists, etc).
+</p>
+<p>
+	Accepted tagged parameters:
+</p>
 <table border="0" spacing="50">
 	<tr>
 		<td width="100"><b>Tag</b></td>
@@ -5388,10 +5505,12 @@
 	</tr>
 	<tr>
 		<td>cmd</td>
-		<td>Command to perform on the playlist, one of &quot;load&quot;, 
+		<td>
+			Command to perform on the playlist, one of &quot;load&quot;, 
 			&quot;add&quot;, &quot;insert&quot; or &quot;delete&quot;.
 		 	This parameter is mandatory. If no additional parameter is provided,
-		 	the entire DB is loaded/added/inserted/deleted.</td>
+		 	the entire DB is loaded/added/inserted/deleted.
+		 </td>
 	</tr>
 	<tr>
 		<td>genre_id</td>

Modified: trunk/server/Slim/Control/Queries.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Control/Queries.pm?rev=11389&r1=11388&r2=11389&view=diff
==============================================================================
--- trunk/server/Slim/Control/Queries.pm (original)
+++ trunk/server/Slim/Control/Queries.pm Sat Feb 10 16:14:33 2007
@@ -1761,6 +1761,55 @@
 
 	$request->addResult('_version', $::VERSION);
 	
+	$request->setStatusDone();
+}
+
+sub yearsQuery {
+	my $request = shift;
+
+	$log->debug("Begin Function");
+
+	# check this is the correct query.
+	if ($request->isNotQuery([['years']])) {
+		$request->setStatusBadDispatch();
+		return;
+	}
+
+	# get our parameters
+	my $index         = $request->getParam('_index');
+	my $quantity      = $request->getParam('_quantity');	
+	
+	# get them all by default
+	my $where = {};
+	
+	# sort them
+	my $attr = {
+		'distinct' => 'me.id'
+	};
+
+	if (Slim::Music::Import->stillScanning()) {
+		$request->addResult('rescan', 1);
+	}
+
+	my $rs = Slim::Schema->resultset('Year')->browse->search($where, $attr);
+
+	my $count = $rs->count;
+
+	$request->addResult('count', $count);
+
+	my ($valid, $start, $end) = $request->normalize(scalar($index), scalar($quantity), $count);
+
+	if ($valid) {
+
+		my $loopname = '@years';
+		my $cnt = 0;
+
+		for my $eachitem ($rs->slice($start, $end)) {
+			$request->addResultLoop($loopname, $cnt, 'year', $eachitem->id);
+			$cnt++;
+		}
+	}
+
 	$request->setStatusDone();
 }
 

Modified: trunk/server/Slim/Control/Request.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Control/Request.pm?rev=11389&r1=11388&r2=11389&view=diff
==============================================================================
--- trunk/server/Slim/Control/Request.pm (original)
+++ trunk/server/Slim/Control/Request.pm Sat Feb 10 16:14:33 2007
@@ -60,6 +60,7 @@
  N    info            total                       genres|artists|albums|songs ?
  N    songinfo        <startindex>                <numitems>                  <tagged parameters>
  N    titles          <startindex>                <numitems>                  <tagged parameters>
+ N    years           <startindex>                <numitems>                  <tagged parameters>
  
  N    playlists       <startindex>                <numitems>                  <tagged parameters>
  N    playlists       tracks                      <startindex>                <numitems>       <tagged parameters>
@@ -566,6 +567,7 @@
     addDispatch(['tracks',         '_index',         '_quantity'],                                     [0, 1, 1, \&Slim::Control::Queries::titlesQuery]);
     addDispatch(['version',        '?'],                                                               [0, 1, 0, \&Slim::Control::Queries::versionQuery]);
     addDispatch(['wipecache'],                                                                         [0, 0, 0, \&Slim::Control::Commands::wipecacheCommand]);
+    addDispatch(['years',          '_index',         '_quantity'],                                     [0, 1, 1, \&Slim::Control::Queries::yearsQuery]);
 
 # NOTIFICATIONS
     addDispatch(['client',         'disconnect'],                                                      [1, 0, 0, undef]);



More information about the checkins mailing list