-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfeed.php
More file actions
31 lines (25 loc) · 1020 Bytes
/
feed.php
File metadata and controls
31 lines (25 loc) · 1020 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
declare(strict_types=1);
// Este endpoint devuelve el RSS XML en vivo generado desde la base de datos.
require_once __DIR__ . '/feed_builder.php';
require_once __DIR__ . '/canonical_redirect.php';
require_once __DIR__ . '/lib/cache_service.php';
$dbPath = getenv('PODCAST_DB_PATH') ?: __DIR__ . '/podcast.sqlite';
enforceCanonicalHostFromPodcastLink($dbPath);
if (tryServeWebCache($dbPath, 'application/rss+xml; charset=UTF-8')) {
exit;
}
try {
$pdo = new PDO('sqlite:' . $dbPath);
// Prioriza la URL principal del podcast para atom:link/self.
$selfHref = resolveFeedSelfHref($pdo);
// Genera el XML completo en memoria y lo devuelve en esta request.
$xml = buildPodcastFeedXml($pdo, $selfHref);
header('Content-Type: application/rss+xml; charset=UTF-8');
storeWebCache($dbPath, $xml);
echo $xml;
} catch (Throwable $e) {
http_response_code(500);
header('Content-Type: text/plain; charset=UTF-8');
echo 'Error generando el feed: ' . $e->getMessage() . "\n";
}