Skip to content

Commit

Permalink
Real Second Fix Errors Recover
Browse files Browse the repository at this point in the history
  • Loading branch information
ArthurAugis committed Sep 29, 2024
1 parent b8c22f7 commit 6b09687
Showing 1 changed file with 44 additions and 14 deletions.
58 changes: 44 additions & 14 deletions websites/W/Watch-Anime/presence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,58 @@ async function getInformationAnime(nameAnime: string): Promise<AnimeInfo | null>
img: data[0].affiche_anime,
name: data[0].nom_anime
};
} else {

Check failure on line 17 in websites/W/Watch-Anime/presence.ts

View workflow job for this annotation

GitHub Actions / Compile and Lint

Unnecessary { after 'else'
throw new Error("Aucun anime trouvé");
}
} catch (error) {
console.error("Erreur lors de la récupération de l\'image de l\'anime:", error);
console.error("Erreur lors de la récupération de l'image de l'anime:", error);

Check warning on line 21 in websites/W/Watch-Anime/presence.ts

View workflow job for this annotation

GitHub Actions / Compile and Lint

Unexpected console statement
return null;
}
}

function getTimestampsFromMedia(mediaElement: HTMLMediaElement) {

Check failure on line 26 in websites/W/Watch-Anime/presence.ts

View workflow job for this annotation

GitHub Actions / Compile and Lint

'getTimestampsFromMedia' is defined but never used
if (!mediaElement) {

Check failure on line 27 in websites/W/Watch-Anime/presence.ts

View workflow job for this annotation

GitHub Actions / Compile and Lint

Unnecessary { after 'if' condition
throw new Error("L'élément média est invalide.");
}

const { currentTime, duration } = mediaElement;
const startTimestamp = Date.now() - currentTime * 1000;

Check failure on line 32 in websites/W/Watch-Anime/presence.ts

View workflow job for this annotation

GitHub Actions / Compile and Lint

Combine this with the previous 'const' statement
const endTimestamp = startTimestamp + duration * 1000;

Check failure on line 33 in websites/W/Watch-Anime/presence.ts

View workflow job for this annotation

GitHub Actions / Compile and Lint

Combine this with the previous 'const' statement

Check warning on line 33 in websites/W/Watch-Anime/presence.ts

View workflow job for this annotation

GitHub Actions / Compile and Lint

Variable 'endTimestamp' is only used once

return {
currentTime,
duration,
startTimestamp,
endTimestamp
};
}

function debugMode(word: unknown) {

Check failure on line 43 in websites/W/Watch-Anime/presence.ts

View workflow job for this annotation

GitHub Actions / Compile and Lint

'debugMode' is defined but never used
console.log("-------------------");

Check warning on line 44 in websites/W/Watch-Anime/presence.ts

View workflow job for this annotation

GitHub Actions / Compile and Lint

Unexpected console statement
console.log(word);

Check warning on line 45 in websites/W/Watch-Anime/presence.ts

View workflow job for this annotation

GitHub Actions / Compile and Lint

Unexpected console statement
console.log("-------------------");

Check warning on line 46 in websites/W/Watch-Anime/presence.ts

View workflow job for this annotation

GitHub Actions / Compile and Lint

Unexpected console statement
}
//#endregion FUNCTIONS

//#region PRESENCEDECLARATION
//#region PRESENCE DECLARATION
const presence = new Presence({
clientId: "1146930741570187385",
clientId: "1146930741570187385"
});

let browsingTimestamp = Math.floor(Date.now() / 1000);
const strings = presence.getStrings({

Check failure on line 55 in websites/W/Watch-Anime/presence.ts

View workflow job for this annotation

GitHub Actions / Compile and Lint

Combine this with the previous 'const' statement

Check failure on line 55 in websites/W/Watch-Anime/presence.ts

View workflow job for this annotation

GitHub Actions / Compile and Lint

'strings' is assigned a value but never used
play: "presence.playback.playing",
pause: "presence.playback.paused"
});

const browsingTimestamp = Math.floor(Date.now() / 1000);

Check failure on line 60 in websites/W/Watch-Anime/presence.ts

View workflow job for this annotation

GitHub Actions / Compile and Lint

Combine this with the previous 'const' statement

const enum Assets {
Logo = "https://watch-anime.fr/favicon.png",
Logo = "https://watch-anime.fr/favicon.png"
}
//#endregion PRESENCEDECLARATION
//#endregion PRESENCE DECLARATION

//#region PRESENCE CALL
presence.on("UpdateData", async () => {

let details: string | undefined;
let state: string | undefined;
let presenceData: PresenceData;
Expand All @@ -54,12 +83,13 @@ presence.on("UpdateData", async () => {
} else {
const pathParts = window.location.pathname.split("/");
if (pathParts[1] === "player" && pathParts.length >= 6) {
let animeName = decodeURIComponent(pathParts[2]);
const animeName = decodeURIComponent(pathParts[2]);

Check warning on line 86 in websites/W/Watch-Anime/presence.ts

View workflow job for this annotation

GitHub Actions / Compile and Lint

Variable 'animeName' is only used once
animeInfo = await getInformationAnime(animeName);
let language = pathParts[3];
let season = pathParts[4].split("-")[1]; // Saison
let episode = pathParts[5].split("-")[1]; // Episode
const language = pathParts[3];

Check warning on line 88 in websites/W/Watch-Anime/presence.ts

View workflow job for this annotation

GitHub Actions / Compile and Lint

Variable 'language' is only used once
const season = pathParts[4].split("-")[1]; // Saison

Check warning on line 89 in websites/W/Watch-Anime/presence.ts

View workflow job for this annotation

GitHub Actions / Compile and Lint

Variable 'season' is only used once
const episode = pathParts[5].split("-")[1]; // Episode

Check warning on line 90 in websites/W/Watch-Anime/presence.ts

View workflow job for this annotation

GitHub Actions / Compile and Lint

Variable 'episode' is only used once
urlAnime = `https://watch-anime.fr/${pathParts[1]}/${pathParts[2]}`;

if (animeInfo) {
details = `Visite la page de l'animé : ${animeInfo.name}`;
state = `Saison ${season} • Épisode ${episode}${language.toUpperCase()}`;
Expand All @@ -71,7 +101,7 @@ presence.on("UpdateData", async () => {
presenceData = {
details: details!,

Check warning on line 102 in websites/W/Watch-Anime/presence.ts

View workflow job for this annotation

GitHub Actions / Compile and Lint

Forbidden non-null assertion
largeImageKey: Assets.Logo,
startTimestamp: browsingTimestamp,
startTimestamp: browsingTimestamp
};
} else if (animeInfo) {
presenceData = {
Expand All @@ -89,9 +119,9 @@ presence.on("UpdateData", async () => {
url: urlAnime!
}
] as [ButtonData, ButtonData?]
}
};
}

presence.setActivity(presenceData);
});
//#endregion PRESENCE CALL
//#endregion PRESENCE CALL

0 comments on commit 6b09687

Please sign in to comment.