Compare commits

..

No commits in common. "00468be4e99025444fa90ba42cc4851931966225" and "1170a04b455be7544632d1dbf747ae503636f3bd" have entirely different histories.

4 changed files with 23 additions and 34 deletions

3
.gitignore vendored
View file

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

View file

@ -45,20 +45,13 @@
<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>
<div><?= $podcast->episodes[0]->desc ?></div> <p><?= $podcast->episodes[0]->desc ?></p>
<audio controls=true <?= $podcast->episodes[0]->audioData; ?>></audio> <audio controls <?= $podcast->episodes[0]->getFormatedAudioData(); ?>"></audio>
</div> </div>
</div> </div>
<script type="text/javascript" src="tools/script.js"></script> <script type="text/javascript" src="tools/script.js"></script>
<div> <div hidden>
<?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,33 +5,21 @@ class Episode {
public string $title; public string $title;
public string $pubDate; public string $pubDate;
public string $desc; public string $desc;
public string $audioData; public array $audioData;
function __construct($epData) { function __construct($epData) {
$this->title = $epData->title; $this->title = $epData->title;
$this->pubDate = $this->formatDate($epData->pubDate); $this->pubDate = "date";
$this->desc = preg_replace("/<br \/>.+<\/p>/", "", $epData->description); $this->desc = "description";
$this->audioData = $this->formatAudioData($epData->enclosure->attributes()); $this->audioData = [
} "url" => "https",
"length" => "1",
function formatDate($date) { "type" => "mp3"
$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"]} length={$this->audioData["length"]} type={$this->audioData["type"]}"; return "src=\"{$this->audioData["url"]}\" type={}";
} }
} }
?> ?>

View file

@ -10,12 +10,19 @@ 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("/<br \/>.+<\/p>/", "", $xml->channel->description); $this->desc = preg_replace(
"/<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() {