endpoint = 'https://api.srgssr.ch/srgssr-play-subtitles/v2/'; parent::__construct(); } public function getUrl(string $urn): string { $response = Http::withHeaders($this->headers)->withQueryParameters([ 'episode' => $urn, ])->get($this->endpoint.'subtitles'); if($response->ok() && !empty($response[0]['url'])){ return $response[0]['url']; } return false; } public function getWebVTT(string $urn): ?string { $url = $this->getUrl($urn); $response = null; if($url){ $response = Http::get($url); } else { $altUrn = explode(":", $urn)[4]; $response = Http::get("https://subtitles.eai-general.aws.srf.ch/srf/{$altUrn}/episode/de/vod/vod.vtt"); } if($response && $response->successful()){ return $response->body(); } return false; } }