Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gnu-fm
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
16
Issues
16
List
Board
Labels
Milestones
Merge Requests
7
Merge Requests
7
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gnu.io
gnu-fm
Commits
d19bc9c5
Commit
d19bc9c5
authored
Mar 31, 2014
by
Mike Sheldon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add initial implementation of track.getInfo webservice method
parent
ae6c4d4d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
0 deletions
+53
-0
index.php
nixtape/2.0/index.php
+26
-0
TrackXML.php
nixtape/api/TrackXML.php
+27
-0
No files found.
nixtape/2.0/index.php
View file @
d19bc9c5
...
...
@@ -113,6 +113,7 @@ $method_map = array(
'tag.getinfo'
=>
method_tag_getInfo
,
'track.addtags'
=>
method_track_addTags
,
'track.removetag'
=>
method_track_removeTag
,
'track.getinfo'
=>
method_track_getInfo
,
'track.gettoptags'
=>
method_track_getTopTags
,
'track.gettopfans'
=>
method_track_getTopFans
,
'track.gettags'
=>
method_track_getTags
,
...
...
@@ -1137,6 +1138,31 @@ function method_track_removeTag() {
}
/**
* track.getinfo : Get general information about a track.
*
* ###Description
* Get further information about this track.
*
* ###Parameters
* * **artist** (required) : Name of the track's artist.
* * **track** (required) : Name of the track.
* * **username** (optional) : User to get track info for (e.g. whether loved or not)
* ---
*
* @package Webservice
* @subpackage Track
* @api
*/
function
method_track_getInfo
()
{
if
(
!
isset
(
$_REQUEST
[
'artist'
])
||
!
isset
(
$_REQUEST
[
'track'
]))
{
report_failure
(
LFM_INVALID_PARAMS
);
}
$xml
=
TrackXML
::
getInfo
(
$_REQUEST
[
'artist'
],
$_REQUEST
[
'track'
],
$_REQUEST
[
'username'
]);
respond
(
$xml
);
}
/**
* track.gettoptags : Get the top tags for a track.
*
...
...
nixtape/api/TrackXML.php
View file @
d19bc9c5
...
...
@@ -64,6 +64,33 @@ class TrackXML {
return
$xml
;
}
public
static
function
getInfo
(
$artist
,
$name
,
$username
)
{
global
$adodb
;
try
{
$track
=
new
Track
(
$name
,
$artist
);
}
catch
(
Exception
$e
)
{
return
(
XML
::
error
(
'failed'
,
'7'
,
'Invalid resource specified'
));
}
$xml
=
new
SimpleXMLElement
(
'<lfm status="ok"></lfm>'
);
$root
=
$xml
->
addChild
(
'track'
,
null
);
$root
->
addChild
(
'name'
,
$track
->
name
);
$root
->
addChild
(
'mbid'
,
$track
->
mbid
);
$root
->
addChild
(
'url'
,
$track
->
getURL
());
$root
->
addChild
(
'duration'
,
$track
->
duration
*
1000
);
$streamable
=
$root
->
addChild
(
'streamable'
,
$track
->
streamable
);
$streamable
->
addAttribute
(
'fulltrack'
,
$track
->
streamable
);
$root
->
addChild
(
'listeners'
,
$track
->
getListenerCount
());
$root
->
addChild
(
'playcount'
,
$track
->
getPlayCount
());
if
(
$username
)
{
$userid
=
$adodb
->
GetOne
(
'SELECT uniqueid FROM Users WHERE '
.
'username = '
.
$adodb
->
qstr
(
$username
));
$root
->
addChild
(
'userloved'
,
$track
->
isLoved
(
$userid
)
?
1
:
0
);
}
return
$xml
;
}
public
static
function
getTopTags
(
$artist
,
$name
,
$limit
,
$cache
)
{
try
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment