From 690d7e810f0e29415dd0f55250feccd7af9216e4 Mon Sep 17 00:00:00 2001 From: Martin Kristensen Date: Thu, 16 May 2024 11:14:18 +0200 Subject: [PATCH 1/4] Add classes and configuration for API:Youtube --- Classes/Service/Api/ApiService.php | 195 ++++++++++++++++++ .../Extraction/ApiMetadataExtraction.php | 115 +++++++++++ Classes/Utility/ExtensionHelper.php | 3 + Configuration/Services/Api/onlinemedia.json | 6 + Resources/Private/Language/locallang_em.xlf | 24 +++ ext_conf_template.txt | 22 ++ ext_localconf.php | 4 + 7 files changed, 369 insertions(+) create mode 100644 Classes/Service/Api/ApiService.php create mode 100644 Classes/Service/Extraction/ApiMetadataExtraction.php create mode 100644 Configuration/Services/Api/onlinemedia.json mode change 100755 => 100644 Resources/Private/Language/locallang_em.xlf diff --git a/Classes/Service/Api/ApiService.php b/Classes/Service/Api/ApiService.php new file mode 100644 index 0000000..d2f8a53 --- /dev/null +++ b/Classes/Service/Api/ApiService.php @@ -0,0 +1,195 @@ + + * @license http://www.gnu.org/copyleft/gpl.html + */ +class ApiService extends AbstractService +{ + /** @var array */ + protected $onlineExtensions = [ + 'youtube', // VIDEOTYPE_YOUTUBE + 'vimeo', // VIDEOTYPE_VIMEO + ]; + + + + + /** + * Returns a list of supported file types. + * + * @return array + */ + public function getSupportedFileExtensions() + { + return array_merge( + $this->onlineExtensions + ); + } + + /** + * Takes a file reference and extracts its metadata. + * + * @param \TYPO3\CMS\Core\Resource\File $file Path to the file + * @return array + * @see \Causal\ImageAutoresize\Utility\ImageUtility::getMetadata() + */ + public function extractMetadataFromLocalFile($file) + { + $fileName = $file->getForLocalProcessing(false); + $extension = strtolower(substr($fileName, strrpos($fileName, '.') + 1)); + + //ok + error_log("extension navn:"); + + error_log($extension); + + try { + switch (true) { + + // case in_array($extension, $this->getOnlineExtensions): + // $metadata = $this->extractMetadataWithGetId3($fileName); + // break; + case $extension === 'youtube': + $metadata = $this->extractMetadataFromYoutube($file); + break; + case $extension === 'vimeo': + $metadata = $this->extractMetadataFromVimeo($file); + break; + default: + $metadata = []; + break; + } + $this->cleanupTempFile($fileName, $file); + + static::getLogger()->debug('Metadata extracted', $metadata); + } catch (\Exception $e) { + static::getLogger()->error('Error while extracting metadata from file', ['exception' => $e]); + $metadata = []; + } + + + error_log("metadate første tomme array:"); + error_log(print_r($metadata, true)); + return $metadata; + } + + + + + /** + * Takes a file reference and extracts its metadata. + * + * @param File $file + * @return array + */ + public function extractMetadata(File $file) + { + static::getLogger()->debug( + 'Extracting metadata', + [ + 'file' => $file->getUid(), + 'identifier' => $file->getCombinedIdentifier(), + ] + ); + #$localTempFilePath = $file->getForLocalProcessing(false); + $metadata = $this->extractMetadataFromLocalFile($file); + #$this->cleanupTempFile($localTempFilePath, $file); + + // Emit Signal after metadata has been extracted + if ($this->eventDispatcher !== null) { + $event = new AfterMetadataExtractedEvent($file, $metadata); + $this->eventDispatcher->dispatch($event); + $metadata = $event->getMetadata(); + } else { + $this->getSignalSlotDispatcher()->dispatch( + self::class, + 'postMetaDataExtraction', + [ + $file, + &$metadata + ] + ); + } + + return $metadata; + } + + /** + * Fetch metadata from a youtube video. + * + * @param \TYPO3\CMS\Core\Resource\File $file File object + * @return array + */ + protected function extractMetadataFromYoutube($file) + { + static::getLogger()->debug('Fetching metadata from Youtube API'); + $metadata = []; + + // Fetch online media id + $onlineMediaHelper = OnlineMediaHelperRegistry::getInstance()->getOnlineMediaHelper($file); + $videoId = $onlineMediaHelper->getOnlineMediaId($file); + + $params = array( + 'part' => 'contentDetails,snippet', // snippet has description + 'id' => $videoId, + 'key' => $this->settings['youtube_api_key'], + ); + + $api_url = $this->settings['youtube_api_base'] . '?' . http_build_query($params); + + $result = json_decode(@file_get_contents($api_url), true); + + if(empty($result['items'][0]['contentDetails'])) { + return null; + } + + $duration = self::covTime($result['items'][0]['contentDetails']['duration']); + $metadata['duration'] = $duration; + + return $metadata; + + } + + + /** + * Convert Youtube time + * + * @param string $youtubeTime + */ + public function covTime($youtubeTime) + { + $start = new \DateTime('@0'); // Unix epoch + $start->add(new \DateInterval($youtubeTime)); + return $start->format('U'); + } + +} + diff --git a/Classes/Service/Extraction/ApiMetadataExtraction.php b/Classes/Service/Extraction/ApiMetadataExtraction.php new file mode 100644 index 0000000..65db58b --- /dev/null +++ b/Classes/Service/Extraction/ApiMetadataExtraction.php @@ -0,0 +1,115 @@ + + * @license http://www.gnu.org/copyleft/gpl.html + */ +class ApiMetadataExtraction extends AbstractExtractionService +{ + /** + * @var integer + */ + protected $priority = 50; + + /** + * @var string + */ + protected $serviceName = 'Api'; + + /** + * ApiMetadataExtraction constructor. + */ + public function __construct() + { + parent::__construct(); + + $apiService = $this->getApiService(); + $this->supportedFileExtensions = $apiService->getSupportedFileExtensions(); + } + + /** + * Checks if the given file can be processed by this extractor. + * + * @param File $file + * @return boolean + */ + protected function _canProcess(File $file): bool + { + $fileExtension = strtolower($file->getProperty('extension')); + return in_array($fileExtension, $this->supportedFileExtensions); + } + + /** + * The actual processing task. + * + * Should return an array with database properties for sys_file_metadata to write. + * + * @param File $file + * @param array $previousExtractedData optional, contains the array of already extracted data + * @return array + */ + public function extractMetaData(File $file, array $previousExtractedData = []) + { + $metadata = []; + + $extractedMetadata = $this->getApiService()->extractMetadata($file); + + error_log(print_r($extractedMetadata, true)); + + if (!empty($extractedMetadata)) { + $dataMapping = $this->getDataMapping($file); + $metadata = $this->remapServiceOutput($extractedMetadata, $dataMapping); + $this->processCategories($file, $metadata); + } + + return $metadata; + } + + /** + * Returns a API service. + * + * @return \Causal\Extractor\Service\Api\ApiService + */ + protected function getApiService() + { + /** @var \Causal\Extractor\Service\Api\ApiService $apiService */ + static $apiService = null; + + if ($apiService === null) { + $apiService = GeneralUtility::makeInstance(\Causal\Extractor\Service\Api\ApiService::class); + } + + return $apiService; + } + + /** + * Returns a logger. + * + * @return \TYPO3\CMS\Core\Log\Logger + */ + protected static function getLogger() + { + /** @var \TYPO3\CMS\Core\Log\Logger $logger */ + $logger = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Log\LogManager::class)->getLogger(__CLASS__); + return $logger; + } +} diff --git a/Classes/Utility/ExtensionHelper.php b/Classes/Utility/ExtensionHelper.php index e75207b..48eca61 100644 --- a/Classes/Utility/ExtensionHelper.php +++ b/Classes/Utility/ExtensionHelper.php @@ -132,6 +132,9 @@ public static function getExtensionCategory(string $extension): string case 'wmv': case 'yuv': return 'video'; + case 'youtube': + case 'vimeo': + return 'onlinemedia'; } return 'other'; diff --git a/Configuration/Services/Api/onlinemedia.json b/Configuration/Services/Api/onlinemedia.json new file mode 100644 index 0000000..204de3d --- /dev/null +++ b/Configuration/Services/Api/onlinemedia.json @@ -0,0 +1,6 @@ +[ + { + "FAL": "duration", + "DATA": "duration->Causal\\Extractor\\Utility\\Number::castInteger" + } +] diff --git a/Resources/Private/Language/locallang_em.xlf b/Resources/Private/Language/locallang_em.xlf old mode 100755 new mode 100644 index 2b0f708..bef207e --- a/Resources/Private/Language/locallang_em.xlf +++ b/Resources/Private/Language/locallang_em.xlf @@ -12,6 +12,9 @@ External Tools + + Online Media + Apache Tika: If ticked, Apache Tika will be used to detect and extract metadata from your assets. @@ -24,6 +27,9 @@ Native PHP: If ticked, native PHP code and libraries will be used to detect and extract metadata from your assets. + + API: If ticked, API code will be used to fetch metadata for your assets. Remember to fill out Online media tokens. + Base directory for mapping: The metadata extraction requires mapping configuration files. By default these are provided in the Configuration/Services directory. If you wish to use a different mapping configuration, you can provide a different mapping configuration base directory. @@ -104,6 +110,24 @@ copy JSON to clipboard + + Api key from Youtube : https://developers.google.com/youtube/v3/docs/ + + + Baseurl for Youtube Api calls + + + Url for Youtube thumbnail provider + + + Api key from Vimeo : https://developers.google.com/youtube/v3/docs/ + + + Baseurl for Vimeo Api calls + + + Url for Vimeo thumbnail provider + \ No newline at end of file diff --git a/ext_conf_template.txt b/ext_conf_template.txt index c3e95ef..bbff1a5 100644 --- a/ext_conf_template.txt +++ b/ext_conf_template.txt @@ -1,6 +1,7 @@ # customcategory=mapping=LLL:EXT:extractor/Resources/Private/Language/locallang_em.xlf:settings.category.mapping # customcategory=tika=LLL:EXT:extractor/Resources/Private/Language/locallang_em.xlf:settings.category.tika # customcategory=tools=LLL:EXT:extractor/Resources/Private/Language/locallang_em.xlf:settings.category.tools +# customcategory=online=LLL:EXT:extractor/Resources/Private/Language/locallang_em.xlf:settings.category.online # cat=basic/enable/10; type=boolean; label=LLL:EXT:extractor/Resources/Private/Language/locallang_em.xlf:settings.enable_tika enable_tika = 0 @@ -14,6 +15,9 @@ enable_tools_pdfinfo = 0 # cat=basic/enable/40; type=boolean; label=LLL:EXT:extractor/Resources/Private/Language/locallang_em.xlf:settings.enable_php enable_php = 1 +# cat=basic/enable/50; type=boolean; label=LLL:EXT:extractor/Resources/Private/Language/locallang_em.xlf:settings.enable_api +enable_api = 0 + # cat=tika//10; type=options[LLL:EXT:extractor/Resources/Private/Language/locallang_em.xlf:settings.tika_mode.jar=jar,LLL:EXT:extractor/Resources/Private/Language/locallang_em.xlf:settings.tika_mode.server=server]; label=LLL:EXT:extractor/Resources/Private/Language/locallang_em.xlf:settings.tika_mode tika_mode = jar @@ -32,6 +36,24 @@ tools_exiftool = # cat=tools//30; type=user[Causal\Extractor\Em\ConfigurationHelper->createToolInput]; label=LLL:EXT:extractor/Resources/Private/Language/locallang_em.xlf:settings.tools_pdfinfo tools_pdfinfo = +# cat=online//10; type=string; label=LLL:EXT:extractor/Resources/Private/Language/locallang_em.xlf:settings.online_youtube_api_key +youtube_api_key = + +# cat=online//20; type=string; label=LLL:EXT:extractor/Resources/Private/Language/locallang_em.xlf:settings.online_youtube_api_base +youtube_api_base = https://www.googleapis.com/youtube/v3/videos + +# cat=online//30; type=string; label=LLL:EXT:extractor/Resources/Private/Language/locallang_em.xlf:settings.online_youtube_thumbnail_base +youtube_thumbnail_base = https://i.ytimg.com/vi/ + +# cat=online//40; type=string; label=LLL:EXT:extractor/Resources/Private/Language/locallang_em.xlf:settings.online_vimeo_api_key +vimeo_api_key = + +# cat=online//50; type=string; label=LLL:EXT:extractor/Resources/Private/Language/locallang_em.xlf:settings.online_vimeo_api_base +vimeo_api_base = https://api.vimeo.com/videos/ + +# cat=online//60; type=string; label=LLL:EXT:extractor/Resources/Private/Language/locallang_em.xlf:settings.online_vimeo_thumbnail_base +vimeo_thumbnail_base = + # cat=mapping//10; type=string; label=LLL:EXT:extractor/Resources/Private/Language/locallang_em.xlf:settings.mapping_base_directory mapping_base_directory = EXT:extractor/Configuration/Services/ diff --git a/ext_localconf.php b/ext_localconf.php index 96c0b8d..672690b 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -29,5 +29,9 @@ if (!isset($settings['enable_php']) || (bool)$settings['enable_php']) { $extractorRegistry->registerExtractionService(\Causal\Extractor\Service\Extraction\PhpMetadataExtraction::class); } + // Mind the "!isset" in test below to be backward compatible + if (!isset($settings['enable_api']) || (bool)$settings['enable_api']) { + $extractorRegistry->registerExtractionService(\Causal\Extractor\Service\Extraction\ApiMetadataExtraction::class); + } } })('extractor'); From bcbaba4f200f48c479edbe3c79b08795f55261bd Mon Sep 17 00:00:00 2001 From: Daniel Alexander Damm Date: Thu, 16 May 2024 15:57:46 +0200 Subject: [PATCH 2/4] extract from Vimeo api --- Classes/Service/Api/ApiService.php | 59 +++++++++++++++++---- Configuration/Services/Api/onlinemedia.json | 7 ++- 2 files changed, 54 insertions(+), 12 deletions(-) diff --git a/Classes/Service/Api/ApiService.php b/Classes/Service/Api/ApiService.php index d2f8a53..987095b 100644 --- a/Classes/Service/Api/ApiService.php +++ b/Classes/Service/Api/ApiService.php @@ -65,11 +65,6 @@ public function extractMetadataFromLocalFile($file) { $fileName = $file->getForLocalProcessing(false); $extension = strtolower(substr($fileName, strrpos($fileName, '.') + 1)); - - //ok - error_log("extension navn:"); - - error_log($extension); try { switch (true) { @@ -94,10 +89,6 @@ public function extractMetadataFromLocalFile($file) static::getLogger()->error('Error while extracting metadata from file', ['exception' => $e]); $metadata = []; } - - - error_log("metadate første tomme array:"); - error_log(print_r($metadata, true)); return $metadata; } @@ -164,13 +155,11 @@ protected function extractMetadataFromYoutube($file) ); $api_url = $this->settings['youtube_api_base'] . '?' . http_build_query($params); - $result = json_decode(@file_get_contents($api_url), true); if(empty($result['items'][0]['contentDetails'])) { return null; } - $duration = self::covTime($result['items'][0]['contentDetails']['duration']); $metadata['duration'] = $duration; @@ -179,6 +168,54 @@ protected function extractMetadataFromYoutube($file) } + /** + * Fetch metadata from a Vimeo video. + * + * @param \TYPO3\CMS\Core\Resource\File $file File object + * @return array + */ + protected function extractMetadataFromVimeo($file) + { + static::getLogger()->debug('Fetching metadata from Vimeo API'); + $metadata = []; + + // Fetch online media id + $onlineMediaHelper = OnlineMediaHelperRegistry::getInstance()->getOnlineMediaHelper($file); + $videoId = $onlineMediaHelper->getOnlineMediaId($file); + + $params = array( + // 'fields' => 'duration', + ); + + // Create a stream - setting headers for authentication + $opts = array( + 'http'=>array( + 'method'=>"GET", + 'header'=>"cache-control: no-cache\r\n" . + "authorization: Bearer ". $this->settings['vimeo_api_key'] ."\r\n" + ) + ); + + $context = stream_context_create($opts); + + // Build URI with Params and open the file using the HTTP headers set above + $api_url = $this->settings['vimeo_api_base'] . $videoId . '?' . http_build_query($params); + $result = json_decode(@file_get_contents($api_url, false, $context), true); + + // foreach($result as $key=>$value) { + // error_log($key); + // error_log(print_r($value, true)); + // } + if(empty($result)) { + return []; + } + $metadata = $result; + + return $metadata; + + } + + /** * Convert Youtube time * diff --git a/Configuration/Services/Api/onlinemedia.json b/Configuration/Services/Api/onlinemedia.json index 204de3d..b9df7c4 100644 --- a/Configuration/Services/Api/onlinemedia.json +++ b/Configuration/Services/Api/onlinemedia.json @@ -2,5 +2,10 @@ { "FAL": "duration", "DATA": "duration->Causal\\Extractor\\Utility\\Number::castInteger" + }, + { + "FAL": "description", + "DATA": "description" } -] +] + From 1307d2ee3a8ee15d09d06a7c65453723e6ccc7be Mon Sep 17 00:00:00 2001 From: Daniel Alexander Damm Date: Tue, 21 May 2024 13:49:50 +0200 Subject: [PATCH 3/4] Add Utility for youtube time conversion --- Classes/Utility/YoutubeTime.php | 37 +++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 Classes/Utility/YoutubeTime.php diff --git a/Classes/Utility/YoutubeTime.php b/Classes/Utility/YoutubeTime.php new file mode 100644 index 0000000..68e2c7f --- /dev/null +++ b/Classes/Utility/YoutubeTime.php @@ -0,0 +1,37 @@ + + * @license http://www.gnu.org/copyleft/gpl.html + */ +class YoutubeTime +{ + /** + * Convert Youtube time + * + * @param string $youtubeTime + * @return int + */ + public static function toSeconds($youtubeTime) : int + { + $start = new \DateTime('@0'); // Unix epoch + $start->add(new \DateInterval($youtubeTime)); + return (int)$start->format('U'); + } +} From 71c4f6e634244536ea3453c0eb3161a49c906c17 Mon Sep 17 00:00:00 2001 From: Daniel Alexander Damm Date: Tue, 21 May 2024 13:50:40 +0200 Subject: [PATCH 4/4] Fetch publisher from Vimeo - Cleanup --- Classes/Service/Api/ApiService.php | 77 ++++++------------- .../Extraction/ApiMetadataExtraction.php | 4 +- Configuration/Services/Api/onlinemedia.json | 17 +++- 3 files changed, 37 insertions(+), 61 deletions(-) diff --git a/Classes/Service/Api/ApiService.php b/Classes/Service/Api/ApiService.php index 987095b..1dac9b6 100644 --- a/Classes/Service/Api/ApiService.php +++ b/Classes/Service/Api/ApiService.php @@ -15,20 +15,16 @@ namespace Causal\Extractor\Service\Api; use Causal\Extractor\Service\AbstractService; -use Causal\Extractor\Utility\ColorSpace; -use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; -use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\CMS\Core\Utility\MathUtility; - +// use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; +// use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Resource\OnlineMedia\Helpers\OnlineMediaHelperRegistry; use TYPO3\CMS\Core\Resource\File; - use Causal\Extractor\Resource\Event\AfterMetadataExtractedEvent; /** * A ApiService service implementation. * - * @author --- + * @author Martin Kristensen + Daniel Damm * @license http://www.gnu.org/copyleft/gpl.html */ class ApiService extends AbstractService @@ -40,8 +36,6 @@ class ApiService extends AbstractService ]; - - /** * Returns a list of supported file types. * @@ -54,6 +48,7 @@ public function getSupportedFileExtensions() ); } + /** * Takes a file reference and extracts its metadata. * @@ -68,15 +63,11 @@ public function extractMetadataFromLocalFile($file) try { switch (true) { - - // case in_array($extension, $this->getOnlineExtensions): - // $metadata = $this->extractMetadataWithGetId3($fileName); - // break; case $extension === 'youtube': - $metadata = $this->extractMetadataFromYoutube($file); + $metadata['youtube'] = $this->extractMetadataFromYoutube($file); break; case $extension === 'vimeo': - $metadata = $this->extractMetadataFromVimeo($file); + $metadata['vimeo'] = $this->extractMetadataFromVimeo($file); break; default: $metadata = []; @@ -92,8 +83,6 @@ public function extractMetadataFromLocalFile($file) return $metadata; } - - /** * Takes a file reference and extracts its metadata. @@ -110,9 +99,7 @@ public function extractMetadata(File $file) 'identifier' => $file->getCombinedIdentifier(), ] ); - #$localTempFilePath = $file->getForLocalProcessing(false); $metadata = $this->extractMetadataFromLocalFile($file); - #$this->cleanupTempFile($localTempFilePath, $file); // Emit Signal after metadata has been extracted if ($this->eventDispatcher !== null) { @@ -133,6 +120,7 @@ public function extractMetadata(File $file) return $metadata; } + /** * Fetch metadata from a youtube video. * @@ -144,27 +132,21 @@ protected function extractMetadataFromYoutube($file) static::getLogger()->debug('Fetching metadata from Youtube API'); $metadata = []; - // Fetch online media id - $onlineMediaHelper = OnlineMediaHelperRegistry::getInstance()->getOnlineMediaHelper($file); - $videoId = $onlineMediaHelper->getOnlineMediaId($file); - $params = array( - 'part' => 'contentDetails,snippet', // snippet has description - 'id' => $videoId, + 'part' => 'contentDetails,snippet', + 'id' => $this->getMediaId($file), 'key' => $this->settings['youtube_api_key'], ); $api_url = $this->settings['youtube_api_base'] . '?' . http_build_query($params); $result = json_decode(@file_get_contents($api_url), true); - if(empty($result['items'][0]['contentDetails'])) { - return null; + if(empty($result['items'][0])) { + return []; } - $duration = self::covTime($result['items'][0]['contentDetails']['duration']); - $metadata['duration'] = $duration; + $metadata = $result['items'][0]; return $metadata; - } @@ -178,15 +160,7 @@ protected function extractMetadataFromVimeo($file) { static::getLogger()->debug('Fetching metadata from Vimeo API'); $metadata = []; - - // Fetch online media id - $onlineMediaHelper = OnlineMediaHelperRegistry::getInstance()->getOnlineMediaHelper($file); - $videoId = $onlineMediaHelper->getOnlineMediaId($file); - $params = array( - // 'fields' => 'duration', - ); - // Create a stream - setting headers for authentication $opts = array( 'http'=>array( @@ -196,37 +170,30 @@ protected function extractMetadataFromVimeo($file) ) ); - $context = stream_context_create($opts); - // Build URI with Params and open the file using the HTTP headers set above - $api_url = $this->settings['vimeo_api_base'] . $videoId . '?' . http_build_query($params); - $result = json_decode(@file_get_contents($api_url, false, $context), true); + $api_url = $this->settings['vimeo_api_base'] . $this->getMediaId($file); + $result = json_decode(@file_get_contents($api_url, false, stream_context_create($opts)), true); - // foreach($result as $key=>$value) { - // error_log($key); - // error_log(print_r($value, true)); - // } if(empty($result)) { return []; } $metadata = $result; return $metadata; - } /** - * Convert Youtube time + * Fetch online media id from file. * - * @param string $youtubeTime + * @param \TYPO3\CMS\Core\Resource\File $file File object + * @return string */ - public function covTime($youtubeTime) + protected function getMediaId($file) { - $start = new \DateTime('@0'); // Unix epoch - $start->add(new \DateInterval($youtubeTime)); - return $start->format('U'); - } + $onlineMediaHelper = OnlineMediaHelperRegistry::getInstance()->getOnlineMediaHelper($file); + $mediaId = $onlineMediaHelper->getOnlineMediaId($file); + return $mediaId; + } } - diff --git a/Classes/Service/Extraction/ApiMetadataExtraction.php b/Classes/Service/Extraction/ApiMetadataExtraction.php index 65db58b..0ae5ebc 100644 --- a/Classes/Service/Extraction/ApiMetadataExtraction.php +++ b/Classes/Service/Extraction/ApiMetadataExtraction.php @@ -20,7 +20,7 @@ /** * A service to extract metadata from files using API * - * @author Xavier Perseguers + * @author Martin Kristensen * @license http://www.gnu.org/copyleft/gpl.html */ class ApiMetadataExtraction extends AbstractExtractionService @@ -73,8 +73,6 @@ public function extractMetaData(File $file, array $previousExtractedData = []) $extractedMetadata = $this->getApiService()->extractMetadata($file); - error_log(print_r($extractedMetadata, true)); - if (!empty($extractedMetadata)) { $dataMapping = $this->getDataMapping($file); $metadata = $this->remapServiceOutput($extractedMetadata, $dataMapping); diff --git a/Configuration/Services/Api/onlinemedia.json b/Configuration/Services/Api/onlinemedia.json index b9df7c4..55842ac 100644 --- a/Configuration/Services/Api/onlinemedia.json +++ b/Configuration/Services/Api/onlinemedia.json @@ -1,11 +1,22 @@ [ { "FAL": "duration", - "DATA": "duration->Causal\\Extractor\\Utility\\Number::castInteger" + "DATA": [ + "youtube|contentDetails|duration->Causal\\Extractor\\Utility\\YoutubeTime::toSeconds", + "vimeo|duration->Causal\\Extractor\\Utility\\Number::castInteger" + ] }, { "FAL": "description", - "DATA": "description" + "DATA": [ + "youtube|snippet|description->Causal\\Extractor\\Utility\\SimpleString::trim", + "vimeo|description->Causal\\Extractor\\Utility\\SimpleString::trim" + ] + }, + { + "FAL": "publisher", + "DATA": [ + "vimeo|user|name->Causal\\Extractor\\Utility\\SimpleString::trim" + ] } ] -