diff --git a/index.php b/index.php index 086510b..e6284b9 100644 --- a/index.php +++ b/index.php @@ -1,73 +1,35 @@ - - - - - - - - - - - Le plus beau des voyages - + + + + + + + + + + + + + + + + Le plus beau des voyages -.+<\/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 ?>

+ +

+ title ?> +

@@ -75,28 +37,21 @@
-

description ?>

+

+ desc ?> +


- +

episodes[0]->title; ?>

+
episodes[0]->pubDate; ?>
+

episodes[0]->desc ?>

+
- - - - - - \ No newline at end of file + + \ No newline at end of file diff --git a/tools/episode.php b/tools/episode.php new file mode 100644 index 0000000..dc1ce69 --- /dev/null +++ b/tools/episode.php @@ -0,0 +1,25 @@ +title = $epData->title; + $this->pubDate = "date"; + $this->desc = "description"; + $this->audioData = [ + "url" => "https", + "length" => "1", + "type" => "mp3" + ]; + } + + function getFormatedAudioData() { + return "src=\"{$this->audioData["url"]}\" type={}"; + } +} +?> \ No newline at end of file diff --git a/tools/podcast.php b/tools/podcast.php new file mode 100644 index 0000000..55570f5 --- /dev/null +++ b/tools/podcast.php @@ -0,0 +1,38 @@ +parseFeed(); + + $this->title = ucfirst(strtolower($xml->channel->title)); + $this->desc = preg_replace( + "/
.+<\/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 + if (time() - filemtime("assets/podcast.rss") > 5*60) { + $data = file_get_contents("https://feeds.acast.com/public/shows/le-plus-beau-des-voyages"); + file_put_contents("assets/podcast.rss",$data); + } + $cachedFeedData = file_get_contents("tools/podcast.rss"); + return simplexml_load_string($cachedFeedData,'SimpleXMLElement', LIBXML_NOCDATA);; + } +} +?> \ No newline at end of file