* @link https://forgejo.la-taniere-solidaire.gay/Renarde/site-web-le-plus-beau-des-voyages */ class Podcast { public string $title; public string $description; public string $latestEpTitle; public string $latestEpDescription; public string $latestEpPublicationDate; public string $latestEpAudioData; /** * @param string $url RSS feed URL */ function __construct($url) { $data = file_get_contents($url); /** * TODO : Implement caching system * * file_put_contents("feed.rss", $FeedData); */ $xml = simplexml_load_string($data,'SimpleXMLElement', LIBXML_NOCDATA); $this->title = ucfirst(strtolower($xml->channel->title)); // Remove acast branding $this->description = preg_replace( "/
.+<\/p>/", "", $xml->channel->description ); $this->latestEpTitle = $xml->channel->item[0]->title; // Remove acast branding $this->latestEpDescription = preg_replace( "/
.+<\/p>/", "", $xml->channel->item[0]->description ); // Localize the date $fmt = new \IntlDateFormatter('fr_FR', null, null); $fmt->setPattern('d MMMM yyyy HH:mm'); $cff = DateTime::createFromFormat( DateTime::RFC7231, $xml->channel->item[0]->pubDate ); $this->latestEpPublicationDate = $fmt->format($cff); // Generate audio tags $rawAudioData = $xml->channel->item[0]->enclosure->attributes(); $this->latestEpAudioData = "src={$rawAudioData->url} " . "type={$rawAudioData->type} " . "length={$rawAudioData->length}"; } } ?>