diff --git a/index.php b/index.php index 2cbb10e..5e9fcc6 100644 --- a/index.php +++ b/index.php @@ -19,31 +19,71 @@ - +.+<\/p>/", "", $text + ); + }; + + $formatDate = function($locale,$date) { + $fmt = new \IntlDateFormatter($locale, null, null); + $fmt->setPattern('d MMMM yyyy HH:mm'); + $dateTimeCFF = DateTime::createFromFormat( + DateTime::RFC7231, + $date + ); + return $fmt->format($dateTimeCFF); + }; + + $formatAudioData = function($rawAudioData) { + return "controls=true". + " src={$rawAudioData->url}". + " type={$rawAudioData->type}". + " length={$rawAudioData->length}"; + }; + + $data = file_get_contents( "https://feeds.acast.com/public/shows/le-plus-beau-des-voyages" ); + $xml = simplexml_load_string($data,'SimpleXMLElement', LIBXML_NOCDATA); + $podcast = (object) [ + "title" => ucfirst( + strtolower($xml->channel->title) + ), + "description" => $removeAcastBranding( + $xml->channel->description + ), + "latestEpTitle" => $xml->channel->item[0]->title, + "latestEpPublicationDate" => $formatDate( + "fr_FR",$xml->channel->item[0]->pubDate + ), + "latestEpDescription" => $removeAcastBranding( + $xml->channel->item[0]->description + ), + "latestEpAudioData" => $formatAudioData($xml->channel->item[0]->enclosure->attributes()) + ]; ?> - - + +

title ?>

Animé par Pauline

-

- description ?> -

-
- - -
-

Le dernier épisode :

-

latestEpTitle ?>

- latestEpPublicationDate ?> - -

latestEpDescription ?>

+

description ?>

+ +

Dernier épisode :

+
+ podcast logo +
+

latestEpTitle ?>

+
latestEpPublicationDate ?>
+
+
+
latestEpDescription ?>
+ +
\ No newline at end of file diff --git a/podcast.php b/podcast.php deleted file mode 100644 index 031591e..0000000 --- a/podcast.php +++ /dev/null @@ -1,63 +0,0 @@ - - * @link https://forgejo.la-taniere-solidaire.gay/Renarde/site-web-le-plus-beau-des-voyages - */ - -namespace podcast; - -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}"; - } -} -?>