Toolvana: production-ready media tools platform (CodeIgniter 4)
- 134-tool registry with programmatic SEO (unique titles/H1/descriptions, JSON-LD graphs, sitemap index, canonical 301 enforcement via required filter) - DB-backed job queue (SKIP LOCKED) with drivers: Ffmpeg, Images (GD), Pdf (qpdf/gs/poppler), Youtube (thumbnails), Qr (server-side PNG) - Security: SSRF guard, MIME validation, rate limits, API-key auth, bcrypt admin login, security headers - Admin panel: dashboard, tools/categories/guides CRUD, SEO audit, analytics, job inspector with retry, system health, feature flags - Docker deployment (nginx + web/api FPM pools + scalable workers), PHPUnit suite (19 tests / 1139 assertions), PWA manifest + service worker
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Controllers\Api;
|
||||
|
||||
use App\Controllers\BaseController;
|
||||
use App\Libraries\Pipeline\Youtube as YoutubeLib;
|
||||
|
||||
/**
|
||||
* Instant YouTube URL analysis used by the paste-a-link UX: returns
|
||||
* oEmbed metadata + thumbnail candidates before any job is queued.
|
||||
*/
|
||||
final class Youtube extends BaseController
|
||||
{
|
||||
public function info(): \CodeIgniter\HTTP\ResponseInterface
|
||||
{
|
||||
$payload = $this->request->getJSON(true) ?: $this->request->getPost();
|
||||
$url = (string) ($payload['url'] ?? '');
|
||||
|
||||
$videoId = YoutubeLib::extractId($url);
|
||||
if ($videoId === null) {
|
||||
return response()->setStatusCode(422)->setJSON([
|
||||
'ok' => false, 'error' => 'invalid_url',
|
||||
'message' => 'Invalid YouTube URL. Paste a link like https://www.youtube.com/watch?v=…',
|
||||
]);
|
||||
}
|
||||
|
||||
service('analytics')->track('tool_start', ['tool' => 'youtube-url-analyzer']);
|
||||
|
||||
return response()->setJSON([
|
||||
'ok' => true,
|
||||
'id' => $videoId,
|
||||
'watch_url' => 'https://www.youtube.com/watch?v=' . $videoId,
|
||||
'embed_url' => 'https://www.youtube-nocookie.com/embed/' . $videoId,
|
||||
'thumbnails' => [
|
||||
['label' => 'Max resolution', 'url' => "https://i.ytimg.com/vi/{$videoId}/maxresdefault.jpg"],
|
||||
['label' => 'Standard', 'url' => "https://i.ytimg.com/vi/{$videoId}/sddefault.jpg"],
|
||||
['label' => 'High quality', 'url' => "https://i.ytimg.com/vi/{$videoId}/hqdefault.jpg"],
|
||||
['label' => 'Medium', 'url' => "https://i.ytimg.com/vi/{$videoId}/mqdefault.jpg"],
|
||||
],
|
||||
'info' => YoutubeLib::fetchInfo($videoId),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user