From 922998690ab988d6d2fcaadcdd69ce1aa4d54c70 Mon Sep 17 00:00:00 2001 From: Ethan Finlay Date: Mon, 19 Dec 2022 12:38:09 -0500 Subject: [PATCH] adding concept of provider name --- src/Rule/VideoScan.php | 4 ++-- src/Video/Kaltura.php | 5 +++++ src/Video/Vimeo.php | 5 +++++ src/Video/Youtube.php | 5 +++++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/Rule/VideoScan.php b/src/Rule/VideoScan.php index 17be85e..d61a3e7 100644 --- a/src/Rule/VideoScan.php +++ b/src/Rule/VideoScan.php @@ -42,12 +42,12 @@ public function check() $captions = $this->getCaptionData($url, $provider); if (self::NO_API_CREDITS === $captions) { - $this->setError('Out of Youtube API credits'); + $this->setError("{$provider->getName()} videos cannot be scanned at this time. Please try again at a later time."); continue; } if (self::FAILED_CONNECTION === $captions) { - $this->setError('Failed provider API connection.'); + $this->setError("Failed {$provider->getName()} API connection."); continue; } diff --git a/src/Video/Kaltura.php b/src/Video/Kaltura.php index 8a7c98a..73e24d2 100644 --- a/src/Video/Kaltura.php +++ b/src/Video/Kaltura.php @@ -15,6 +15,7 @@ class Kaltura { const KALTURA_FAILED_CONNECTION = -1; const KALTURA_FAIL = 0; const KALTURA_SUCCESS = 1; + const PROVIDER_NAME = 'Kaltura'; private $client; private $language; @@ -127,4 +128,8 @@ function getVideoData($link_url) return !isset($result->objects) ? $result->objects : self::KALTURA_FAILED_CONNECTION; } + public function getName() { + return self::PROVIDER_NAME; + } + } \ No newline at end of file diff --git a/src/Video/Vimeo.php b/src/Video/Vimeo.php index 6e4a6b0..cf90786 100644 --- a/src/Video/Vimeo.php +++ b/src/Video/Vimeo.php @@ -9,6 +9,7 @@ class Vimeo const VIMEO_FAILED_CONNECTION = -1; const VIMEO_FAIL = 0; const VIMEO_SUCCESS = 1; + const PROVIDER_NAME = "Vimeo"; private $regex = '@vimeo\.com/[^0-9]*([0-9]{7,9})@i'; private $search_url = 'https://api.vimeo.com/videos/'; @@ -94,4 +95,8 @@ function getVideoData($link_url) return isset($result->data) ? $result->data : self::VIMEO_FAILED_CONNECTION; } + + public function getName() { + return self::PROVIDER_NAME; + } } diff --git a/src/Video/Youtube.php b/src/Video/Youtube.php index abb17e4..dfa5ec7 100644 --- a/src/Video/Youtube.php +++ b/src/Video/Youtube.php @@ -10,6 +10,7 @@ class Youtube const YOUTUBE_FAIL = 0; const YOUTUBE_SUCCESS = 1; const YOUTUBE_NO_CREDITS = -2; + const PROVIDER_NAME = 'Youtube'; private $regex = array( '@youtube\.com/embed/([^"\&\? ]+)@i', @@ -146,4 +147,8 @@ function getVideoData($link_url) return isset($result->items) ? $result->items : self::YOUTUBE_FAILED_REQUEST; } + + public function getName() { + return self::PROVIDER_NAME; + } }