1
0
Fork 0
mirror of https://github.com/Yetangitu/ampache synced 2025-10-03 09:49:30 +02:00

Merge pull request #1355 from Phyks/api_update

API improvements
This commit is contained in:
Afterster 2016-08-21 08:55:34 +02:00 committed by GitHub
commit 624a2f0717
2 changed files with 55 additions and 21 deletions

View file

@ -305,7 +305,6 @@ class Api
* artists
* This takes a collection of inputs and returns
* artist objects. This function is deprecated!
* //DEPRECATED
* @param array $input
*/
public static function artists($input)
@ -332,7 +331,6 @@ class Api
/**
* artist
* This returns a single artist based on the UID of said artist
* //DEPRECATED
* @param array $input
*/
public static function artist($input)

View file

@ -72,8 +72,11 @@ class XML_Data
return false;
}
$limit = intval($limit);
self::$limit = $limit;
if (strtolower($limit) == "none") {
self::$limit = null;
} else {
self::$limit = intval($limit);
}
} // set_limit
/**
@ -257,11 +260,15 @@ class XML_Data
*/
public static function tags($tags)
{
if (count($tags) > self::$limit or self::$offset > 0) {
$tags = array_splice($tags, self::$offset, self::$limit);
}
$string = '<total_count>' . count($tags) . '</total_count>\n';
$string = '';
if (count($tags) > self::$limit or self::$offset > 0) {
if (null !== self::$limit) {
$tags = array_splice($tags, self::$offset, self::$limit);
} else {
$tags = array_splice($tags, self::$offset);
}
}
foreach ($tags as $tag_id) {
$tag = new Tag($tag_id);
@ -293,11 +300,18 @@ class XML_Data
*/
public static function artists($artists, $include=[], $full_xml=true)
{
if (count($artists) > self::$limit or self::$offset > 0) {
$artists = array_splice($artists, self::$offset, self::$limit);
if (null == $include) {
$include = array();
}
$string = '<total_count>' . count($artists) . '</total_count>\n';
$string = '';
if (count($artists) > self::$limit or self::$offset > 0) {
if (null !== self::$limit) {
$artists = array_splice($artists, self::$offset, self::$limit);
} else {
$artists = array_splice($artists, self::$offset);
}
}
Rating::build_cache('artist', $artists);
@ -354,13 +368,21 @@ class XML_Data
*/
public static function albums($albums, $include=[], $full_xml=true)
{
if (null == $include) {
$include = array();
}
$string = '<total_count>' . count($albums) . '</total_count>\n';
if (count($albums) > self::$limit or self::$offset > 0) {
$albums = array_splice($albums, self::$offset, self::$limit);
if (null !== self::$limit) {
$albums = array_splice($albums, self::$offset, self::$limit);
} else {
$albums = array_splice($albums, self::$offset);
}
}
Rating::build_cache('album', $albums);
$string = "";
foreach ($albums as $album_id) {
$album = new Album($album_id);
$album->format();
@ -412,11 +434,15 @@ class XML_Data
*/
public static function playlists($playlists)
{
if (count($playlists) > self::$limit or self::$offset > 0) {
$playlists = array_slice($playlists, self::$offset, self::$limit);
}
$string = '<total_count>' . count($playlists) . '</total_count>\n';
$string = '';
if (count($playlists) > self::$limit or self::$offset > 0) {
if (null !== self::$limit) {
$playlists = array_slice($playlists, self::$offset, self::$limit);
} else {
$playlists = array_slice($playlists, self::$offset);
}
}
// Foreach the playlist ids
foreach ($playlists as $playlist_id) {
@ -444,14 +470,19 @@ class XML_Data
*/
public static function songs($songs, $playlist_data='', $full_xml=true)
{
$string = '<total_count>' . count($songs) . '</total_count>\n';
if (count($songs) > self::$limit or self::$offset > 0) {
$songs = array_slice($songs, self::$offset, self::$limit);
if (null !== self::$limit) {
$songs = array_slice($songs, self::$offset, self::$limit);
} else {
$songs = array_slice($songs, self::$offset);
}
}
Song::build_cache($songs);
Stream::set_session($_REQUEST['auth']);
$string = "";
// Foreach the ids!
foreach ($songs as $song_id) {
$song = new Song($song_id);
@ -531,11 +562,16 @@ class XML_Data
*/
public static function videos($videos)
{
$string = '<total_count>' . count($videos) . '</total_count>\n';
if (count($videos) > self::$limit or self::$offset > 0) {
$videos = array_slice($videos, self::$offset, self::$limit);
if (null !== self::$limit) {
$videos = array_slice($videos, self::$offset, self::$limit);
} else {
$videos = array_slice($videos, self::$offset);
}
}
$string = '';
foreach ($videos as $video_id) {
$video = new Video($video_id);
$video->format();