|
1 | | -import { ActivityType, Assets } from 'premid' |
| 1 | +import { ActivityType, Assets, getTimestamps, getTimestampsFromMedia, timestampFromFormat } from 'premid' |
2 | 2 |
|
3 | 3 | const presence = new Presence({ |
4 | 4 | clientId: '645028677033132033', |
@@ -144,7 +144,7 @@ enum ActivityAssets { |
144 | 144 | const uploadedImages: Record<string, string> = {} |
145 | 145 | async function uploadImage(urlToUpload: string): Promise<string> { |
146 | 146 | if (isUploading) |
147 | | - return 'plex' |
| 147 | + return ActivityAssets.Logo |
148 | 148 |
|
149 | 149 | if (uploadedImages[urlToUpload]) |
150 | 150 | return uploadedImages[urlToUpload] |
@@ -215,31 +215,27 @@ presence.on('UpdateData', async () => { |
215 | 215 | .children |
216 | 216 | .length > 1 |
217 | 217 | ) { |
218 | | - [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestampsfromMedia(media!) |
| 218 | + [presenceData.startTimestamp, presenceData.endTimestamp] = getTimestampsFromMedia(media!) |
219 | 219 | } |
220 | 220 | else { |
221 | 221 | const formatTimestamps = document |
222 | 222 | .querySelector('[data-testid="mediaDuration"]') |
223 | 223 | ?.textContent |
224 | 224 | ?.split(' '); |
225 | 225 |
|
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] ?? ''), |
229 | 229 | ) |
230 | 230 | } |
231 | 231 |
|
232 | 232 | if (cover && navigator.mediaSession.metadata?.artwork?.[0]?.src) { |
233 | 233 | 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 | + ) |
243 | 239 | } |
244 | 240 |
|
245 | 241 | presenceData.smallImageKey = media?.paused ? Assets.Pause : Assets.Play |
|
0 commit comments