diff --git a/misc/testing/Tests/testnewamazon.php b/misc/testing/Tests/test_amazon_API.php similarity index 100% rename from misc/testing/Tests/testnewamazon.php rename to misc/testing/Tests/test_amazon_API.php diff --git a/misc/testing/Tests/test_cache_server.php b/misc/testing/Tests/test_cache_server.php new file mode 100755 index 000000000..3bcae8244 --- /dev/null +++ b/misc/testing/Tests/test_cache_server.php @@ -0,0 +1,13 @@ +getMessage() . PHP_EOL); +} + +print_r($cache->serverStatistics()); diff --git a/misc/testing/Tests/test_giantbomb_API.php b/misc/testing/Tests/test_giantbomb_API.php new file mode 100755 index 000000000..37c419a18 --- /dev/null +++ b/misc/testing/Tests/test_giantbomb_API.php @@ -0,0 +1,45 @@ +getSetting('giantbombkey'); +$cli = new ColorCLI(); +$obj = new GiantBomb($giantbombkey, $resp = "json"); + +$searchgame = "South Park The Stick of Truth"; +$resultsfound = 0; + +$e = null; +try { + $fields = array( + "deck", "description", "original_game_rating", "api_detail_url", "image", "genres", "name", + "platforms", "publishers", "original_release_date", "reviews", "site_detail_url" + ); + $result = $obj->search($searchgame, $fields, 1); + $result = json_decode(json_encode($result), true); + if ($result['number_of_total_results'] != 0) { + $resultsfound = count($result['results']); + for ($i = 0; $i <= $resultsfound; $i++) { + similar_text($result['results'][$i]['name'], $searchgame, $p); + if ($p > 90) { + $result = $result['results'][$i]; + break; + } + } + } +} catch (\Exception $e) { + $result = false; +} + +if ($result !== false && !empty($result)) { + print_r($result); + exit($cli->header("\nLooks like it is working alright.")); +} else { + print_r($e); + exit($cli->error("\nThere was a problem attempting to query giantbomb. Maybe your key is wrong, or you are being throttled.\n")); +} diff --git a/misc/testing/Tests/test_nntp_server.php b/misc/testing/Tests/test_nntp_server.php new file mode 100755 index 000000000..2505e757c --- /dev/null +++ b/misc/testing/Tests/test_nntp_server.php @@ -0,0 +1,36 @@ +error("\nTest your nntp connection, get group information and postdate for specific article.\n\n" + . "php $argv[0] alt.binaries.teevee 595751142 ...: To test nntp on alt.binaries.teevee with artivle 595751142.\n")); +} +$nntp = new NNTP(); +if ($nntp->doConnect() !== true) { + exit(); +} + +$first = $argv[2]; +$group = $argv[1]; + +// Select a group. +$groupArr = $nntp->selectGroup($group); +print_r($groupArr); + +// Insert actual local part numbers here. +$msg = $nntp->getXOVER($first . '-' . $first); + +// Print out the array of headers. +print_r($msg); + +// get postdate for an article +$binaries = new Binaries(['NNTP' => $nntp]); +$newdate = $binaries->postdate($first, $groupArr); +echo $cli->primary("The posted date for " . $group . ", article " . $first . " is " . date('Y-m-d H:i:s', $newdate)); diff --git a/misc/testing/Tests/test_rottentomato_API.php b/misc/testing/Tests/test_rottentomato_API.php new file mode 100755 index 000000000..dc28cf2e2 --- /dev/null +++ b/misc/testing/Tests/test_rottentomato_API.php @@ -0,0 +1,18 @@ +getSetting('rottentomatokey'); +if (isset($rtkey)) { + $rt = new RottenTomato($rtkey); + print_r(json_decode($rt->searchMovie("inception"))); + $url = (RottenTomato::API_URL . "movies.json?apikey=" . $rt->getApiKey() . "&q=inception&page_limit=50"); + exit($cli->header("\nIf nothing was displayed above then there might be an error. If so, go to the following url: $url\n")); +} else { + exit($cli->error("\nNo rotten tomato key.\n")); +} diff --git a/misc/testing/Tests/test_tmdb_API.php b/misc/testing/Tests/test_tmdb_API.php index ccae607f3..222b1a26d 100755 --- a/misc/testing/Tests/test_tmdb_API.php +++ b/misc/testing/Tests/test_tmdb_API.php @@ -19,7 +19,7 @@ if (!empty($argv[1]) && is_numeric($argv[2]) && is_numeric($argv[3])) { $series = $tmdb->client->searchTVShow((string)$argv[1]); // Use the first show found (highest match) and get the requested season/episode from $argv - if ($series) { + if (!empty($series)) { $seriesAppends = $tmdb->client->getTVShow($series[0]->_data['id'], 'append_to_response=alternative_titles,external_ids'); if ($seriesAppends) { $series[0]->_data['networks'] = $seriesAppends->_data['networks']; diff --git a/misc/testing/Tests/test_tvdb_API.php b/misc/testing/Tests/test_tvdb_API.php index 4e2102626..0fe067201 100755 --- a/misc/testing/Tests/test_tvdb_API.php +++ b/misc/testing/Tests/test_tvdb_API.php @@ -7,13 +7,14 @@ use newznab\processing\tv\TVDB; $c = new newznab\ColorCLI(); $tvdb = new TVDB(); -if (!empty($argv[1]) && is_numeric($argv[2]) && is_numeric($argv[3])) { +if (isset($argv[1]) && !empty($argv[1]) && isset($argv[2]) && is_numeric($argv[2]) && isset($argv[3]) && is_numeric($argv[3])) { // Test if your TvDB API key and configuration are working // If it works you should get a var dumped array of the show/season/episode entered $season = (int)$argv[2]; $episode = (int)$argv[3]; + $day = (isset($argv[4]) && is_numeric($argv[4]) ? $argv[4] : ''); $serverTime = $tvdb->client->getServerTime(); @@ -26,18 +27,23 @@ if (!empty($argv[1]) && is_numeric($argv[2]) && is_numeric($argv[3])) { echo PHP_EOL . $c->info("Server Time: " . $serverTime) . PHP_EOL; print_r($series[0]); - if ($season > 0 AND $episode > 0) { + if ($season > 0 && $episode > 0 && $day === '') { $episodeObj = $tvdb->client->getEpisode($series[0]->id, $season, $episode, 'en'); if ($episodeObj) { print_r($episodeObj); } } else if ($season == 0 && $episode == 0) { $episodeObj = $tvdb->client->getSerieEpisodes($series[0]->id, 'en'); - if ($episodeObj['episodes'] instanceof \Traversable) { + if (is_array($episodeObj['episodes'])) { foreach ($episodeObj['episodes'] AS $ep) { print_r($ep); } } + } else if (preg_match('#^(19|20)\d{2}\/\d{2}\/\d{2}$#', $season . '/' . $episode . '/' . $day, $airdate)) { + $episodeObj = $tvdb->client->getEpisodeByAirDate($series[0]->id, (string)$airdate[0], 'en'); + if ($episodeObj) { + print_r($episodeObj); + } } else { exit($c->error("Invalid episode data returned from TVDB API.")); } @@ -47,5 +53,7 @@ if (!empty($argv[1]) && is_numeric($argv[2]) && is_numeric($argv[3])) { } } else { - exit($c->error("Invalid arguments. This script requires a text string (show name) followed by a season and episode number.")); + exit($c->error("Invalid arguments. This script requires a text string (show name) followed by a season and episode number." . PHP_EOL . + "You can also optionally supply 'YYYY' 'MM' 'DD' arguments instead of season/episode for an airdate lookup.") + ); }