diff --git a/Command/VideoUpdateStatusCommand.php b/Command/VideoUpdateStatusCommand.php index bc4a5b7..87d8ef5 100644 --- a/Command/VideoUpdateStatusCommand.php +++ b/Command/VideoUpdateStatusCommand.php @@ -8,6 +8,7 @@ use MongoDB\BSON\ObjectId; use Psr\Log\LoggerInterface; use Pumukit\SchemaBundle\Document\MultimediaObject; +use Pumukit\YoutubeBundle\Document\Error; use Pumukit\YoutubeBundle\Document\Youtube; use Pumukit\YoutubeBundle\Services\VideoListService; use Symfony\Component\Console\Command\Command; @@ -81,7 +82,7 @@ protected function updateVideoStatusInYoutube($youtubeDocuments, OutputInterface if (!$youtube->getYoutubeId()) { $errorLog = sprintf('YouTube document %s does not have a Youtube ID variable set.', $youtube->getId()); $youtube->setStatus(Youtube::STATUS_ERROR); - $error = \Pumukit\YoutubeBundle\Document\Error::create( + $error = Error::create( 'pumukit.youtubeIdNotFound', $errorLog, new \DateTime(), @@ -98,7 +99,7 @@ protected function updateVideoStatusInYoutube($youtubeDocuments, OutputInterface if (!$multimediaObject instanceof MultimediaObject) { $errorLog = sprintf("No multimedia object for YouTube document %s\n", $youtube->getId()); $youtube->setStatus(Youtube::STATUS_ERROR); - $error = \Pumukit\YoutubeBundle\Document\Error::create( + $error = Error::create( 'pumukit.videoNotFound', $errorLog, new \DateTime(), diff --git a/Services/CaptionsDeleteService.php b/Services/CaptionsDeleteService.php index f98a8a1..5fbee50 100644 --- a/Services/CaptionsDeleteService.php +++ b/Services/CaptionsDeleteService.php @@ -7,6 +7,7 @@ use Doctrine\ODM\MongoDB\DocumentManager; use Psr\Log\LoggerInterface; use Pumukit\SchemaBundle\Document\Tag; +use Pumukit\YoutubeBundle\Document\Error; use Pumukit\YoutubeBundle\Document\Youtube; class CaptionsDeleteService extends GoogleCaptionService @@ -35,7 +36,7 @@ public function deleteCaption(Tag $account, Youtube $youtube, array $captionsId) $errorLog = sprintf('[YouTube] Remove caption for Youtube document %s failed. Error: %s', $youtube->getId(), $exception->getMessage()); $this->logger->error($errorLog); $error = json_decode($exception->getMessage(), true, 512, JSON_THROW_ON_ERROR); - $error = \Pumukit\YoutubeBundle\Document\Error::create( + $error = Error::create( $error['error']['errors'][0]['reason'], $error['error']['errors'][0]['message'], new \DateTime(), diff --git a/Services/CaptionsInsertService.php b/Services/CaptionsInsertService.php index 35f433b..ae83067 100644 --- a/Services/CaptionsInsertService.php +++ b/Services/CaptionsInsertService.php @@ -10,6 +10,7 @@ use Pumukit\SchemaBundle\Document\MultimediaObject; use Pumukit\SchemaBundle\Document\Tag; use Pumukit\YoutubeBundle\Document\Caption; +use Pumukit\YoutubeBundle\Document\Error; use Pumukit\YoutubeBundle\Document\Youtube; class CaptionsInsertService extends GoogleCaptionService @@ -56,7 +57,7 @@ public function uploadCaption(Youtube $youtube, MultimediaObject $multimediaObje $youtube->removeCaptionUpdateError(); } catch (\Exception $exception) { $error = json_decode($exception->getMessage(), true, 512, JSON_THROW_ON_ERROR); - $error = \Pumukit\YoutubeBundle\Document\Error::create( + $error = Error::create( $error['error']['errors'][0]['reason'], $error['error']['errors'][0]['message'], new \DateTime(), diff --git a/Services/CaptionsListService.php b/Services/CaptionsListService.php index 292a9e6..476464e 100644 --- a/Services/CaptionsListService.php +++ b/Services/CaptionsListService.php @@ -4,16 +4,17 @@ namespace Pumukit\YoutubeBundle\Services; +use Google\Service\YouTube\CaptionListResponse; use Pumukit\SchemaBundle\Document\Tag; class CaptionsListService extends GoogleAccountService { - public function findAll(Tag $account, string $videoId): \Google\Service\YouTube\CaptionListResponse + public function findAll(Tag $account, string $videoId): CaptionListResponse { return $this->list($account, $videoId); } - private function list(Tag $account, string $videoId): \Google\Service\YouTube\CaptionListResponse + private function list(Tag $account, string $videoId): CaptionListResponse { $service = $this->googleServiceFromAccount($account); diff --git a/Services/PlaylistItemInsertService.php b/Services/PlaylistItemInsertService.php index b409816..5805765 100644 --- a/Services/PlaylistItemInsertService.php +++ b/Services/PlaylistItemInsertService.php @@ -9,6 +9,7 @@ use Psr\Log\LoggerInterface; use Pumukit\SchemaBundle\Document\MultimediaObject; use Pumukit\SchemaBundle\Document\Tag; +use Pumukit\YoutubeBundle\Document\Error; use Pumukit\YoutubeBundle\Document\Youtube; use Pumukit\YoutubeBundle\PumukitYoutubeBundle; @@ -105,7 +106,7 @@ private function fixPlaylistsForMultimediaObject(MultimediaObject $multimediaObj $response = $this->playlistItemDeleteService->deleteOnePlaylist($account, $playlistRel); } catch (\Exception $exception) { $error = json_decode($exception->getMessage(), true, 512, JSON_THROW_ON_ERROR); - $error = \Pumukit\YoutubeBundle\Document\Error::create( + $error = Error::create( $error['error']['errors'][0]['reason'], $error['error']['errors'][0]['message'], new \DateTime(), @@ -132,7 +133,7 @@ private function fixPlaylistsForMultimediaObject(MultimediaObject $multimediaObj $youtubeDocument->removePlaylistUpdateError(); } catch (\Exception $exception) { $error = json_decode($exception->getMessage(), true, 512, JSON_THROW_ON_ERROR); - $error = \Pumukit\YoutubeBundle\Document\Error::create( + $error = Error::create( $error['error']['errors'][0]['reason'], $error['error']['errors'][0]['message'], new \DateTime(), diff --git a/Services/VideoDeleteService.php b/Services/VideoDeleteService.php index fd982d4..c6e1609 100644 --- a/Services/VideoDeleteService.php +++ b/Services/VideoDeleteService.php @@ -8,6 +8,7 @@ use Psr\Log\LoggerInterface; use Pumukit\SchemaBundle\Document\MultimediaObject; use Pumukit\SchemaBundle\Document\Tag; +use Pumukit\YoutubeBundle\Document\Error; use Pumukit\YoutubeBundle\Document\Youtube; class VideoDeleteService extends GoogleVideoService @@ -67,7 +68,7 @@ public function deleteVideoFromYouTubeByMultimediaObject(MultimediaObject $multi } $response = $this->delete($account, $video); if (204 !== $response->getStatusCode()) { - $error = \Pumukit\YoutubeBundle\Document\Error::create( + $error = Error::create( $response->getReasonPhrase(), $response->getReasonPhrase(), new \DateTime(), @@ -80,7 +81,7 @@ public function deleteVideoFromYouTubeByMultimediaObject(MultimediaObject $multi } } catch (\Exception $exception) { $error = json_decode($exception->getMessage(), true, 512, JSON_THROW_ON_ERROR); - $error = \Pumukit\YoutubeBundle\Document\Error::create( + $error = Error::create( $error['error']['errors'][0]['reason'], $error['error']['errors'][0]['message'], new \DateTime(), @@ -120,7 +121,7 @@ public function deleteVideoFromYouTubeByYouTubeDocument(Youtube $youtube): bool } $response = $this->delete($account, $video); if (204 !== $response->getStatusCode()) { - $error = \Pumukit\YoutubeBundle\Document\Error::create( + $error = Error::create( $response->getReasonPhrase(), $response->getReasonPhrase(), new \DateTime(), @@ -134,7 +135,7 @@ public function deleteVideoFromYouTubeByYouTubeDocument(Youtube $youtube): bool } } catch (\Exception $exception) { $error = json_decode($exception->getMessage(), true, 512, JSON_THROW_ON_ERROR); - $error = \Pumukit\YoutubeBundle\Document\Error::create( + $error = Error::create( $error['error']['errors'][0]['reason'], $error['error']['errors'][0]['message'], new \DateTime(), diff --git a/Services/VideoInsertService.php b/Services/VideoInsertService.php index 1d2e4d4..312eb7c 100644 --- a/Services/VideoInsertService.php +++ b/Services/VideoInsertService.php @@ -10,6 +10,7 @@ use Pumukit\SchemaBundle\Document\MultimediaObject; use Pumukit\SchemaBundle\Document\Tag; use Pumukit\SchemaBundle\Document\Track; +use Pumukit\YoutubeBundle\Document\Error; use Pumukit\YoutubeBundle\Document\Youtube; class VideoInsertService extends GoogleVideoService @@ -174,7 +175,7 @@ private function updateVideoAndYoutubeDocumentByErrorResult( array $exception ): void { $youtube->setStatus(Youtube::STATUS_ERROR); - $error = \Pumukit\YoutubeBundle\Document\Error::create( + $error = Error::create( $exception['error']['errors'][0]['reason'], $exception['error']['message'], new \DateTime(), diff --git a/Services/VideoListService.php b/Services/VideoListService.php index e472402..63b1d1d 100644 --- a/Services/VideoListService.php +++ b/Services/VideoListService.php @@ -10,6 +10,7 @@ use Psr\Log\LoggerInterface; use Pumukit\SchemaBundle\Document\MultimediaObject; use Pumukit\SchemaBundle\Document\Tag; +use Pumukit\YoutubeBundle\Document\Error; use Pumukit\YoutubeBundle\Document\Youtube; class VideoListService extends GoogleVideoService @@ -65,7 +66,7 @@ public function updateVideoStatus(Youtube $youtube, MultimediaObject $multimedia $status = $this->getStatusFromYouTubeResponse($response, $video); } catch (\Exception $exception) { $error = json_decode($exception->getMessage(), true, 512, JSON_THROW_ON_ERROR); - $error = \Pumukit\YoutubeBundle\Document\Error::create( + $error = Error::create( $error['error']['errors'][0]['reason'], $error['error']['errors'][0]['message'], new \DateTime(), @@ -81,7 +82,7 @@ public function updateVideoStatus(Youtube $youtube, MultimediaObject $multimedia $youtube->setStatus($status); if (Youtube::STATUS_ERROR === $status || Youtube::STATUS_TO_REVIEW === $status) { $reason = $this->getReasonStatusFromYoutubeResponse($response, $video); - $error = \Pumukit\YoutubeBundle\Document\Error::create( + $error = Error::create( 'pumukit.statusError', $reason, new \DateTime(), diff --git a/Services/VideoUpdateService.php b/Services/VideoUpdateService.php index 51e99f8..5fbbae5 100644 --- a/Services/VideoUpdateService.php +++ b/Services/VideoUpdateService.php @@ -5,9 +5,11 @@ namespace Pumukit\YoutubeBundle\Services; use Doctrine\ODM\MongoDB\DocumentManager; +use Google\Service\YouTube\Video; use Psr\Log\LoggerInterface; use Pumukit\SchemaBundle\Document\MultimediaObject; use Pumukit\SchemaBundle\Document\Tag; +use Pumukit\YoutubeBundle\Document\Error; use Pumukit\YoutubeBundle\Document\Youtube; class VideoUpdateService extends GoogleVideoService @@ -68,7 +70,7 @@ public function updateVideoOnYoutube(MultimediaObject $multimediaObject): bool $response = $this->update($account, $video); } catch (\Exception $exception) { $error = json_decode($exception->getMessage(), true, 512, JSON_THROW_ON_ERROR); - $error = \Pumukit\YoutubeBundle\Document\Error::create( + $error = Error::create( $error['error']['errors'][0]['reason'], $error['error']['errors'][0]['message'], new \DateTime(), @@ -92,7 +94,7 @@ public function updateVideoOnYoutube(MultimediaObject $multimediaObject): bool private function update( Tag $youtubeAccount, \Google_Service_YouTube_Video $video, - ): \Google\Service\YouTube\Video { + ): Video { $infoLog = sprintf('[YouTube] Video update: %s ', $video->getId()); $this->logger->info($infoLog);