client->get($imdbCode, $cacheTags); if (true === $parseResults) { return $this->parse($results, $imdbCode); } return $results; } public function fetchEpisodeResults(string $imdbId, int $season, int $episode, bool $parseResults = true): array { $cacheTags = ['torrentio', 'tvshows', 'torrentio.tvshows', $imdbId, "torrentio.$imdbId", "$imdbId.$season", "torrentio.$imdbId.$season", "$imdbId.$season.$episode", "torrentio.$imdbId.$season.$episode"]; $results = $this->client->get("$imdbId:$season:$episode", $cacheTags); if (null === $results) { throw new TorrentioRateLimitException(); } if (true === $parseResults) { return $this->parse($results, $imdbId); } return $results; } public function parse(array $data, string $imdbId): array { $results = []; foreach ($data['streams'] as $stream) { if (!str_starts_with($stream['url'], "https")) { continue; } if ( array_key_exists('behaviorHints', $stream) && array_key_exists('bingeGroup', $stream['behaviorHints']) ) { $bingeGroup = $stream['behaviorHints']['bingeGroup']; } else { $bingeGroup = '-'; } $result = ResultFactory::map( $stream['url'], $stream['title'], $bingeGroup, $imdbId ); $results[] = $result; } return $results; } }