1. Go to this page and download the library: Download ayacoo/video-validator library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ayacoo / video-validator example snippets
declare(strict_types=1);
namespace Ayacoo\Tiktok\Listener;
use Ayacoo\Tiktok\Crawler\TiktokValidator;
use Ayacoo\VideoValidator\Event\ModifyValidatorEvent;
use TYPO3\CMS\Core\Utility\GeneralUtility;
class ValidatorListener
{
public function setValidator(ModifyValidatorEvent $event): ModifyValidatorEvent
{
$extension = strtolower($event->getExtension());
if ($extension === 'tiktok') {
$validator = GeneralUtility::makeInstance(TiktokValidator::class, $extension);
$event->setValidator($validator);
}
return $event;
}
}
declare(strict_types=1);
namespace Ayacoo\Tiktok\Crawler;
use Ayacoo\Tiktok\Helper\TiktokHelper;
use Ayacoo\VideoValidator\Service\Validator\AbstractVideoValidator;
use Ayacoo\VideoValidator\Service\Validator\AbstractVideoValidatorInterface;
use TYPO3\CMS\Core\Resource\File;
use TYPO3\CMS\Core\Utility\GeneralUtility;
class TiktokValidator extends AbstractVideoValidator implements AbstractVideoValidatorInterface
{
private TiktokHelper $tiktokHelper;
private string $username;
public function __construct(string $extension)
{
$this->tiktokHelper = GeneralUtility::makeInstance(TiktokHelper::class, $extension);
}
public function getOEmbedUrl(string $mediaId, string $format = 'json'): string
{
return sprintf(
'https://www.tiktok.com/oembed?url=https://www.tiktok.com/video/%s',
rawurlencode($mediaId)
);
}
public function getOnlineMediaId(File $file): string
{
$this->username = $file->getProperty('tiktok_username') ?? '';
return $this->tiktokHelper->getOnlineMediaId($file);
}
public function buildUrl(string $mediaId): string
{
return 'https://www.tiktok.com/@' . $this->username . '/' . $mediaId;
}
}
declare(strict_types=1);
namespace Extension\Namespace\Listener;
use Ayacoo\VideoValidator\Event\ModifyReportServiceEvent;
use TYPO3\CMS\Core\Utility\GeneralUtility;
class ReportServiceListener
{
public function setReportServices(ModifyReportServiceEvent $event): ModifyReportServiceEvent
{
$yourReportService = GeneralUtility::makeInstance(XmlReportService::class);
$reportServices = $event->getReportServices() ?? [];
$reportServices['XmlReportService'] = $yourReportService;
$event->setReportServices($reportServices);
return $event;
}
}
declare(strict_types=1);
namespace Extension\Namespace\Report;
use Ayacoo\VideoValidator\Service\Report\AbstractReportServiceInterface;
class YourReportService implements AbstractReportServiceInterface
{
protected array $settings = [];
protected array $validVideos = [];
protected array $invalidVideos = [];
public function makeReport(): void
{
// Do your custom stuff e.g. CSV or XML export
$mediaExtension = $this->getSettings()['extension'];
$xmlDocument = new SimpleXMLElement('<?xml version="1.0"
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.