diff --git a/Changelog b/Changelog
index cf67892e1..76ae7c083 100755
--- a/Changelog
+++ b/Changelog
@@ -1,4 +1,5 @@
2015-10-23 DariusIII
+ Upd: Update api, Releases, anime etc
Chg: Add missing genres and groups output to api
Chg: Add the fixes from nZEDb/dev-tv branch
Chg: Revert the failed releases query in search
diff --git a/newznab/Capabilities.php b/newznab/Capabilities.php
new file mode 100644
index 000000000..5eb7bcf16
--- /dev/null
+++ b/newznab/Capabilities.php
@@ -0,0 +1,75 @@
+ null,
+ ];
+ $options += $defaults;
+ $this->pdo = ($options['Settings'] instanceof Settings ? $options['Settings'] : new Settings());
+ }
+
+ /**
+ * Collect and return various capability information for usage in API
+ *
+ * @return array
+ */
+ public function getForMenu()
+ {
+ $serverroot = '';
+ $https = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? true : false);
+
+ if (isset($_SERVER['SERVER_NAME'])) {
+ $serverroot = (
+ ($https === true ? 'https://' : 'http://') . $_SERVER['SERVER_NAME'] .
+ (($_SERVER['SERVER_PORT'] != '80' && $_SERVER['SERVER_PORT'] != '443') ? ':' . $_SERVER['SERVER_PORT'] : '') .
+ WWW_TOP . '/'
+ );
+ }
+
+ return [
+ 'server' => [
+ 'appversion' => (new Versions())->getTagVersion(),
+ 'version' => '0.1',
+ 'title' => $this->pdo->getSetting('title'),
+ 'strapline' => $this->pdo->getSetting('strapline'),
+ 'email' => $this->pdo->getSetting('email'),
+ 'url' => $serverroot,
+ 'image' => $serverroot . 'themes_shared/images/logo.png'
+ ],
+ 'limits' => [
+ 'max' => 100,
+ 'default' => 100
+ ],
+ 'registration' => [
+ 'available' => 'yes',
+ 'open' => $this->pdo->getSetting('registerstatus') == 0 ? 'yes' : 'no'
+ ],
+ 'searching' => [
+ ['search' => 'yes'],
+ ['supportedParams' => 'q'],
+ ['tv-search' => 'yes'],
+ ['supportedParams' => 'q, vid, tvdbid, traktid, rid, tvmazeid, imdbid, tmdbid, season, ep'],
+ ['movie-search' => 'yes'],
+ ['supportedParams' => 'q'],
+ ['audio-search' => 'yes']
+ ]
+ ];
+ }
+}
diff --git a/newznab/Releases.php b/newznab/Releases.php
index 1a859cc7c..df7ad7843 100755
--- a/newznab/Releases.php
+++ b/newznab/Releases.php
@@ -1293,20 +1293,20 @@ class Releases
}
/**
- * @param int $rageID
+ * @param $videoId
*
- * @return int
+ * @return bool|\PDOStatement
*/
- public function removeRageIdFromReleases($rageID)
+ public function removeVideoIdFromReleases($videoId)
{
- $res = $this->pdo->queryOneRow(
- sprintf('SELECT COUNT(r.id) AS num FROM releases r WHERE rageid = %d', $rageID)
+ return $this->pdo->queryExec(
+ sprintf('
+ UPDATE releases
+ SET videos_id = 0, tv_episodes_id = 0
+ WHERE videos_id = %d',
+ $videoId
+ )
);
- $this->pdo->queryExec(
- sprintf('UPDATE releases SET rageid = -1, seriesfull = NULL, season = NULL, episode = NULL WHERE rageid = %d', $rageID)
- );
-
- return ($res === false ? 0 : $res['num']);
}
/**
diff --git a/www/admin/show-remove.php b/www/admin/show-remove.php
index f86344db1..3f3e9c0cf 100755
--- a/www/admin/show-remove.php
+++ b/www/admin/show-remove.php
@@ -9,7 +9,7 @@ $releases = new Releases(['Settings' => $page->settings]);
$success = false;
if (isset($_GET["id"])) {
- $success = $releases->removeRageIdFromReleases($_GET["id"]);
+ $success = $releases->removeVideoIdFromReleases($_GET["id"]);
$page->smarty->assign('videoid', $_GET["id"]);
}
diff --git a/www/pages/anime.php b/www/pages/anime.php
index 0eca88eb4..e91a1de1b 100755
--- a/www/pages/anime.php
+++ b/www/pages/anime.php
@@ -13,7 +13,7 @@ $AniDB = new AniDB(['Settings' => $page->settings]);
if (isset($_GET['id']) && ctype_digit($_GET['id'])) {
# force the category to 5070 as it should be for anime, as $catarray was NULL and we know the category for sure for anime
- $releases = $Releases->searchbyAnidbId($_GET['id'], 0, 1000, '', array('5070'), -1);
+ $releases = $Releases->searchbyAnidbId($_GET['id'], '', 0, 1000, '', ['5070'], -1);
$anidb = $AniDB->getAnimeInfo($_GET['id']);
if (!$releases && !$anidb) {
diff --git a/www/pages/api.php b/www/pages/api.php
index 30e710580..5cfb8dede 100644
--- a/www/pages/api.php
+++ b/www/pages/api.php
@@ -6,6 +6,7 @@ use newznab\Releases;
use newznab\Category;
use newznab\Groups;
use newznab\Genres;
+use newznab\Capabilities;
$rc = new ReleaseComments;
$groups = new Groups();
@@ -445,7 +446,21 @@ switch ($function) {
$genre = $genres->getGenres('', true);
$page->smarty->assign('genres', $genre);
header('Content-type: text/xml');
- echo $page->smarty->fetch('apicaps.tpl');
+ if ($outputXML) { //use apicaps.tpl if xml is requested
+ $response = $page->smarty->fetch('apicaps.tpl');
+ header('Content-type: text/xml');
+ header('Content-Length: ' . strlen($response) );
+ echo $response;
+ } else { //otherwise construct array of capabilities and categories
+ //get capabilities
+ $caps = (new Capabilities(['Settings' => $page->settings]))->getForMenu();
+ $caps['categories'] = $cats;
+ //use json_encode
+ $response = encodeAsJSON($caps);
+ header('Content-type: application/json');
+ header('Content-Length: ' . strlen($response) );
+ echo $response;
+ }
break;
// Register request.
diff --git a/www/themes/omicron/templates/frontend/apicaps.tpl b/www/themes/omicron/templates/frontend/apicaps.tpl
index 3be9a5a85..8cdd2a482 100644
--- a/www/themes/omicron/templates/frontend/apicaps.tpl
+++ b/www/themes/omicron/templates/frontend/apicaps.tpl
@@ -6,9 +6,9 @@
-
-
-
+
+
+