Skip to content

Commit

Permalink
fix(Prime Video): use built in getTimestamps function (#8831)
Browse files Browse the repository at this point in the history
* fix(Prime Video): use built in getTimestamps function

* chore: remove stray console.log

* chore: format

* chore: bump version
  • Loading branch information
veryCrunchy authored Oct 24, 2024
1 parent 3da10f1 commit d147598
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 21 deletions.
2 changes: 1 addition & 1 deletion websites/P/Prime Video/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
26 changes: 6 additions & 20 deletions websites/P/Prime Video/presence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -123,7 +110,6 @@ presence.on("UpdateData", async () => {
.split(/[”"]/);
presenceData.smallImageKey = Assets.Search;
}

if (presenceData.details) presence.setActivity(presenceData);
else presence.setActivity();
});

0 comments on commit d147598

Please sign in to comment.