From e873d7cb52fb0d57512e00540e61e198f8d09fa1 Mon Sep 17 00:00:00 2001 From: Huong Nguyen Date: Tue, 16 Dec 2025 11:06:34 +0700 Subject: [PATCH] MDL-67733 repository_youtube: Use new Google API Client integration --- public/repository/youtube/lib.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/public/repository/youtube/lib.php b/public/repository/youtube/lib.php index 11aedf8555e..c498461d8a0 100644 --- a/public/repository/youtube/lib.php +++ b/public/repository/youtube/lib.php @@ -22,6 +22,10 @@ * @copyright 2010 Dongsheng Cai {@link http://dongsheng.org} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ + +use Google\Client; +use Google\Service\YouTube; + require_once($CFG->dirroot . '/repository/lib.php'); /** @@ -45,13 +49,13 @@ class repository_youtube extends repository { /** * Google Client. - * @var Google_Client + * @var Client */ private $client = null; /** * YouTube Service. - * @var Google_Service_YouTube + * @var YouTube */ private $service = null; @@ -90,11 +94,10 @@ class repository_youtube extends repository { global $CFG; if (!isset($this->service)) { - require_once($CFG->libdir . '/google/lib.php'); - $this->client = get_google_client(); + $this->client = new core\google_api_client(); $this->client->setDeveloperKey($this->apikey); - $this->client->setScopes(array(Google_Service_YouTube::YOUTUBE_READONLY)); - $this->service = new Google_Service_YouTube($this->client); + $this->client->setScopes([YouTube::YOUTUBE_READONLY]); + $this->service = new YouTube($this->client); } } @@ -228,7 +231,7 @@ class repository_youtube extends repository { 'source' => $source, ); } - } catch (Google_Service_Exception $e) { + } catch (\Google\Service\Exception $e) { // If we throw the google exception as-is, we may expose the apikey // to end users. The full message in the google exception includes // the apikey param, so we take just the part pertaining to the