2024-05-06 12:52:55 +02:00
|
|
|
<?php
|
|
|
|
namespace feed;
|
|
|
|
|
|
|
|
require_once "episode.php";
|
|
|
|
|
|
|
|
class Podcast {
|
|
|
|
public string $title;
|
|
|
|
public string $desc;
|
|
|
|
public array $episodes;
|
|
|
|
|
|
|
|
function __construct() {
|
|
|
|
$xml = $this->parseFeed();
|
|
|
|
|
|
|
|
$this->title = ucfirst(strtolower($xml->channel->title));
|
|
|
|
$this->desc = preg_replace(
|
|
|
|
"/<br \/>.+<\/p>/", "", $xml->channel->description
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->episodes = array();
|
|
|
|
foreach ($xml->channel->item as $epData) {
|
|
|
|
array_unshift($this->episodes,new Episode($epData));
|
|
|
|
}
|
|
|
|
|
|
|
|
//var_dump($this->episodes);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function parseFeed() {
|
|
|
|
// Renew cache if older than 5 minutes
|
2024-05-06 12:56:24 +02:00
|
|
|
if (time() - filemtime("tools/podcast.rss") > 5*60) {
|
2024-05-06 12:52:55 +02:00
|
|
|
$data = file_get_contents("https://feeds.acast.com/public/shows/le-plus-beau-des-voyages");
|
2024-05-06 12:56:24 +02:00
|
|
|
file_put_contents("tools/podcast.rss",$data);
|
2024-05-06 12:52:55 +02:00
|
|
|
}
|
|
|
|
$cachedFeedData = file_get_contents("tools/podcast.rss");
|
|
|
|
return simplexml_load_string($cachedFeedData,'SimpleXMLElement', LIBXML_NOCDATA);;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|