diff --git a/Classes/Service/ApiService.php b/Classes/Service/ApiService.php index 3886dda..0aed074 100644 --- a/Classes/Service/ApiService.php +++ b/Classes/Service/ApiService.php @@ -82,17 +82,23 @@ public function youtube( /** * Grab the data of a publicly embeddable video hosted on vimeo * - * @param string $id The "id" of a video + * @param string|null $id The "id" of a video * @return array|null The data or null if there's an error - * @throws InfiniteRedirectionException|JsonException + * @throws InfiniteRedirectionException + * @throws JsonException */ - public function vimeo(string $id): ?array + public function vimeo(?string $id = null): ?array { if (!$id) { return null; } + if (!strpos($id, 'https://vimeo.com/')) { + $id = str_replace('https://vimeo.com/', '', $id); + } + $url = urlencode('https://vimeo.com/' . $id); + $data = $this->getJson( 'https://vimeo.com/api/oembed.json?width=2560&url=' . $url, 'video', diff --git a/Classes/Service/ParseIDService.php b/Classes/Service/ParseIDService.php index e6cd5bc..3db7914 100644 --- a/Classes/Service/ParseIDService.php +++ b/Classes/Service/ParseIDService.php @@ -69,6 +69,7 @@ public function platform($url = null): ?string * http://vimeo.com/album/2222222/video/11111111 * https://vimeo.com/11111111?param=test * http://vimeo.com/11111111?param=test + * https://vimeo.com/jonnitto/carbonplausible * * @param string|integer $url The URL or the plain id * @return string|null The video id extracted from url @@ -83,11 +84,7 @@ public function vimeo($url = null): ?string if (preg_match('%^https?:\/\/(?:www\.|player\.)?vimeo.com\/(?:channels\/(?:\w+\/)?|groups\/([^\/]*)\/videos\/|album\/(\d+)\/video\/|video\/|)(\d+)(?:$|\/|\?)(?:[?]?.*)$%im', $url, $regs)) { return (string) $regs[3]; } - // The ID has to start with a number - if (preg_match('/^[0-9]/', $url)) { - return (string) $url; - } - return null; + return str_replace('https://vimeo.com/', '', (string) $url); } /**