Update api page.

This commit is contained in:
DariusIII
2015-09-17 23:33:15 +02:00
parent 32f980d215
commit f0ffcaa25a
+15 -12
View File
@@ -127,7 +127,7 @@ switch ($function) {
verifyEmptyParameter('q');
$maxAge = maxAge();
$page->users->addApiRequest($uid, $_SERVER['REQUEST_URI']);
$categoryID = categoryid();
$categoryID = categoryID();
$limit = limit();
$offset = offset();
@@ -164,7 +164,7 @@ switch ($function) {
$offset,
limit(),
(isset($_GET['q']) ? $_GET['q'] : ''),
categoryid(),
categoryID(),
$maxAge
);
@@ -362,7 +362,7 @@ switch ($function) {
$offset,
limit(),
(isset($_GET['q']) ? $_GET['q'] : ''),
categoryid(),
categoryID(),
$maxAge
);
@@ -558,15 +558,14 @@ function maxAge()
* Verify cat parameter.
* @return array
*/
function categoryid()
function categoryID()
{
$categoryID = [];
$categoryID[] = -1;
if (isset($_GET['cat'])) {
$categoryIDs = $_GET['cat'];
// Append Web-DL category id if HD present for SickBeard / NZBDrone compatibility.
if (strpos($_GET['cat'], (string)Category::CAT_TV_HD) !== false &&
strpos($_GET['cat'], (string)Category::CAT_TV_WEBDL) === false) {
$categoryIDs = urldecode($_GET['cat']);
// Append Web-DL category ID if HD present for SickBeard / NZBDrone compatibility.
if (strpos($categoryIDs, (string)Category::CAT_TV_HD) !== false &&
strpos($categoryIDs, (string)Category::CAT_TV_WEBDL) === false) {
$categoryIDs .= (',' . Category::CAT_TV_WEBDL);
}
$categoryID = explode(',', $categoryIDs);
@@ -612,10 +611,14 @@ function printOutput($data, $xml = true, $page, $offset = 0)
if ($xml) {
$page->smarty->assign('offset', $offset);
$page->smarty->assign('releases', $data);
$response = trim($page->smarty->fetch('apiresult.tpl'));
header('Content-type: text/xml');
echo trim($page->smarty->fetch('apiresult.tpl'));
header('Content-Length: ' . strlen($response) );
echo $response;
} else {
$response = json_encode($data);
header('Content-type: application/json');
header('Content-Length: ' . strlen($response) );
echo json_encode($data);
}
}
@@ -644,10 +647,10 @@ function addCoverURL(&$releases, callable $getCoverURL)
/**
* Add language from media info XML to release search names.
* @param array $releases
* @param \newznab\db\Settings $settings
* @param newznab\db\Settings $settings
* @return array
*/
function addLanguage(&$releases, \newznab\db\Settings $settings)
function addLanguage(&$releases, Settings $settings)
{
if ($releases && count($releases)) {
foreach ($releases as $key => $release) {