mirror of
https://github.com/Yetangitu/ampache
synced 2025-10-03 17:59:21 +02:00
Improve API, as discussed in #1292
* Provide artists art in the `artists` method. * Add `name` as an alias for `title` attribute for `songs` and stuff. * Add a `.htaccess` file to enable CORS headers. Closes #1292.
This commit is contained in:
parent
c4a51bc1b1
commit
21b321098c
2 changed files with 14 additions and 0 deletions
|
@ -306,11 +306,15 @@ class XML_Data
|
|||
$rating = new Rating($artist_id,'artist');
|
||||
$tag_string = self::tags_string($artist->tags);
|
||||
|
||||
// Build the Art URL, include session
|
||||
$art_url = AmpConfig::get('web_path') . '/image.php?object_id=' . $artist_id . '&object_type=artist&auth=' . scrub_out($_REQUEST['auth']);
|
||||
|
||||
$string .= "<artist id=\"" . $artist->id . "\">\n" .
|
||||
"\t<name><![CDATA[" . $artist->f_full_name . "]]></name>\n" .
|
||||
$tag_string .
|
||||
"\t<albums>" . ($artist->albums ?: 0) . "</albums>\n" .
|
||||
"\t<songs>" . ($artist->songs ?: 0) . "</songs>\n" .
|
||||
"\t<art><![CDATA[$art_url]]></art>\n" .
|
||||
"\t<preciserating>" . ($rating->get_user_rating() ?: 0) . "</preciserating>\n" .
|
||||
"\t<rating>" . ($rating->get_user_rating() ?: 0) . "</rating>\n" .
|
||||
"\t<averagerating>" . ($rating->get_average_rating() ?: 0) . "</averagerating>\n" .
|
||||
|
@ -441,7 +445,9 @@ class XML_Data
|
|||
$art_url = Art::url($song->album, 'album', $_REQUEST['auth']);
|
||||
|
||||
$string .= "<song id=\"" . $song->id . "\">\n" .
|
||||
// Title is an alias for name
|
||||
"\t<title><![CDATA[" . $song->title . "]]></title>\n" .
|
||||
"\t<name><![CDATA[" . $song->title . "]]></name>\n" .
|
||||
"\t<artist id=\"" . $song->artist .
|
||||
'"><![CDATA[' . $song->get_artist_name() .
|
||||
"]]></artist>\n" .
|
||||
|
@ -512,7 +518,9 @@ class XML_Data
|
|||
$video->format();
|
||||
|
||||
$string .= "<video id=\"" . $video->id . "\">\n" .
|
||||
// Title is an alias for name
|
||||
"\t<title><![CDATA[" . $video->title . "]]></title>\n" .
|
||||
"\t<name><![CDATA[" . $video->title . "]]></name>\n" .
|
||||
"\t<mime><![CDATA[" . $video->mime . "]]></mime>\n" .
|
||||
"\t<resolution>" . $video->f_resolution . "</resolution>\n" .
|
||||
"\t<size>" . $video->size . "</size>\n" .
|
||||
|
@ -559,7 +567,9 @@ class XML_Data
|
|||
$art_url = Art::url($song->album, 'album', $_REQUEST['auth']);
|
||||
|
||||
$string .= "<song id=\"" . $song->id . "\">\n" .
|
||||
// Title is an alias for name
|
||||
"\t<title><![CDATA[" . $song->title . "]]></title>\n" .
|
||||
"\t<name><![CDATA[" . $song->title . "]]></name>\n" .
|
||||
"\t<artist id=\"" . $song->artist . "\"><![CDATA[" . $song->f_artist_full . "]]></artist>\n" .
|
||||
"\t<album id=\"" . $song->album . "\"><![CDATA[" . $song->f_album_full . "]]></album>\n" .
|
||||
"\t<genre id=\"" . $song->genre . "\"><![CDATA[" . $song->f_genre . "]]></genre>\n" .
|
||||
|
|
4
server/.htaccess
Normal file
4
server/.htaccess
Normal file
|
@ -0,0 +1,4 @@
|
|||
# Enable CORS headers
|
||||
<IfModule mod_headers.c>
|
||||
Header set Access-Control-Allow-Origin "*"
|
||||
</IfModule>
|
Loading…
Add table
Add a link
Reference in a new issue