Begin script rewrite
This commit is contained in:
parent
7b020f7dbe
commit
b4e360ef8a
1 changed files with 11 additions and 35 deletions
|
@ -7,47 +7,23 @@ function removeAcastBranding(description,removeBR) { // Retire la mention "hébe
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchRSSfeed() {
|
async function fetchRSSfeed() {
|
||||||
const RSS_URL = 'https://feeds.acast.com/public/shows/le-plus-beau-des-voyages';
|
const RSS_URL = "https://feeds.acast.com/public/shows/le-plus-beau-des-voyages";
|
||||||
const response = await fetch("https://api.rss2json.com/v1/api.json?rss_url=" + RSS_URL);
|
const RSS_API = "https://api.rss2json.com/v1/api.json?rss_url="
|
||||||
|
const response = await fetch( RSS_API + RSS_URL);
|
||||||
return await response.json();
|
return await response.json();
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatEpisodeIntoHTML(episode) {
|
|
||||||
|
|
||||||
const article = document.createElement("article");
|
|
||||||
article.className = "podcast";
|
|
||||||
|
|
||||||
const podcastTitle = document.createElement("h3");
|
|
||||||
podcastTitle.innerHTML = episode.title;
|
|
||||||
|
|
||||||
const podcastAudio = document.createElement("audio");
|
|
||||||
podcastAudio.setAttribute("controls",true);
|
|
||||||
podcastAudio.setAttribute("src",episode.enclosure.link);
|
|
||||||
podcastAudio.setAttribute("type",episode.enclosure.type);
|
|
||||||
podcastAudio.setAttribute("length",episode.enclosure.length)
|
|
||||||
podcastAudio.setAttribute("duration",episode.enclosure.duration)
|
|
||||||
|
|
||||||
const podcastDescription = document.createElement("div");
|
|
||||||
podcastDescription.className = "podcast-desc"
|
|
||||||
podcastDescription.innerHTML = removeAcastBranding(episode.description,true);
|
|
||||||
|
|
||||||
article.append(podcastTitle,podcastAudio,podcastDescription);
|
|
||||||
article.append(document.createElement("hr"))
|
|
||||||
|
|
||||||
return article
|
|
||||||
}
|
|
||||||
|
|
||||||
window.addEventListener("DOMContentLoaded", function () {
|
window.addEventListener("DOMContentLoaded", function () {
|
||||||
console.log(
|
console.log(
|
||||||
"Hewo, c'est renarde 🦊, la créatrice de ce site. Si tu veux trouver le code source du site c'est par ici -> "
|
"Hewo, c'est renarde 🦊, la créatrice de ce site.\nSi tu veux trouver le code source du site c'est par ici -> "
|
||||||
+ 'https://forgejo.la-taniere-solidaire.gay/Renarde/site-web-le-plus-beau-des-voyages'
|
+ 'https://forgejo.la-taniere-solidaire.gay/Renarde/site-web-le-plus-beau-des-voyages'
|
||||||
);
|
);
|
||||||
|
|
||||||
fetchRSSfeed().then( rssData => {
|
// fetchRSSfeed().then( rssData => {
|
||||||
document.getElementById("FeedDesc").innerHTML = removeAcastBranding(rssData.feed.description,false);
|
// document.getElementById("FeedDesc").innerHTML = removeAcastBranding(rssData.feed.description,false);
|
||||||
for (const episode of rssData.items) {
|
// for (const episode of rssData.items) {
|
||||||
const formatedEp = formatEpisodeIntoHTML(episode)
|
// const formatedEp = formatEpisodeIntoHTML(episode)
|
||||||
this.document.getElementById("Podcasts").append(formatedEp)
|
// this.document.getElementById("Podcasts").append(formatedEp)
|
||||||
}
|
// }
|
||||||
})
|
// })
|
||||||
})
|
})
|
Loading…
Reference in a new issue