mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-30 09:48:55 +00:00
Add back reporting of total releases to api response
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
2016-09-16 DariusIII
|
||||
* Chg: Add back reporting of total releases to api response
|
||||
* Chg: Group music releases in Gamma theme.
|
||||
2016-09-15 DariusIII
|
||||
* Chg: Update yenc decode handling for new php-yenc module
|
||||
|
||||
@@ -1118,6 +1118,9 @@ class Releases
|
||||
);
|
||||
|
||||
$releases = $this->pdo->query($sql, true, NN_CACHE_EXPIRY_MEDIUM);
|
||||
if (!empty($releases) && count($releases)) {
|
||||
$releases[0]['_totalrows'] = $this->getPagerCount($baseSql);
|
||||
}
|
||||
return $releases;
|
||||
}
|
||||
|
||||
@@ -1175,6 +1178,9 @@ class Releases
|
||||
);
|
||||
$releases = $this->pdo->query($sql, true, NN_CACHE_EXPIRY_MEDIUM);
|
||||
|
||||
if (!empty($releases) && count($releases)) {
|
||||
$releases[0]['_totalrows'] = $this->getPagerCount($baseSql);
|
||||
}
|
||||
return $releases;
|
||||
}
|
||||
|
||||
@@ -1232,6 +1238,9 @@ class Releases
|
||||
);
|
||||
$releases = $this->pdo->query($sql, true, NN_CACHE_EXPIRY_MEDIUM);
|
||||
|
||||
if (!empty($releases) && count($releases)) {
|
||||
$releases[0]['_totalrows'] = $this->getPagerCount($baseSql);
|
||||
}
|
||||
return $releases;
|
||||
}
|
||||
|
||||
|
||||
@@ -63,9 +63,10 @@ abstract class Capabilities
|
||||
* @param array $data Data to print.
|
||||
* @param array $params Additional request parameters
|
||||
* @param bool $xml True: Print as XML False: Print as JSON.
|
||||
* @param $offset
|
||||
* @param string $type What type of API query to format if XML
|
||||
*/
|
||||
public function output($data, $params, $xml = true, $type = '')
|
||||
public function output($data, $params, $xml = true, $offset, $type = '')
|
||||
{
|
||||
$this->type = $type;
|
||||
|
||||
@@ -73,6 +74,7 @@ abstract class Capabilities
|
||||
'Parameters' => $params,
|
||||
'Data' => $data,
|
||||
'Server' => $this->getForMenu(),
|
||||
'Offset' => $offset,
|
||||
'Type' => $type
|
||||
];
|
||||
|
||||
|
||||
@@ -95,6 +95,7 @@ class XML_Response
|
||||
'Parameters' => null,
|
||||
'Data' => null,
|
||||
'Server' => null,
|
||||
'Offset' => null,
|
||||
'Type' => null,
|
||||
];
|
||||
$options += $defaults;
|
||||
@@ -102,6 +103,7 @@ class XML_Response
|
||||
$this->parameters = $options['Parameters'];
|
||||
$this->releases = $options['Data'];
|
||||
$this->server = $options['Server'];
|
||||
$this->offset = $options['Offset'];
|
||||
$this->type = $options['Type'];
|
||||
|
||||
$this->xml = new \XMLWriter();
|
||||
@@ -172,6 +174,7 @@ class XML_Response
|
||||
$this->includeRssAtomLink();
|
||||
$this->includeMetaInfo();
|
||||
$this->includeImage();
|
||||
$this->includeTotalRows();
|
||||
$this->includeReleases();
|
||||
$w->endElement(); // End channel
|
||||
$w->endElement(); // End RSS
|
||||
@@ -335,6 +338,14 @@ class XML_Response
|
||||
$this->xml->endElement();
|
||||
}
|
||||
|
||||
public function includeTotalRows()
|
||||
{
|
||||
$this->xml->startElement($this->namespace.":response");
|
||||
$this->xml->writeAttribute('offset', $this->offset);
|
||||
$this->xml->writeAttribute('total', isset($this->releases[0]['_totalrows']) ? $this->releases[0]['_totalrows'] : 0);
|
||||
$this->xml->endElement();
|
||||
}
|
||||
|
||||
/**
|
||||
* Loop through the releases and add their info to the XML stream
|
||||
*/
|
||||
|
||||
+10
-6
@@ -125,11 +125,15 @@ switch ($function) {
|
||||
"basic", $categoryID, $minSize
|
||||
);
|
||||
} else {
|
||||
$totalRows = $releases->getBrowseCount($categoryID, $maxAge, $catExclusions);
|
||||
$relData = $releases->getBrowseRange(
|
||||
$categoryID, $offset, $limit, '', $maxAge, $catExclusions, $groupName, $minSize
|
||||
);
|
||||
if ($totalRows > 0 && count($relData) > 0) {
|
||||
$relData[0]['_totalrows'] = $totalRows;
|
||||
}
|
||||
}
|
||||
$api->output($relData, $params, $outputXML, 'api');
|
||||
$api->output($relData, $params, $outputXML, $offset, 'api');
|
||||
break;
|
||||
// Search tv releases.
|
||||
case 'tv':
|
||||
@@ -183,7 +187,7 @@ switch ($function) {
|
||||
);
|
||||
|
||||
$api->addLanguage($relData);
|
||||
$api->output($relData, $params, $outputXML, 'api');
|
||||
$api->output($relData, $params, $outputXML, $offset, 'api');
|
||||
break;
|
||||
|
||||
// Search movie releases.
|
||||
@@ -212,7 +216,7 @@ switch ($function) {
|
||||
);
|
||||
|
||||
$api->addLanguage($relData);
|
||||
$api->output($relData, $params, $outputXML, 'api');
|
||||
$api->output($relData, $params, $outputXML, $offset, 'api');
|
||||
break;
|
||||
|
||||
// Get NZB.
|
||||
@@ -250,7 +254,7 @@ switch ($function) {
|
||||
if ($data) {
|
||||
$relData[] = $data;
|
||||
}
|
||||
$api->output($relData, $params, $outputXML, 'api');
|
||||
$api->output($relData, $params, $outputXML, $offset, 'api');
|
||||
break;
|
||||
|
||||
// Get an NFO file for an individual release.
|
||||
@@ -282,7 +286,7 @@ switch ($function) {
|
||||
|
||||
// Capabilities request.
|
||||
case 'c':
|
||||
$api->output('', $params, $outputXML, 'caps');
|
||||
$api->output('', $params, $outputXML, $offset, 'caps');
|
||||
break;
|
||||
// Register request.
|
||||
case 'r':
|
||||
@@ -318,6 +322,6 @@ switch ($function) {
|
||||
$params['password'] = $password;
|
||||
$params['token'] = $userData['rsstoken'];
|
||||
|
||||
$api->output('', $params, true, 'reg');
|
||||
$api->output('', $params, true, $offset, 'reg');
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user