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 presence #8327

Closed
wants to merge 1 commit into from
Closed
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
25 changes: 25 additions & 0 deletions websites/A/AnimeDrive/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"$schema": "https://schemas.premid.app/metadata/1.9",

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

View workflow job for this annotation

GitHub Actions / Presence Validator

Schema version is not up to date - expected: https://schemas.premid.app/metadata/1.10, got: https://schemas.premid.app/metadata/1.9
"author": {
"id": "291136400068444161",
"name": "ferivoq"
},
"service": "AnimeDrive",
"description": {
"en": "AnimeDrive is an anime streaming website with Hungarian subs/dubs"
},
"url": [
"animedrive.hu",
"www.animedrive.hu"
],
"version": "1.0.0",
"logo": "https://cdn.discordapp.com/icons/702098578251841577/be50b5dbcb30bd99512b6df29284db0c.webp",
"thumbnail": "https://i.imgur.com/uP6s5yc.png",
"color": "#6f0094",
"category": "anime",
"tags": [
"anime",
"animes",
"animedrive"
]
}
83 changes: 83 additions & 0 deletions websites/A/AnimeDrive/presence.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
const presence = new Presence({
clientId: "1211027222815711282",
}), browsingTimestamp = Math.floor(Date.now() / 1000);;

presence.on("UpdateData", async () => {
const presenceData: PresenceData = {
largeImageKey:
"https://cdn.discordapp.com/icons/702098578251841577/be50b5dbcb30bd99512b6df29284db0c.webp",
startTimestamp: browsingTimestamp,
buttons: [{
label: "Meglátogatás",
url: "https://animedrive.hu/"
}]
},
{ pathname, search } = document.location;

switch (pathname) {
case "/": {
presenceData.details = "Főoldal Böngészése";
break;
}
case "/search/": {
presenceData.details = "Anime Keresése";
break;
}
case "/anime/": {
if (search.startsWith("?id=")) {
const animeId = search.split("?id=")[1].split("&")[0];
const contentDiv = document.querySelector('.col-sm-12.col-md-8.col-lg-9');

Check failure on line 29 in websites/A/AnimeDrive/presence.ts

View workflow job for this annotation

GitHub Actions / Compile and Lint

Combine this with the previous 'const' statement

Check failure on line 29 in websites/A/AnimeDrive/presence.ts

View workflow job for this annotation

GitHub Actions / Compile and Lint

Strings must use doublequote
const h2Content = contentDiv ? contentDiv.querySelector('h2') : null;

Check failure on line 30 in websites/A/AnimeDrive/presence.ts

View workflow job for this annotation

GitHub Actions / Compile and Lint

Combine this with the previous 'const' statement

Check failure on line 30 in websites/A/AnimeDrive/presence.ts

View workflow job for this annotation

GitHub Actions / Compile and Lint

Strings must use doublequote
const h4Content = contentDiv ? contentDiv.querySelector('h4') : null;

Check failure on line 31 in websites/A/AnimeDrive/presence.ts

View workflow job for this annotation

GitHub Actions / Compile and Lint

Combine this with the previous 'const' statement

Check failure on line 31 in websites/A/AnimeDrive/presence.ts

View workflow job for this annotation

GitHub Actions / Compile and Lint

Strings must use doublequote

if (h4Content && h4Content.textContent.trim()) {
presenceData.details = `Adatlap böngészése:`;

Check failure on line 34 in websites/A/AnimeDrive/presence.ts

View workflow job for this annotation

GitHub Actions / Compile and Lint

Strings must use doublequote
presenceData.state = `${h2Content.textContent.trim()}`;
} else if (h2Content && h2Content.textContent.trim()) {
presenceData.details = `Adatlap böngészése:`;

Check failure on line 37 in websites/A/AnimeDrive/presence.ts

View workflow job for this annotation

GitHub Actions / Compile and Lint

Strings must use doublequote
presenceData.state = `${h2Content.textContent.trim()}`;
} else {
presenceData.details = `Adatlap böngészése:`;

Check failure on line 40 in websites/A/AnimeDrive/presence.ts

View workflow job for this annotation

GitHub Actions / Compile and Lint

Strings must use doublequote
presenceData.state = `ID: ${animeId}`;
}

presenceData.buttons.push({
label: "Adatlap",
url: `https://animedrive.hu/anime/?id=${animeId}`
});
} else {

Check failure on line 48 in websites/A/AnimeDrive/presence.ts

View workflow job for this annotation

GitHub Actions / Compile and Lint

Unnecessary { after 'else'
presenceData.details = "Anime Böngészése";
}
break;
}
case "/watch/": {
if (search.startsWith("?id=")) {
const animeId = search.split("?id=")[1].split("&")[0];
const linkElement = document.querySelector('a.text-white[href^="https://animedrive.hu/anime/?id="]');
const h2Element = linkElement ? linkElement.querySelector('h2') : null;

const episodeElement = document.querySelector('a.nk-pagination-current-white');
const epModified = episodeElement.textContent.match(/\d+/)[0];

Check warning on line 60 in websites/A/AnimeDrive/presence.ts

View workflow job for this annotation

GitHub Actions / Compile and Lint

Variable 'epModified' is only used once

if (h2Element && h2Element.textContent.trim()) {
presenceData.details = `${h2Element.textContent.trim()}`;
presenceData.state = `Epizód: ${episodeElement.textContent.trim()}`;
} else {
presenceData.details = `Adatlap böngészése:`;
presenceData.state = `ID: ${animeId}`;
}

presenceData.buttons.push({
label: "Lejátszás",
url: `https://animedrive.hu/watch/?id=${animeId}&ep=${epModified}`
});
} else {
presenceData.details = "Anime Nézése";
}
break;
}
default:
presenceData.details = "AnimeDrive Böngészése";
}
presence.setActivity(presenceData);
});
Loading