mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-29 01:08:56 +00:00
Fix some more API related issues
This commit is contained in:
+19
-12
@@ -719,7 +719,7 @@ class Releases
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function apiSearch($searchName, $groupName, $offset = 0, $limit = 1000, $maxAge = -1, array $excludedCats = [], array $cat = [-1], $minSize = 0): array
|
||||
public function apiSearch($searchName, $groupName, $offset = 0, $limit = 1000, $maxAge = -1, array $excludedCats = [], array $cat = [-1], $minSize = 0, array $excludedCategories = []): array
|
||||
{
|
||||
$searchOptions = [];
|
||||
if ($searchName !== -1) {
|
||||
@@ -741,7 +741,7 @@ class Releases
|
||||
($minSize > 0 ? sprintf('AND r.size >= %d', $minSize) : '')
|
||||
);
|
||||
$baseSql = sprintf(
|
||||
"SELECT r.searchname, r.guid, r.postdate, r.categories_id, r.size, r.totalpart, r.fromname, r.passwordstatus, r.grabs, r.comments, r.adddate, r.videos_id, r.tv_episodes_id, cp.title AS parent_category, c.title AS sub_category,
|
||||
"SELECT r.searchname, r.guid, r.postdate, r.categories_id, r.size, r.totalpart, r.fromname, r.passwordstatus, r.grabs, r.comments, r.adddate, r.videos_id, r.tv_episodes_id, m.imdbid, m.tmdbid, m.traktid, cp.title AS parent_category, c.title AS sub_category,
|
||||
CONCAT(cp.title, ' > ', c.title) AS category_name,
|
||||
%s AS category_ids,
|
||||
g.name AS group_name,
|
||||
@@ -751,6 +751,7 @@ class Releases
|
||||
FROM releases r
|
||||
LEFT OUTER JOIN videos v ON r.videos_id = v.id
|
||||
LEFT OUTER JOIN tv_episodes tve ON r.tv_episodes_id = tve.id
|
||||
LEFT JOIN movieinfo m ON m.id = r.movieinfo_id
|
||||
LEFT JOIN groups g ON g.id = r.groups_id
|
||||
LEFT JOIN categories c ON c.id = r.categories_id
|
||||
LEFT JOIN categories cp ON cp.id = c.parentid
|
||||
@@ -798,7 +799,7 @@ class Releases
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function tvSearch(array $siteIdArr = [], $series = '', $episode = '', $airdate = '', $offset = 0, $limit = 100, $name = '', array $cat = [-1], $maxAge = -1, $minSize = 0): array
|
||||
public function tvSearch(array $siteIdArr = [], $series = '', $episode = '', $airdate = '', $offset = 0, $limit = 100, $name = '', array $cat = [-1], $maxAge = -1, $minSize = 0, array $excludedCategories = []): array
|
||||
{
|
||||
$siteSQL = [];
|
||||
$showSql = '';
|
||||
@@ -861,7 +862,7 @@ class Releases
|
||||
'%s
|
||||
WHERE r.nzbstatus = %d
|
||||
AND r.passwordstatus %s
|
||||
%s %s %s %s %s',
|
||||
%s %s %s %s %s %s',
|
||||
($name !== '' ? $this->releaseSearch->getFullTextJoinString() : ''),
|
||||
NZB::NZB_ADDED,
|
||||
$this->showPasswords,
|
||||
@@ -869,7 +870,8 @@ class Releases
|
||||
($name !== '' ? $this->releaseSearch->getSearchSQL(['searchname' => $name]) : ''),
|
||||
Category::getCategorySearch($cat),
|
||||
($maxAge > 0 ? sprintf('AND r.postdate > NOW() - INTERVAL %d DAY', $maxAge) : ''),
|
||||
($minSize > 0 ? sprintf('AND r.size >= %d', $minSize) : '')
|
||||
($minSize > 0 ? sprintf('AND r.size >= %d', $minSize) : ''),
|
||||
! empty($excludedCategories) ? sprintf('AND r.categories_id NOT IN('.implode(',', $excludedCategories).')') : ''
|
||||
);
|
||||
$baseSql = sprintf(
|
||||
"SELECT r.searchname, r.guid, r.postdate, r.categories_id, r.size, r.totalpart, r.fromname, r.passwordstatus, r.grabs, r.comments, r.adddate, r.videos_id, r.tv_episodes_id,
|
||||
@@ -936,7 +938,7 @@ class Releases
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function apiTvSearch(array $siteIdArr = [], $series = '', $episode = '', $airdate = '', $offset = 0, $limit = 100, $name = '', array $cat = [-1], $maxAge = -1, $minSize = 0): array
|
||||
public function apiTvSearch(array $siteIdArr = [], $series = '', $episode = '', $airdate = '', $offset = 0, $limit = 100, $name = '', array $cat = [-1], $maxAge = -1, $minSize = 0, array $excludedCategories = []): array
|
||||
{
|
||||
$siteSQL = [];
|
||||
$showSql = '';
|
||||
@@ -998,7 +1000,7 @@ class Releases
|
||||
'%s
|
||||
WHERE r.nzbstatus = %d
|
||||
AND r.passwordstatus %s
|
||||
%s %s %s %s %s',
|
||||
%s %s %s %s %s %s',
|
||||
($name !== '' ? $this->releaseSearch->getFullTextJoinString() : ''),
|
||||
NZB::NZB_ADDED,
|
||||
$this->showPasswords,
|
||||
@@ -1006,7 +1008,8 @@ class Releases
|
||||
($name !== '' ? $this->releaseSearch->getSearchSQL(['searchname' => $name]) : ''),
|
||||
Category::getCategorySearch($cat),
|
||||
($maxAge > 0 ? sprintf('AND r.postdate > NOW() - INTERVAL %d DAY', $maxAge) : ''),
|
||||
($minSize > 0 ? sprintf('AND r.size >= %d', $minSize) : '')
|
||||
($minSize > 0 ? sprintf('AND r.size >= %d', $minSize) : ''),
|
||||
! empty($excludedCategories) ? sprintf('AND r.categories_id NOT IN('.implode(',', $excludedCategories).')') : ''
|
||||
);
|
||||
$baseSql = sprintf(
|
||||
"SELECT r.searchname, r.guid, r.postdate, r.categories_id, r.size, r.totalpart, r.fromname, r.passwordstatus, r.grabs, r.comments, r.adddate, r.tv_episodes_id,
|
||||
@@ -1061,18 +1064,19 @@ class Releases
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function animeSearch($aniDbID, $offset = 0, $limit = 100, $name = '', array $cat = [-1], $maxAge = -1): array
|
||||
public function animeSearch($aniDbID, $offset = 0, $limit = 100, $name = '', array $cat = [-1], $maxAge = -1, array $excludedCategories = []): array
|
||||
{
|
||||
$whereSql = sprintf(
|
||||
'%s
|
||||
WHERE r.passwordstatus %s
|
||||
AND r.nzbstatus = %d
|
||||
%s %s %s %s',
|
||||
%s %s %s %s %s',
|
||||
($name !== '' ? $this->releaseSearch->getFullTextJoinString() : ''),
|
||||
$this->showPasswords,
|
||||
NZB::NZB_ADDED,
|
||||
($aniDbID > -1 ? sprintf(' AND r.anidbid = %d ', $aniDbID) : ''),
|
||||
($name !== '' ? $this->releaseSearch->getSearchSQL(['searchname' => $name]) : ''),
|
||||
! empty($excludedCategories) ? sprintf('AND r.categories_id NOT IN('.implode(',', $excludedCategories).')') : '',
|
||||
Category::getCategorySearch($cat),
|
||||
($maxAge > 0 ? sprintf(' AND r.postdate > NOW() - INTERVAL %d DAY ', $maxAge) : '')
|
||||
);
|
||||
@@ -1126,16 +1130,18 @@ class Releases
|
||||
* @param int $maxAge
|
||||
* @param int $minSize
|
||||
*
|
||||
* @param array $excludedCategories
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function moviesSearch($imDbId = -1, $tmDbId = -1, $traktId = -1, $offset = 0, $limit = 100, $name = '', array $cat = [-1], $maxAge = -1, $minSize = 0): array
|
||||
public function moviesSearch($imDbId = -1, $tmDbId = -1, $traktId = -1, $offset = 0, $limit = 100, $name = '', array $cat = [-1], $maxAge = -1, $minSize = 0, array $excludedCategories = []): array
|
||||
{
|
||||
$whereSql = sprintf(
|
||||
'%s
|
||||
WHERE r.categories_id BETWEEN '.Category::MOVIE_ROOT.' AND '.Category::MOVIE_OTHER.'
|
||||
AND r.nzbstatus = %d
|
||||
AND r.passwordstatus %s
|
||||
%s %s %s %s %s %s',
|
||||
%s %s %s %s %s %s %s',
|
||||
$name !== '' ? $this->releaseSearch->getFullTextJoinString() : '',
|
||||
NZB::NZB_ADDED,
|
||||
$this->showPasswords,
|
||||
@@ -1143,6 +1149,7 @@ class Releases
|
||||
($imDbId !== -1 && is_numeric($imDbId)) ? sprintf(' AND m.imdbid = %d ', str_pad($imDbId, 7, '0', STR_PAD_LEFT)) : '',
|
||||
($tmDbId !== -1 && is_numeric($tmDbId)) ? sprintf(' AND m.tmdbid = %d ', $tmDbId) : '',
|
||||
($traktId !== -1 && is_numeric($traktId)) ? sprintf(' AND m.traktid = %d ', $traktId) : '',
|
||||
! empty($excludedCategories) ? sprintf('AND r.categories_id NOT IN('.implode(',', $excludedCategories).')') : '',
|
||||
Category::getCategorySearch($cat),
|
||||
$maxAge > 0 ? sprintf(' AND r.postdate > NOW() - INTERVAL %d DAY ', $maxAge) : '',
|
||||
$minSize > 0 ? sprintf('AND r.size >= %d', $minSize) : ''
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
2018-08-07 DariusIII
|
||||
* Fix: Fix some more API related issues
|
||||
* Chg: User can change only role allowed permissions (direct versus role based permissions)
|
||||
* Fix: Fix category exclusions for RSS feeds
|
||||
* Chg: Update ApiTransformer to handle null values
|
||||
|
||||
@@ -202,7 +202,8 @@ class ApiController extends BasePageController
|
||||
$request->input('q') ?? '',
|
||||
$api->categoryID(),
|
||||
$maxAge,
|
||||
$minSize
|
||||
$minSize,
|
||||
$catExclusions
|
||||
);
|
||||
|
||||
$api->addLanguage($relData);
|
||||
@@ -229,7 +230,8 @@ class ApiController extends BasePageController
|
||||
$request->input('q') ?? '',
|
||||
$api->categoryID(),
|
||||
$maxAge,
|
||||
$minSize
|
||||
$minSize,
|
||||
$catExclusions
|
||||
);
|
||||
|
||||
$api->addCoverURL(
|
||||
|
||||
@@ -69,6 +69,7 @@ class ApiV2Controller extends Controller
|
||||
$releases = new Releases();
|
||||
$minSize = $request->has('minsize') && $request->input('minsize') > 0 ? $request->input('minsize') : 0;
|
||||
$maxAge = $api->maxAge();
|
||||
$catExclusions = User::getCategoryExclusion($user->id);
|
||||
UserRequest::addApiRequest($user->id, $request->getRequestUri());
|
||||
|
||||
$imdbId = $request->has('imdbid') && ! empty($request->input('imdbid')) ? $request->input('imdbid') : -1;
|
||||
@@ -84,7 +85,8 @@ class ApiV2Controller extends Controller
|
||||
$request->input('id') ?? '',
|
||||
$api->categoryID(),
|
||||
$maxAge,
|
||||
$minSize
|
||||
$minSize,
|
||||
$catExclusions
|
||||
);
|
||||
|
||||
$response = [
|
||||
@@ -159,6 +161,7 @@ class ApiV2Controller extends Controller
|
||||
$user = Auth::user();
|
||||
$api = new API();
|
||||
$releases = new Releases();
|
||||
$catExclusions = User::getCategoryExclusion($user->id);
|
||||
$minSize = $request->has('minsize') && $request->input('minsize') > 0 ? $request->input('minsize') : 0;
|
||||
$api->verifyEmptyParameter('id');
|
||||
$api->verifyEmptyParameter('vid');
|
||||
@@ -202,7 +205,8 @@ class ApiV2Controller extends Controller
|
||||
$request->input('id') ?? '',
|
||||
$api->categoryID(),
|
||||
$maxAge,
|
||||
$minSize
|
||||
$minSize,
|
||||
$catExclusions
|
||||
);
|
||||
|
||||
$response = [
|
||||
|
||||
Reference in New Issue
Block a user