Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(wcostream): add option for non iframe video #8884

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion websites/W/Wcostream/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
"url": "www.wcostream.com",
"regExp": "(www[.])?wcostream[.].{2,5}",
"version": "1.1.11",
"version": "1.1.12",
"logo": "https://cdn.rcd.gg/PreMiD/websites/W/Wcostream/assets/logo.png",
"thumbnail": "https://cdn.rcd.gg/PreMiD/websites/W/Wcostream/assets/thumbnail.png",
"color": "#FFCE39",
Expand All @@ -22,7 +22,7 @@
"streaming"
],
"iframe": true,
"iFrameRegExp": ".*",

Check warning on line 25 in websites/W/Wcostream/metadata.json

View workflow job for this annotation

GitHub Actions / Presence Validator

Presence (Wcostream) has metadata.iFrameRegExp set to '.*', please change this if possible
"settings": [
{
"id": "timestamps",
Expand Down
29 changes: 27 additions & 2 deletions websites/W/Wcostream/presence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,16 @@ presence.on("UpdateData", async () => {
presence.getSetting<boolean>("timestamps"),
presence.getSetting<boolean>("cover"),
presence.getSetting<boolean>("buttons"),
]);
]),
directVideo = document.querySelector<HTMLVideoElement>("video");

if (video.timeLeft !== "") {
if (!title) {
title =
document.querySelector('[itemprop="partOfSeries"]')?.textContent ??
document.querySelector(".video-title")?.textContent ??
document.querySelector(".entry-title")?.textContent;
document.querySelector(".entry-title")?.textContent ??
document.title.split("|")[0];
}
presenceData.details = "Watching:";
presenceData.state = title?.split("Episode")?.[0];
Expand All @@ -58,6 +61,27 @@ presence.on("UpdateData", async () => {
presenceData.smallImageKey = video.paused ? Assets.Pause : Assets.Play;
presenceData.smallImageText = video.paused ? "Paused" : "Playing";
presenceData.buttons = [{ label: "Watch Episode", url: document.URL }];
} else if (directVideo) {
presenceData.smallImageKey = directVideo.paused
? Assets.Pause
: Assets.Play;
presenceData.smallImageText = directVideo.paused
? "Paused"
: "Playing back";

presenceData.details = "Watching:";
presenceData.state =
document.querySelector(".jw-title-primary.jw-reset")?.textContent ??
document.querySelector('[itemprop="partOfSeries"]')?.textContent ??
document.querySelector(".video-title")?.textContent ??
document.querySelector(".entry-title")?.textContent;

presenceData.buttons = [{ label: "Watch Episode", url: document.URL }];

if (!directVideo.paused) {
[presenceData.startTimestamp, presenceData.endTimestamp] =
presence.getTimestampsfromMedia(directVideo);
}
} else if (pathname === "/") presenceData.details = "Home page";
else if (pathname.startsWith("/search")) {
presenceData.details = "Searching...";
Expand All @@ -75,5 +99,6 @@ presence.on("UpdateData", async () => {
delete presenceData.startTimestamp;
delete presenceData.endTimestamp;
}
if (presenceData.endTimestamp) presenceData.type = ActivityType.Watching;
presence.setActivity(presenceData);
});
Loading