Compare commits
2 commits
1170a04b45
...
00468be4e9
Author | SHA1 | Date | |
---|---|---|---|
|
00468be4e9 | ||
|
c27bf0e11d |
4 changed files with 34 additions and 23 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -1,2 +1 @@
|
|||
scss/*.map
|
||||
feed.json
|
||||
tools/*.rss
|
15
index.php
15
index.php
|
@ -45,13 +45,20 @@
|
|||
<div>
|
||||
<h3><?= $podcast->episodes[0]->title; ?></h3>
|
||||
<div><?= $podcast->episodes[0]->pubDate; ?></div>
|
||||
<p><?= $podcast->episodes[0]->desc ?></p>
|
||||
<audio controls <?= $podcast->episodes[0]->getFormatedAudioData(); ?>"></audio>
|
||||
<div><?= $podcast->episodes[0]->desc ?></div>
|
||||
<audio controls=true <?= $podcast->episodes[0]->audioData; ?>></audio>
|
||||
</div>
|
||||
</div>
|
||||
<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>
|
||||
</body>
|
||||
</html>
|
|
@ -5,21 +5,33 @@ class Episode {
|
|||
public string $title;
|
||||
public string $pubDate;
|
||||
public string $desc;
|
||||
public array $audioData;
|
||||
public string $audioData;
|
||||
|
||||
function __construct($epData) {
|
||||
$this->title = $epData->title;
|
||||
$this->pubDate = "date";
|
||||
$this->desc = "description";
|
||||
$this->audioData = [
|
||||
"url" => "https",
|
||||
"length" => "1",
|
||||
"type" => "mp3"
|
||||
];
|
||||
$this->pubDate = $this->formatDate($epData->pubDate);
|
||||
$this->desc = preg_replace("/<br \/>.+<\/p>/", "", $epData->description);
|
||||
$this->audioData = $this->formatAudioData($epData->enclosure->attributes());
|
||||
}
|
||||
|
||||
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() {
|
||||
return "src=\"{$this->audioData["url"]}\" type={}";
|
||||
return "src={$this->audioData["url"]} length={$this->audioData["length"]} type={$this->audioData["type"]}";
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -10,19 +10,12 @@ class Podcast {
|
|||
|
||||
function __construct() {
|
||||
$xml = $this->parseFeed();
|
||||
|
||||
$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();
|
||||
foreach ($xml->channel->item as $epData) {
|
||||
array_unshift($this->episodes,new Episode($epData));
|
||||
}
|
||||
|
||||
//var_dump($this->episodes);
|
||||
|
||||
}
|
||||
|
||||
function parseFeed() {
|
||||
|
|
Loading…
Reference in a new issue