/** * Get Album List as JSON */ public function getPlayListList(&$PA, &$fobj, $maxCount = 50) { $this->init($PA); /** @var \Google_Service_YouTube_Playlists_Resource $playLists */ $playLists = $this->youTubeApi->listPlaylists("snippet,contentDetails", $maxCount); $playListsItems = $this->getYouTubePlayListItemList($playLists); $template = GeneralUtility::getFileAbsFileName('EXT:youtube_playlist/Resources/Private/Templates/Backend/FlexForm/PlayListList.html'); $renderer = $this->getFluidRenderer(); $renderer->setTemplatePathAndFilename($template); $renderer->assign('playlists', $playListsItems); $renderer->assign('PA', $PA); $content = $renderer->render(); //$this->extbaseShutdown(); return $content; }
/** * action show * * @return void */ public function showAction() { $this->youTubeApi->setChannelId($this->youtubeChannelId); // Playlist IDs $playlistIdStr = $this->settings["selectedPlaylists"]; if (empty($playlistIdStr)) { $this->addFlashMessage("You need to select at least one playlist in your plugin configuration.", $messageTitle = 'Ooops, you did it again', $severity = \TYPO3\CMS\Core\Messaging\AbstractMessage::WARNING, $storeInSession = TRUE); } else { $playlistIdArr = explode(",", $playlistIdStr); $videoArr = array(); $success = false; if (is_array($playlistIdArr)) { // if explode gives an array means: $playlistIdStr contains selected playlists // iterate through playlists and get videos foreach ($playlistIdArr as $playlistId) { $tmpPlVideos = array(); $tmpPlTitle = ""; /* @var \Google_Service_YouTube_PlaylistListResponse $playList */ $playList = $this->youTubeApi->getPlaylist($playlistId); if (isset($playList) && $playList !== false) { $success = true; $playListItems = $playList->getItems(); if (isset($playListItems) && !empty($playListItems)) { /* @var \Google_Service_YouTube_Playlist $playListItem */ $playListItem = $playListItems[0]; /* @var \Google_Service_YouTube_PlaylistSnippet $playListData */ $playListData = $playListItem->getSnippet(); $tmpPlTitle = $playListData->getTitle(); } /* @var \Google_Service_YouTube_PlaylistItemListResponse) $plVideos */ $plVideosStore = $this->youTubeApi->getPlaylistVideos($playlistId); if (isset($plVideosStore) && $plVideosStore !== false) { $plVideos = $plVideosStore->getItems(); if (isset($plVideos) && !empty($plVideos)) { /* @var \Google_Service_YouTube_Video $plVideo */ foreach ($plVideos as $plVideo) { /* @var \Google_Service_YouTube_VideoStatus $videoStatus */ $videoStatus = $plVideo->getStatus(); $privacyStatus = $videoStatus->getPrivacyStatus(); if ($privacyStatus === "public") { /* @var \Google_Service_YouTube_PlaylistItemSnippet $videoData */ $videoData = $plVideo->getSnippet(); /* @var \Google_Service_YouTube_ThumbnailDetails $thumbnails */ $thumbnails = $videoData->getThumbnails(); /* @var \Google_Service_YouTube_Thumbnail $thumbnail */ $thumbnail = $thumbnails->getMedium(); array_push($tmpPlVideos, array("thumb" => $thumbnail->getUrl(), "title" => $videoData->getTitle(), "description" => $videoData->getDescription(), "id" => $videoData->getResourceId()["videoId"])); } } $videoArr[$playlistId] = ["Title" => $tmpPlTitle, "Videos" => $tmpPlVideos]; } } } else { $this->addFlashMessage("Oops, you probably forgot to enter you channel id and server api token or your selected playlist does not container any videos.", $messageTitle = 'Ooops, you did it again', $severity = \TYPO3\CMS\Core\Messaging\AbstractMessage::WARNING, $storeInSession = TRUE); } } } } $this->view->assign("success", $success); $this->view->assign('playlists', $videoArr); }