podcast.js 460 B

1234567891011121314151617
  1. import getPodcastFromFeed from "podparse";
  2. /* Avoids "mixed content" problems, hoping for the best */
  3. function httpsIze(url) {
  4. if (location.protocol === "https:" && url.startsWith("http:")) {
  5. return url.replace("http:", "https:");
  6. }
  7. return url;
  8. }
  9. async function getPodcast(url) {
  10. let feedContent = await fetch(httpsIze(url));
  11. feedContent = await feedContent.text();
  12. return await getPodcastFromFeed(feedContent);
  13. }
  14. export default getPodcast;