We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

Commit 3d5d69b5 authored by Mike Sheldon's avatar Mike Sheldon

getTags is actually an implementation of getTopTags, so rename it as such.

parent e3f6ffd9
......@@ -76,7 +76,7 @@ $method_map = array(
'user.getrecenttracks' => method_user_getrecenttracks,
'radio.tune' => method_radio_tune,
'radio.getplaylist' => method_radio_getPlaylist,
'track.gettags' => method_track_getTags,
'track.gettoptags' => method_track_getTopTags,
);
function method_user_getrecenttracks() {
......@@ -382,13 +382,13 @@ $adodb->SetFetchMode(ADODB_FETCH_ASSOC);
* Track methods
*/
function method_track_getTags() {
function method_track_getTopTags() {
if (!isset($_GET['artist']) || !isset($_GET['track'])) {
report_failure(LFM_INVALID_SIGNATURE);
}
header('Content-Type: text/xml');
print(XML::prettyXML(TrackXML::getTags($_GET['artist'], $_GET['track'])));
print(XML::prettyXML(TrackXML::getTopTags($_GET['artist'], $_GET['track'])));
}
......
......@@ -24,10 +24,10 @@ require_once('xml.php');
class TrackXML {
public static function getTags($artist, $name) {
public static function getTopTags($artist, $name) {
$track = new Track($name, $artist);
$tags = $track->getTags();
$tags = $track->getTopTags();
$xml = new SimpleXMLElement('<lfm status="ok"></lfm>');
......@@ -35,9 +35,10 @@ class TrackXML {
$root->addAttribute('artist', $artist);
$root->addAttribute('track', $name);
foreach($tags as $tag) {
foreach($tags as &$tag) {
$tag_node = $root->addChild('tag', null);
$tag_node->addChild('name', repamp($tag));
$tag_node->addChild('name', repamp($tag['tag']));
$tag_node->addChild('count', repamp($tag['freq']));
}
return($xml);
......
......@@ -152,9 +152,9 @@ class Track {
/**
* Retrieve the tags for this track.
*
* @return An array of tag names
* @return An array of tag names and how frequent they are
*/
function getTags() {
function getTopTags() {
global $adodb;
$adodb->SetFetchMode(ADODB_FETCH_ASSOC);
......@@ -162,11 +162,8 @@ class Track {
. ' artist = ' . $adodb->qstr($this->artist_name)
. ' AND track = ' . $adodb->qstr($this->name)
. ' GROUP BY tag ORDER BY freq DESC');
foreach($res as &$row) {
$tags[] = $row['tag'];
}
return $tags;
return $res;
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment