Compare commits

...

2 commits

Author SHA1 Message Date
Renarde-dev
00468be4e9 Exclude cache from readme 2024-05-06 18:29:17 +02:00
Renarde-dev
c27bf0e11d PHP completed 2024-05-06 18:27:06 +02:00
4 changed files with 34 additions and 23 deletions

3
.gitignore vendored
View file

@ -1,2 +1 @@
scss/*.map tools/*.rss
feed.json

View file

@ -45,13 +45,20 @@
<div> <div>
<h3><?= $podcast->episodes[0]->title; ?></h3> <h3><?= $podcast->episodes[0]->title; ?></h3>
<div><?= $podcast->episodes[0]->pubDate; ?></div> <div><?= $podcast->episodes[0]->pubDate; ?></div>
<p><?= $podcast->episodes[0]->desc ?></p> <div><?= $podcast->episodes[0]->desc ?></div>
<audio controls <?= $podcast->episodes[0]->getFormatedAudioData(); ?>"></audio> <audio controls=true <?= $podcast->episodes[0]->audioData; ?>></audio>
</div> </div>
</div> </div>
<script type="text/javascript" src="tools/script.js"></script> <script type="text/javascript" src="tools/script.js"></script>
<div hidden> <div>
<?php foreach ($podcast->episodes as $key => $ep) {
echo "<div class=\"ep{$key}\" hidden>
<h3>{$ep->title}</h3>
<div>{$ep->pubDate}</div>
<div>{$ep->desc}</div>
<audio controls=true {$ep->audioData}></audio>
</div>";
} ?>
</div> </div>
</body> </body>
</html> </html>

View file

@ -5,21 +5,33 @@ class Episode {
public string $title; public string $title;
public string $pubDate; public string $pubDate;
public string $desc; public string $desc;
public array $audioData; public string $audioData;
function __construct($epData) { function __construct($epData) {
$this->title = $epData->title; $this->title = $epData->title;
$this->pubDate = "date"; $this->pubDate = $this->formatDate($epData->pubDate);
$this->desc = "description"; $this->desc = preg_replace("/<br \/>.+<\/p>/", "", $epData->description);
$this->audioData = [ $this->audioData = $this->formatAudioData($epData->enclosure->attributes());
"url" => "https", }
"length" => "1",
"type" => "mp3" function formatDate($date) {
]; $fmt = new \IntlDateFormatter("fr_FR", null, null);
$fmt->setPattern('d MMMM yyyy HH:mm');
$dateTimeCFF = \DateTime::createFromFormat(
\DateTime::RFC7231,
$date
);
return $fmt->format($dateTimeCFF);
}
function formatAudioData($rawAudioData) {
return "src={$rawAudioData->url}".
" type={$rawAudioData->type}".
" length={$rawAudioData->length}";
} }
function getFormatedAudioData() { function getFormatedAudioData() {
return "src=\"{$this->audioData["url"]}\" type={}"; return "src={$this->audioData["url"]} length={$this->audioData["length"]} type={$this->audioData["type"]}";
} }
} }
?> ?>

View file

@ -10,19 +10,12 @@ class Podcast {
function __construct() { function __construct() {
$xml = $this->parseFeed(); $xml = $this->parseFeed();
$this->title = ucfirst(strtolower($xml->channel->title)); $this->title = ucfirst(strtolower($xml->channel->title));
$this->desc = preg_replace( $this->desc = preg_replace("/<br \/>.+<\/p>/", "", $xml->channel->description);
"/<br \/>.+<\/p>/", "", $xml->channel->description
);
$this->episodes = array(); $this->episodes = array();
foreach ($xml->channel->item as $epData) { foreach ($xml->channel->item as $epData) {
array_unshift($this->episodes,new Episode($epData)); array_unshift($this->episodes,new Episode($epData));
} }
//var_dump($this->episodes);
} }
function parseFeed() { function parseFeed() {