From d147598f06adcdd266dca5a5e8e95a0d07791e1c Mon Sep 17 00:00:00 2001 From: veryCrunchy Date: Thu, 24 Oct 2024 08:43:37 +0200 Subject: [PATCH] fix(Prime Video): use built in `getTimestamps` function (#8831) * fix(Prime Video): use built in getTimestamps function * chore: remove stray console.log * chore: format * chore: bump version --- websites/P/Prime Video/metadata.json | 2 +- websites/P/Prime Video/presence.ts | 26 ++++++-------------------- 2 files changed, 7 insertions(+), 21 deletions(-) diff --git a/websites/P/Prime Video/metadata.json b/websites/P/Prime Video/metadata.json index 67a2b17c4c6b..e334f5d3230f 100644 --- a/websites/P/Prime Video/metadata.json +++ b/websites/P/Prime Video/metadata.json @@ -20,7 +20,7 @@ }, "url": "www.primevideo.com", "regExp": "(([a-z0-9-]+[.])*amazon([.][a-z]+)+([/](-[/]([a-z0-9]+)[/])?(Prime-Video|Prime-Instant-Video|Amazon-Video|gp[/]video)?)?)|([a-z0-9-]+[.])*primevideo([.][a-z]+)+([/]?)?", - "version": "2.1.27", + "version": "2.1.28", "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Prime%20Video/assets/logo.png", "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Prime%20Video/assets/thumbnail.jpg", "color": "#FFFFFF", diff --git a/websites/P/Prime Video/presence.ts b/websites/P/Prime Video/presence.ts index 50f218d1ca74..6aa5aee61b64 100644 --- a/websites/P/Prime Video/presence.ts +++ b/websites/P/Prime Video/presence.ts @@ -7,19 +7,6 @@ const presence = new Presence({ }), browsingTimestamp = Math.floor(Date.now() / 1000); -/** - * Get Timestamps - * @param {Number} videoTime Current video time seconds - * @param {Number} videoDuration Video duration seconds - */ -function getTimestamps(videoTime: number, videoDuration: number): number[] { - const startTime = Date.now(); - return [ - Math.floor(startTime / 1000), - Math.floor(startTime / 1000) - videoTime + videoDuration, - ]; -} - presence.on("UpdateData", async () => { const presenceData: PresenceData = { type: ActivityType.Watching, @@ -67,9 +54,9 @@ presence.on("UpdateData", async () => { presenceData.smallImageText = (await strings).paused; delete presenceData.startTimestamp; } else { - const [startTimestamp, endTimestamp] = getTimestamps( - Math.floor(video.currentTime), - Math.floor(video.duration) + const [startTimestamp, endTimestamp] = presence.getTimestamps( + video.currentTime, + video.duration ); [presenceData.startTimestamp, presenceData.endTimestamp] = [ startTimestamp, @@ -85,9 +72,9 @@ presence.on("UpdateData", async () => { presenceData.smallImageText = (await strings).paused; delete presenceData.startTimestamp; } else { - const [startTimestamp, endTimestamp] = getTimestamps( - Math.floor(video.currentTime), - Math.floor(video.duration) + const [startTimestamp, endTimestamp] = presence.getTimestamps( + video.currentTime, + video.duration ); [presenceData.startTimestamp, presenceData.endTimestamp] = [ startTimestamp, @@ -123,7 +110,6 @@ presence.on("UpdateData", async () => { .split(/[”"]/); presenceData.smallImageKey = Assets.Search; } - if (presenceData.details) presence.setActivity(presenceData); else presence.setActivity(); });