diff --git a/websites/P/Podurama/metadata.json b/websites/P/Podurama/metadata.json new file mode 100644 index 000000000000..94ba86299164 --- /dev/null +++ b/websites/P/Podurama/metadata.json @@ -0,0 +1,28 @@ +{ + "$schema": "https://schemas.premid.app/metadata/1.10", + "author": { + "id": "358402930191106049", + "name": "ion606" + }, + "service": "Podurama", + "description": { + "en": "Best free podcast player to listen to free podcasts, add custom rss feeds or upload your private files on mobile and desktop devices. Discover over 2M podcasts and millions of episodes." + }, + "url": "podurama.com", + "version": "1.0.0", + "logo": "https://i.imgur.com/tetKhbd.png", + "thumbnail": "https://i.imgur.com/GbwflGj.png", + "color": "#4B5458", + "category": "other", + "tags": [ + "podurama" + ], + "settings": [ + { + "id": "usetimeleft", + "title": "Use time left", + "icon": "fad fa-stopwatch", + "value": true + } + ] +} \ No newline at end of file diff --git a/websites/P/Podurama/presence.ts b/websites/P/Podurama/presence.ts new file mode 100644 index 000000000000..b3de90fddafe --- /dev/null +++ b/websites/P/Podurama/presence.ts @@ -0,0 +1,123 @@ +const presence = new Presence({ + clientId: "1234257543467892826", + }), + browsingTimestamp = Math.floor(Date.now() / 1000); + +const enum Assets { + Logo = "https://i.imgur.com/tetKhbd.png", +} + +const enum Pages { + home = "home", + podcast = "podcast", + episode = "episode", + bookmarks = "bookmarks", + recent = "recently-played", + Trending = "top-charts", + myPodcasts = "subscribed-podcasts", + newEps = "new-episodes", + myFiles = "my-files", + favorites = "favourites", + tags = "tags", + Bookmarks = "bookmarks", + followed = "followed-playlists", +} + +presence.on("UpdateData", async () => { + const presenceData: PresenceData = { + largeImageKey: Assets.Logo, + startTimestamp: browsingTimestamp, + }, + [, sect, subsect] = document.location.pathname.split("/"), + player = document.querySelector(".audio-player"), + useTimeLeft = await presence.getSetting("usetimeleft"); + + if (player) { + const audioEl = document.querySelector("audio"), + [startTS, endTS] = presence.getTimestampsfromMedia(audioEl); + presenceData.details = "Listening to a Podcast"; + presenceData.state = player.querySelector(".episode-title").textContent; + + if (audioEl.paused) { + delete presenceData.startTimestamp; + delete presenceData.endTimestamp; + } else { + presenceData.startTimestamp = startTS; + if (useTimeLeft) presenceData.endTimestamp = endTS; + else delete presenceData.endTimestamp; + } + + presenceData.smallImageKey = audioEl.paused ? Assets.Pause : Assets.Play; + presenceData.largeImageKey = player + ?.querySelector(".episode-details") + ?.querySelector("img")?.src; + } else { + switch (sect) { + case Pages.podcast: + { + const header = document.querySelector("header"); + presenceData.details = "Viewing Podcast Page"; + presenceData.state = header.querySelector("h1").textContent; + presenceData.largeImageKey = header.querySelector("img").src; + } + break; + + case Pages.episode: + { + presenceData.details = "Viewing Podcast Page"; + presenceData.state = + document.querySelector(".episode-title").textContent; + presenceData.largeImageKey = + document.querySelector(".main-img-loc").src; + } + break; + + case Pages.bookmarks: + presenceData.details = "Browsing Bookmarks"; + break; + + case Pages.Trending: + { + presenceData.details = "Browsing Trending Podcasts!"; + presenceData.state = `In the '${subsect.replaceAll( + "-", + " " + )}' category`; + } + break; + + case Pages.favorites: + presenceData.details = "Browsing Favorite Episodes!"; + break; + + case Pages.followed: + presenceData.details = "Browsing Followed Podcasts!"; + break; + + case Pages.myFiles: + presenceData.details = "Browsing My Files!"; + break; + + case Pages.myPodcasts: + presenceData.details = "Browsing Subcribed Podcasts!"; + break; + + case Pages.newEps: + presenceData.details = "Searching for New Episodes!"; + break; + + case Pages.recent: + presenceData.details = "Browsing Recently Played!"; + break; + + case Pages.tags: + presenceData.details = "Browsing Collections!"; + break; + + default: + presenceData.details = "Browsing the Site"; + } + } + + presence.setActivity(presenceData); +});