Skip to content

Commit 75f54cf

Browse files
Slowlife01Bas950
andauthored
chore(Plex): lint (#9321)
* chore(Plex): lint * chore: bump version Signed-off-by: Slowlife <slowlife1165@gmail.com> * fine * Update websites/P/Plex/metadata.json Signed-off-by: Bas van Zanten <bas.van.zanten007@gmail.com> --------- Signed-off-by: Slowlife <slowlife1165@gmail.com> Signed-off-by: Bas van Zanten <bas.van.zanten007@gmail.com> Co-authored-by: Bas van Zanten <bas.van.zanten007@gmail.com>
1 parent c1e8abb commit 75f54cf

File tree

2 files changed

+12
-16
lines changed

2 files changed

+12
-16
lines changed

websites/P/Plex/metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
},
1414
"url": "www.plex.tv",
1515
"regExp": "(([a-z0-9-]+[.])*plex[.]tv[/])|( *[/]web[/]index[.]html#)",
16-
"version": "1.10.6",
16+
"version": "1.10.8",
1717
"logo": "https://cdn.rcd.gg/PreMiD/websites/P/Plex/assets/logo.png",
1818
"thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Plex/assets/thumbnail.png",
1919
"color": "#d78c14",

websites/P/Plex/presence.ts

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ActivityType, Assets } from 'premid'
1+
import { ActivityType, Assets, getTimestamps, getTimestampsFromMedia, timestampFromFormat } from 'premid'
22

33
const presence = new Presence({
44
clientId: '645028677033132033',
@@ -144,7 +144,7 @@ enum ActivityAssets {
144144
const uploadedImages: Record<string, string> = {}
145145
async function uploadImage(urlToUpload: string): Promise<string> {
146146
if (isUploading)
147-
return 'plex'
147+
return ActivityAssets.Logo
148148

149149
if (uploadedImages[urlToUpload])
150150
return uploadedImages[urlToUpload]
@@ -215,31 +215,27 @@ presence.on('UpdateData', async () => {
215215
.children
216216
.length > 1
217217
) {
218-
[presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestampsfromMedia(media!)
218+
[presenceData.startTimestamp, presenceData.endTimestamp] = getTimestampsFromMedia(media!)
219219
}
220220
else {
221221
const formatTimestamps = document
222222
.querySelector('[data-testid="mediaDuration"]')
223223
?.textContent
224224
?.split(' ');
225225

226-
[presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestamps(
227-
presence.timestampFromFormat(formatTimestamps?.[0] ?? ''),
228-
presence.timestampFromFormat(formatTimestamps?.[1] ?? ''),
226+
[presenceData.startTimestamp, presenceData.endTimestamp] = getTimestamps(
227+
timestampFromFormat(formatTimestamps?.[0] ?? ''),
228+
timestampFromFormat(formatTimestamps?.[1] ?? ''),
229229
)
230230
}
231231

232232
if (cover && navigator.mediaSession.metadata?.artwork?.[0]?.src) {
233233
const art = navigator.mediaSession.metadata.artwork?.[0]?.src
234-
presenceData.largeImageKey = art?.match(
235-
/(\d+)(?<!10)-(\d+)(192-168)?(?<!172-(1[6-9]|2\d|3[01]))-(\d+)\.(\d+)/g,
236-
)?.[0] // Checks if it's a private ip, since u can't access that to use as a large/smallimagekey.
237-
? ActivityAssets.Logo // If it's a private ip, just use the logo.
238-
: await getShortURL(
239-
art
240-
.replace(/width=\d{1,3}/, 'width=1024')
241-
.replace(/height=\d{1,3}/, 'height=1024'),
242-
)
234+
presenceData.largeImageKey = await getShortURL(
235+
art
236+
.replace(/width=\d{1,3}/, 'width=1024')
237+
.replace(/height=\d{1,3}/, 'height=1024'),
238+
)
243239
}
244240

245241
presenceData.smallImageKey = media?.paused ? Assets.Pause : Assets.Play

0 commit comments

Comments
 (0)