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

Add rating on XML API

This commit is contained in:
Afterster 2015-10-16 22:47:01 +02:00
parent 32c6e77806
commit bda9389c26
4 changed files with 77 additions and 57 deletions

View file

@ -1009,5 +1009,31 @@ class Api
debug_event('api', 'Sociable feature is not enabled.', 3);
}
} // last_shouts
/**
* rate
* This rate a library item
* @param array $input
*/
public static function rate($input)
{
ob_end_clean();
$type = $input['type'];
$id = $input['id'];
$rating = $input['rating'];
if (!Core::is_library_item($type) || !$id) {
echo XML_Data::error('401', T_('Wrong library item type.'));
} else {
$item = new $type($id);
if (!$item->id) {
echo XML_Data::error('404', T_('Library item not found.'));
} else {
$rating = new Rating($id, $type);
$rating->set_rating($rating);
echo XML_Data::single_string('success');
}
}
} // rate
} // API class

View file

@ -447,7 +447,6 @@ class vainfo
$arr[] = trim($genre);
}
}
} else {
$arr = $info[$field];
}
@ -1054,8 +1053,7 @@ class vainfo
$temp = preg_split("~[\.\s\-\_][S|s]eason[\s\-\.\_](\d+)[\.\s\-\_]?\s?[e|E]pisode[\s\-\.\_](\d+)([\s\-\.\_])*~",$file,3);
preg_match("~(?<=[Ss]eason[\.\s\-\_])\d+~", $file, $season);
preg_match("~(?<=[Ee]pisode[\.\s\-\_])\d+~", $file, $episode);
}
else {
} else {
if (preg_match("~[\_\-\.\s](\d)(\d\d)[\_\-\.\s]*~", $file, $seasonEpisode)) {
$temp = preg_split("~[\.\s\-\_](\d)(\d\d)[\.\s\-\_]~",$file);
$season[0] = $seasonEpisode[1];
@ -1159,8 +1157,7 @@ class vainfo
$commonabbr[] = '[1|2][0-9]{3}'; //Remove release year
//scan for brackets, braces, etc and ignore case.
for ($i=0; $i< count($commonabbr);$i++)
{
for ($i=0; $i< count($commonabbr);$i++) {
$commonabbr[$i] = "~\[*|\(*|\<*|\{*\b(?i)" . trim($commonabbr[$i]) . "\b\]*|\)*|\>*|\}*~";
}
$string = preg_replace($commonabbr,'',$name);

View file

@ -184,8 +184,7 @@ class AmpacheTvdb
private function getReleaseByTitle($results, $title, $year)
{
$titles = array();
foreach ($results as $index)
{
foreach ($results as $index) {
$pos = strpos($index->name, $title);
if ($pos !== false) {
$titles[] = $index;
@ -193,8 +192,7 @@ class AmpacheTvdb
}
if ((count($titles) > 1) && ($year != null)) {
foreach ($titles as $index)
{
foreach ($titles as $index) {
$y = $index->firstAired->format('Y');
if ($year == $y) {
return $index;
@ -203,6 +201,5 @@ class AmpacheTvdb
}
return count($titles) > 0 ? $titles[0] : $results[0];
}
} // end AmpacheTvdb
?>