Skip to content

Commit

Permalink
feat(Anime Sama): update timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
skullysmods committed Oct 25, 2024
1 parent f859875 commit 5f7c50a
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 25 deletions.
2 changes: 1 addition & 1 deletion websites/A/Anime Sama/iframe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const iframe = new iFrame();

iframe.on("UpdateData", async () => {
const video = document.querySelector<HTMLVideoElement>("video");
if (!isNaN(video?.duration)) {
if (video && !isNaN(video.duration)) {
iframe.send({
currentTime: video.currentTime,
duration: video.duration,
Expand Down
2 changes: 1 addition & 1 deletion websites/A/Anime Sama/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"vostfr"
],
"iframe": true,
"iFrameRegExp": ".*((sendvid)|(sibnet)|(myvi)).*",
"iFrameRegExp": ".*",

Check warning on line 33 in websites/A/Anime Sama/metadata.json

View workflow job for this annotation

GitHub Actions / Presence Validator

Presence (Anime Sama) has metadata.iFrameRegExp set to '.*', please change this if possible
"settings": [
{
"id": "buttons",
Expand Down
40 changes: 23 additions & 17 deletions websites/A/Anime Sama/presence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,18 @@ const enum Assets {
Logo = "https://cdn.rcd.gg/PreMiD/websites/A/Anime%20Sama/assets/logo.png",
}

interface IFrameData {
duration: number;
currentTime: number;
paused: boolean;
}

let duration: number,
currentTime: number,
paused = true;
let video = {
duration: 0,
currentTime: 0,
paused: true,
};

presence.on("iFrameData", (data: IFrameData) => {
({ duration, currentTime, paused } = data);
});
presence.on(
"iFrameData",
(data: { duration: number; currentTime: number; paused: boolean }) => {
if (data?.duration) video = data;
}
);

presence.on("UpdateData", async () => {
const presenceData: PresenceData = {
Expand Down Expand Up @@ -73,21 +72,28 @@ presence.on("UpdateData", async () => {
presenceData.details = `Regarde ${
document.querySelector("#titreOeuvre").textContent
}`;
const [startTimestamp, endTimestamp] = presence.getTimestamps(
video.currentTime,
video.duration
);
presenceData.state = `${season ? `${season} - ` : ""}${
selectEps.options[selectEps.selectedIndex].value
}`;

presenceData.buttons = [{ label: "Voir l'Anime", url: href }];
presenceData.smallImageKey = Assets.Pause;
presenceData.smallImageKey = video.paused ? Assets.Pause : Assets.Play;
presenceData.smallImageText =
selectLecteur.options[selectLecteur.selectedIndex].value;
presenceData.largeImageKey =
document.querySelector<HTMLMetaElement>("[property='og:image']")
?.content ?? Assets.Logo;
if (!paused) {
[presenceData.startTimestamp, presenceData.endTimestamp] =
presence.getTimestamps(currentTime, duration);
presenceData.smallImageKey = Assets.Play;
[presenceData.startTimestamp, presenceData.endTimestamp] = [
startTimestamp,
endTimestamp,
];
if (video.paused) {
delete presenceData.startTimestamp;
delete presenceData.endTimestamp;
}
if (privacyMode) {
delete presenceData.state;
Expand Down
12 changes: 6 additions & 6 deletions websites/V/Voiranime/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,17 @@
"id": "lang",
"multiLanguage": true
},
{
"id": "buttons",
"title": "Show Buttons",
"icon": "fas fa-compress-arrows-alt",
"value": true
},
{
"id": "privacy",
"title": "Privacy Mode",
"icon": "fad fa-user-secret",
"value": false
},
{
"id": "buttons",
"title": "Show Buttons",
"icon": "fas fa-compress-arrows-alt",
"value": true
}
]
}

0 comments on commit 5f7c50a

Please sign in to comment.