mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-28 17:01:16 +00:00
47 lines
1.6 KiB
PHP
Executable File
47 lines
1.6 KiB
PHP
Executable File
<?php
|
|
|
|
require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap/autoload.php';
|
|
|
|
use App\Services\TvProcessing\Providers\TvMazeProvider;
|
|
|
|
|
|
$tvmaze = new TvMazeProvider;
|
|
|
|
if (! empty($argv[1]) && is_numeric($argv[2]) && is_numeric($argv[3])) {
|
|
// Test if your TVMaze API configuration is 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];
|
|
|
|
// Search for a show
|
|
$series = $tvmaze->client->search((string) $argv[1]);
|
|
|
|
// Use the first show found (highest match) and get the requested season/episode from $argv
|
|
if ($series) {
|
|
echo PHP_EOL.cli()->info('Server Time: '.$serverTime).PHP_EOL;
|
|
print_r($series[0]);
|
|
|
|
if ($season > 0 and $episode > 0) {
|
|
$episodeObj = $tvmaze->client->getEpisodeByNumber($series[0]->id, $season, $episode);
|
|
if ($episodeObj) {
|
|
print_r($episodeObj);
|
|
}
|
|
} elseif ($season == 0 && $episode == 0) {
|
|
$episodeObj = $tvmaze->client->getEpisodesByShowID($series[0]->id);
|
|
if (is_array($episodeObj)) {
|
|
echo '*';
|
|
foreach ($episodeObj as $ep) {
|
|
print_r($ep);
|
|
}
|
|
}
|
|
} else {
|
|
exit(cli()->error('Invalid episode data returned from TVMaze API.'));
|
|
}
|
|
} else {
|
|
exit(cli()->error('Invalid show data returned from TVMaze API.'));
|
|
}
|
|
} else {
|
|
exit(cli()->error('Invalid arguments. This script requires a text string (show name) followed by a season and episode number.'));
|
|
}
|