diff --git a/Classes/Controller/VimeoController.php b/Classes/Controller/VimeoController.php index 6217d6ed9f07037d344a23789c7ce23fe5e2194a..d233e2dc8fc2be3fae0804ff1f8900963cab24ae 100644 --- a/Classes/Controller/VimeoController.php +++ b/Classes/Controller/VimeoController.php @@ -39,6 +39,7 @@ class VimeoController extends ActionController { */ public function indexAction(): void { $id = $this->settings['id']; + $filterIds = $this->settings['filterId'] ?? ''; $maxResults = (int) $this->settings['maxResults']; $clientId = $this->settings['clientId']; $clientSecret = $this->settings['clientSecret']; @@ -48,6 +49,14 @@ class VimeoController extends ActionController { $this->view->assign('error', 'Please configure a client id and a client secret for sg_vimeo.'); return; } + + $filterIds = explode(',', $filterIds); + foreach ($filterIds as &$filterId) { + $filterId = trim($filterId, " "); + } + + $maxResultsWithFilters = (string) ($maxResults + count($filterIds)); + /** @var VimeoService $vimeoService */ $vimeoService = GeneralUtility::makeInstance( VimeoService::class, @@ -55,13 +64,30 @@ class VimeoController extends ActionController { $clientSecret, $personalAccessToken ); - $response = $vimeoService->getVimeoData($id, $maxResults); + $response = $vimeoService->getVimeoData($id, $maxResultsWithFilters); $response = $this->mapVimeoApiResponseWithPossibleCustomThumbnails($response); if ($response === NULL) { return; } if (is_array($response['items'])) { + $response['items'] = array_filter($response['items'], function ($item) use ($filterIds) { + $videoId = (string) $item['videoId']; + foreach ($filterIds as $filterId) { + if ($videoId === $filterId) { + return false; + } + } + return true; + }); + + // Fix the array indexes from previous filtering + $response['items'] = array_values($response['items']); + + while (count($response['items']) > $maxResults) { + array_pop($response['items']); + } + foreach ($response['items'] as &$item) { /* diff --git a/Configuration/FlexForms/flexform_sgvimeo_vimeo.xml b/Configuration/FlexForms/flexform_sgvimeo_vimeo.xml index e5013d0913001824d237552ee6f97ae4705bd677..a9a76430d7193df6973dc05c26bcc7238561a075 100644 --- a/Configuration/FlexForms/flexform_sgvimeo_vimeo.xml +++ b/Configuration/FlexForms/flexform_sgvimeo_vimeo.xml @@ -25,6 +25,17 @@ </config> </TCEforms> </settings.id> + <settings.filterId> + <TCEforms> + <exclude>0</exclude> + <label>LLL:EXT:sg_vimeo/Resources/Private/Language/locallang.xlf:flexform.filterIds</label> + <description>LLL:EXT:sg_vimeo/Resources/Private/Language/locallang.xlf:flexform.filterIds.description</description> + <config> + <type>input</type> + <eval>trim</eval> + </config> + </TCEforms> + </settings.filterId> <settings.maxResults> <TCEforms> <exclude>0</exclude> diff --git a/Resources/Private/Language/de.locallang.xlf b/Resources/Private/Language/de.locallang.xlf index 8c04d5ce7a7a37bbb595061be461daa49d621901..6efd15371f8773134636a087be81794d045e26d0 100644 --- a/Resources/Private/Language/de.locallang.xlf +++ b/Resources/Private/Language/de.locallang.xlf @@ -105,6 +105,14 @@ <source><![CDATA[Example inputs - Single video: 123456789 | Channel: channel/channelname | Showcase: showcase/987645]]></source> <target><![CDATA[Beispieleingaben - Einzelnes Video: 123456789 | Kanal: channel/kanalname | Showcase: showcase/987645]]></target> </trans-unit> + <trans-unit id="flexform.filterIds" approved="yes"> + <source><![CDATA[IDs of the videos to exclude]]></source> + <target><![CDATA[Auszuschließende Video-IDs]]></target> + </trans-unit> + <trans-unit id="flexform.filterIds.description" approved="yes"> + <source><![CDATA[Insert as a comma seperated list. (12345, 67890)]]></source> + <target><![CDATA[Als ein List getrennt durch Kommas angeben. (12345, 67890)]]></target> + </trans-unit> <trans-unit id="flexform.layout" approved="yes"> <source><![CDATA[Layout Style]]></source> <target><![CDATA[Layout-Art]]></target> diff --git a/Resources/Private/Language/locallang.xlf b/Resources/Private/Language/locallang.xlf index 41e222d2d53a72059a207395d9f97e0fe96729d8..878851a0e158266830cb361eacb4cbe5a97b5ad3 100644 --- a/Resources/Private/Language/locallang.xlf +++ b/Resources/Private/Language/locallang.xlf @@ -32,6 +32,12 @@ <trans-unit id="flexform.id"> <source><![CDATA[Video ID (https://vimeo.com/%VIDEO_ID%), channel name (https://vimeo.com/channels/%CHANNEL_NAME%) or showcase (https://vimeo.com/showcase/%SHOWCASE_ID%)]]></source> </trans-unit> + <trans-unit id="flexform.filterIds"> + <source><![CDATA[IDs of the videos to exclude]]></source> + </trans-unit> + <trans-unit id="flexform.filterIds.description"> + <source><![CDATA[Insert as a comma seperated list. (12345, 67890)]]></source> + </trans-unit> <trans-unit id="flexform.layout"> <source><![CDATA[Layout Style]]></source> </trans-unit>