Remove page_limit from RottenTomato.php, it is already at 16 by default. Small fixes in scripts.

This commit is contained in:
Darko
2015-05-18 12:18:15 +02:00
parent 70fef81f56
commit 9c5c965d9f
7 changed files with 35 additions and 63 deletions
+3 -3
View File
@@ -40,14 +40,14 @@ echo "\nUsage: php import.php [path(string)] [usefilename(true/false)] [dupechec
$filestoprocess = glob($path . "*.{nzb,nzb.gz}", GLOB_BRACE);
$items = count($filestoprocess);
$matches = array();
$matches = [];
$digits = preg_match_all("/[0-9]/", count($filestoprocess), $matches);
$dupepath = $path . "dupe/";
$nogrouppath = $path . "nogroup/";
$importedpath = $path . "imported/";
$noregexpath = $path . "noregex/";
$errorpath = $path . "error/";
$missinggroups = array();
$missinggroups = [];
echo "[Importing " . $items . " *.nzb file" . ($items != 1 ? "s" : "") . " from " . $path . ($usefilename ? " U" : " Not u") . "sing filename, " . ($dupecheck ? "C" : "Not c") . "hecking for duplicates" . ($categoryoverride != -1 ? ", Forcing category to " . $categoryoverride : "") . "]\n\n";
foreach ($filestoprocess as $nzbFile) {
@@ -124,7 +124,7 @@ foreach ($filestoprocess as $nzbFile) {
$binaryId = 0;
$groupRegexes = $releaseRegex->getForGroup($groupName);
foreach ($nzbInfo->nzb as $postFile) {
$regexMatches = array();
$regexMatches = [];
foreach ($groupRegexes as $groupRegex) {
$regexCheck = $releaseRegex->performMatch($groupRegex, $postFile["subject"]);
@@ -1,5 +1,4 @@
<?php
require_once NN_LIBS . 'AmazonProductAPI.php';
use newznab\db\DB;
use newznab\libraries\ApaiIO\Configuration\GenericConfiguration;
@@ -279,10 +279,10 @@ class NZBImport
}
// Make a fake message array to use to check the blacklist.
$msg = array("Subject" => (string) $file->attributes()->subject, "From" => (string) $file->attributes()->poster, "Message-ID" => "");
$msg = ["Subject" => (string) $file->attributes()->subject, "From" => (string) $file->attributes()->poster, "Message-ID" => ""];
// Get the group names, groupid, check if it's blacklisted.
$groupArr = array();
$groupArr = [];
foreach ($file->groups->group as $group) {
$group = (string) $group;
@@ -329,7 +329,7 @@ class NZBImport
// Try to insert the NZB details into the DB.
return $this->insertNZB(
array(
[
'subject' => $firstName,
'useFName' => $useNzbName,
'postDate' => (empty($postDate) ? date("Y-m-d H:i:s") : $postDate),
@@ -338,7 +338,7 @@ class NZBImport
'groupName' => $groupName,
'totalFiles' => $totalFiles,
'totalSize' => $totalSize
)
]
);
}
@@ -77,15 +77,12 @@ class RottenTomato
* Movie search
* @throws Exception
* @param string $query search term
* @param int $pageLimit results per page
* @param int $page current page
* @return array results
*/
public function movieSearch($query, $pageLimit = 20, $page = 0) {
$params = array();
public function movieSearch($query, $page = 0) {
$params = [];
$params['q'] = $query;
if ($pageLimit)
$params['page_limit'] .= $pageLimit;
if ($page)
$params['page'] = $page;
$result = $this->getResource(self::ROTTEN_TOMATOES_API_MOVIE_SEARCH, $params);
@@ -98,16 +95,13 @@ class RottenTomato
* @throws Exception
* @param int $id rotten tomatoes id
* @param string $reviewType review type
* @param int $pageLimit results per page
* @param int $page current page
* @return array results
*/
public function getMovieReviews($id, $reviewType = self::REVIEW_TYPE_ALL, $pageLimit = 20, $page = 0) {
public function getMovieReviews($id, $reviewType = self::REVIEW_TYPE_ALL, $page = 0) {
$url = sprintf(self::ROTTEN_TOMATOES_API_MOVIE_REVIEWS, $id);
$params = array();
$params = [];
$params['review_type'] = $reviewType;
if ($pageLimit)
$params['page_limit'] .= $pageLimit;
if ($page)
$params['page'] = $page;
$result = $this->getResource($url, $params);
@@ -144,14 +138,11 @@ class RottenTomato
/**
* Get new DVD releases
* @throws Exception
* @param int $pageLimit results per page
* @param int $page current page
* @return array results
*/
public function getNewDvdReleases($pageLimit = 20, $page = 0) {
$params = array();
if ($pageLimit)
$params['page_limit'] .= $pageLimit;
public function getNewDvdReleases($page = 0) {
$params = [];
if ($page)
$params['page'] = $page;
$result = $this->getResource(self::ROTTEN_TOMATOES_API_NEW_RELEASE_DVDS, $params);
@@ -162,14 +153,11 @@ class RottenTomato
/**
* Get movies that are coming soon
* @throws Exception
* @param int $pageLimit results per page
* @param int $page current page
* @return array results
*/
public function getUpcomingMovies($pageLimit = 20, $page = 0) {
$params = array();
if ($pageLimit)
$params['page_limit'] .= $pageLimit;
public function getUpcomingMovies($page = 0) {
$params = [];
if ($page)
$params['page'] = $page;
$result = $this->getResource(self::ROTTEN_TOMATOES_API_UPCOMING_MOVIES, $params);
@@ -180,14 +168,11 @@ class RottenTomato
/**
* Get movies currently in theaters
* @throws Exception
* @param int $pageLimit results per page
* @param int $page current page
* @return array results
*/
public function getMoviesInTheaters($pageLimit = 5, $page = 0) {
$params = array();
if ($pageLimit)
$params['page_limit'] .= $pageLimit;
public function getMoviesInTheaters($page = 0) {
$params = [];
if ($page)
$params['page'] = $page;
$result = $this->getResource(self::ROTTEN_TOMATOES_API_IN_THEATERS, $params);
@@ -198,14 +183,10 @@ class RottenTomato
/**
* Get movies opening
* @throws Exception
* @param int $pageLimit number of results
* @return array results
*/
public function getOpeningMovies($pageLimit = 20) {
$params = array();
if ($pageLimit)
$params['page_limit'] .= $pageLimit;
$result = $this->getResource(self::ROTTEN_TOMATOES_API_OPENING_MOVIES, $params);
public function getOpeningMovies() {
$result = $this->getResource(self::ROTTEN_TOMATOES_API_OPENING_MOVIES);
if(!isset($result['movies']) && !empty($result['movies']))
throw new Exception("No results");
return $result;
@@ -213,14 +194,10 @@ class RottenTomato
/**
* Get top box office results
* @throws Exception
* @param int $pageLimit number of results
* @return array results
*/
public function getMoviesBoxOffice($pageLimit = 20) {
$params = array();
if ($pageLimit)
$params['page_limit'] .= $pageLimit;
$result = $this->getResource(self::ROTTEN_TOMATOES_API_BOX_OFFICE, $params);
public function getMoviesBoxOffice() {
$result = $this->getResource(self::ROTTEN_TOMATOES_API_BOX_OFFICE);
if(!isset($result['movies']) && !empty($result['movies']))
throw new Exception("No results");
return $result;
@@ -228,14 +205,10 @@ class RottenTomato
/**
* Get top DVD rentals
* @throws Exception
* @param int $pageLimit number of results
* @return array results
*/
public function getDvdTopRentals($pageLimit = 20) {
$params = array();
if ($pageLimit)
$params['page_limit'] .= $pageLimit;
$result = $this->getResource(self::ROTTEN_TOMATOES_API_DVD_TOP_RENTALS, $params);
public function getDvdTopRentals() {
$result = $this->getResource(self::ROTTEN_TOMATOES_API_DVD_TOP_RENTALS);
if(!isset($result['movies']) && !empty($result['movies']))
throw new Exception("No results");
return $result;
@@ -279,7 +252,7 @@ class RottenTomato
* @param array $params parameters (key/value pairs) for query string
* @return array decoded json response
*/
protected function getResource($url, $params = array()) {
protected function getResource($url, $params = []) {
$params['apikey'] = $this->apiKey;
$params['country'] = $this->country;
$queryString = http_build_query($params);
@@ -316,10 +289,10 @@ class RottenTomato
* @return string|boolean result
*/
protected function httpRequestFopen($url){
$http = array();
$http = [];
$http['method'] = 'GET';
$http['timeout'] = $this->timeoutSeconds;
$response = @fopen($url, 'r', false, stream_context_create(array('http' => $http)));
$response = @fopen($url, 'r', false, stream_context_create(['http' => $http]));
$result = false;
if ($response)
$result = $response;
@@ -582,9 +582,9 @@ class SpotNab {
// Fetch some date ranges
$last_month = date("Y-m-d",strtotime(
date("Y-m-d", mktime()) . " - 30 day"));
date("Y-m-d", time()) . " - 30 day"));
$last_year = date('Y-m-d',strtotime(
date("Y-m-d", mktime()) . " - 365 day"));
date("Y-m-d", time()) . " - 365 day"));
// Header
$message = array(
@@ -968,7 +968,7 @@ class SpotNab {
}
// Update DB With Global Identifer
$ures = $db->queryExec(sprintf("UPDATE releases SET gid = '%s' WHERE id = %d", $gid, $r['id']));
$ures = $db->queryExec(sprintf("UPDATE releases SET gid = %s WHERE id = %d", $db->escapeString($gid), $r['id']));
if($ures->rowCount() == 0){
printf("\nPostPrc : Failed to update: %s\n", $r['name']);
}
@@ -11,9 +11,9 @@ use newznab\db\DB;
class ForkingImportNZB extends Forking
{
/**
*
* @param array $options
*/
public function __construct(array $options = array())
public function __construct(array $options = [])
{
$defaults = [
'settings' => new DB(),
+4 -4
View File
@@ -23,13 +23,13 @@ if (count($argv) !== 6) {
if (!is_dir($argv[1])) {
exit('Error: arg1 must be a path (you might not have read access to this path)' . $n);
}
if (!in_array($argv[2], array('true', 'false'))) {
if (!in_array($argv[2], ['true', 'false'])) {
exit('Error: arg2 must be true or false' . $n);
}
if (!in_array($argv[3], array('true', 'false'))) {
if (!in_array($argv[3], ['true', 'false'])) {
exit('Error: arg3 must be true or false' . $n);
}
if (!in_array($argv[4], array('true', 'false'))) {
if (!in_array($argv[4], ['true', 'false'])) {
exit('Error: arg4 must be true or false' . $n);
}
if (!is_numeric($argv[5])) {
@@ -54,7 +54,7 @@ $files = new \RegexIterator(
);
$i = 1;
$nzbFiles = array();
$nzbFiles = [];
foreach ($files as $file) {
$nzbFiles[] = $file[0];
if ($i++ >= $argv[5]) {