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

feat(AnimeDrive): add support for iFrame and Hungarian description #8343

Merged
merged 6 commits into from
May 3, 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
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,
});
}
});
11 changes: 7 additions & 4 deletions websites/A/AnimeDrive/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
},
"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",
"version": "1.0.2",
"logo": "https://cdn.rcd.gg/PreMiD/websites/A/AnimeDrive/assets/logo.png",
"thumbnail": "https://cdn.rcd.gg/PreMiD/websites/A/AnimeDrive/assets/thumbnail.png",
"color": "#6f0094",
Expand All @@ -21,5 +22,7 @@
"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
theusaf marked this conversation as resolved.
Show resolved Hide resolved
}
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
Loading