Skip to content

Commit

Permalink
Added support for iFrame + Hungarian description
Browse files Browse the repository at this point in the history
Signed-off-by: FeriVOQ <[email protected]>
  • Loading branch information
ferivoq authored May 1, 2024
1 parent 7c63ef3 commit 9195332
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 12 deletions.
13 changes: 13 additions & 0 deletions websites/A/AnimeDrive/iframe.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const iframe = new iFrame();

iframe.on("UpdateData", async () => {
const video = document.querySelector("video");

if (video) {
iframe.send({
currentTime: video.currentTime,
paused: video.paused,
duration: video.duration,
});
} else console.error("Video element not found.");

Check warning on line 12 in websites/A/AnimeDrive/iframe.ts

View workflow job for this annotation

GitHub Actions / Compile and Lint

Unexpected console statement
});
13 changes: 8 additions & 5 deletions websites/A/AnimeDrive/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,23 @@
},
"service": "AnimeDrive",
"description": {
"en": "AnimeDrive is an anime streaming website with Hungarian subs/dubs"
"en": "AnimeDrive is an anime streaming website with Hungarian subs/dubs",
"hu": "Az AnimeDrive egy anime streaming weboldal Magyar felirattal/szinkronnal"
},
"url": [
"animedrive.hu",
"www.animedrive.hu"
],
"version": "1.0.1",
"logo": "https://cdn.rcd.gg/PreMiD/websites/A/AnimeDrive/assets/logo.png",
"thumbnail": "https://cdn.rcd.gg/PreMiD/websites/A/AnimeDrive/assets/thumbnail.png",
"version": "1.0.0",

Check failure on line 16 in websites/A/AnimeDrive/metadata.json

View workflow job for this annotation

GitHub Actions / Presence Validator

Version has not been bumped
"logo": "https://cdn.discordapp.com/icons/702098578251841577/be50b5dbcb30bd99512b6df29284db0c.webp",
"thumbnail": "https://i.imgur.com/uP6s5yc.png",
"color": "#6f0094",
"category": "anime",
"tags": [
"anime",
"animes",
"animedrive"
]
],
"iframe": true,
"iFrameRegExp": ".*"

Check warning on line 27 in websites/A/AnimeDrive/metadata.json

View workflow job for this annotation

GitHub Actions / Presence Validator

Presence has metadata.iFrameRegExp set to '.*', please change this if possible
}
39 changes: 32 additions & 7 deletions websites/A/AnimeDrive/presence.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
const presence = new Presence({
clientId: "1211027222815711282",
}),
browsingTimestamp = Math.floor(Date.now() / 1000);
clientId: "1211027222815711282",
});

let videoData: {
duration: number;
paused: boolean;
currentTime: number;
};

presence.on("iFrameData", (data: typeof videoData) => {
videoData = data;
});

presence.on("UpdateData", async () => {
const presenceData: PresenceData = {
largeImageKey:
"https://cdn.rcd.gg/PreMiD/websites/A/AnimeDrive/assets/logo.png",
startTimestamp: browsingTimestamp,
largeImageKey: "https://i.imgur.com/VlBtvJo.png",
},
{ pathname, search } = document.location;

Expand Down Expand Up @@ -60,7 +67,9 @@ presence.on("UpdateData", async () => {
);
if (h2Element && h2Element.textContent.trim()) {
presenceData.details = `${h2Element.textContent.trim()}`;
presenceData.state = `Epizód: ${episodeElement.textContent.trim()}`;
presenceData.state = `${
episodeElement.textContent.match(/\d+/)[0]
}. rész`;
} else {
presenceData.details = "Adatlap böngészése:";
presenceData.state = `ID: ${animeId}`;
Expand All @@ -74,6 +83,22 @@ presence.on("UpdateData", async () => {
}`,
},
];

if (videoData) {
presenceData.smallImageKey = videoData.paused
? Assets.Pause
: Assets.Play;
presenceData.smallImageText = videoData.paused ? "Szünet" : "Néz";

if (!videoData.paused) {
const [startTimestamp, endTimestamp] = presence.getTimestamps(
videoData.currentTime,
videoData.duration
);
presenceData.startTimestamp = startTimestamp;
presenceData.endTimestamp = endTimestamp;
}
}
} else presenceData.details = "Anime Nézése";

break;
Expand Down

0 comments on commit 9195332

Please sign in to comment.