From 480474d89c6d669bb05d6447c9f2dd13082e720b Mon Sep 17 00:00:00 2001 From: lxzy Date: Thu, 6 Aug 2026 04:40:22 -0700 Subject: [PATCH 1/3] Add Cinejoy Activity --- websites/C/Cinejoy/metadata.json | 25 +++++++++ websites/C/Cinejoy/presence.ts | 95 ++++++++++++++++++++++++++++++++ 2 files changed, 120 insertions(+) create mode 100644 websites/C/Cinejoy/metadata.json create mode 100644 websites/C/Cinejoy/presence.ts diff --git a/websites/C/Cinejoy/metadata.json b/websites/C/Cinejoy/metadata.json new file mode 100644 index 000000000000..785336991d12 --- /dev/null +++ b/websites/C/Cinejoy/metadata.json @@ -0,0 +1,25 @@ +{ + "$schema": "https://schemas.premid.app/metadata/1.17", + "apiVersion": 1, + "author": { + "id": "1233363061440512011", + "name": "lxzy" + }, + "service": "Cinejoy", + "description": { + "en": "Watch free movies and TV shows on Cinejoy." + }, + "url": "cinejoy.to", + "regExp": "^https?[:][/][/]([a-z0-9-]+[.])*cinejoy[.]to[/]", + "version": "1.0.0", + "logo": "https://cinejoy.to/favicon.ico", + "thumbnail": "https://i.imgur.com/S4XjEAo.jpeg", + "color": "#95FF50", + "category": "videos", + "tags": [ + "movie", + "tv", + "series", + "streaming" + ] +} \ No newline at end of file diff --git a/websites/C/Cinejoy/presence.ts b/websites/C/Cinejoy/presence.ts new file mode 100644 index 000000000000..285bb0f2e8a2 --- /dev/null +++ b/websites/C/Cinejoy/presence.ts @@ -0,0 +1,95 @@ +import { Assets, getTimestampsFromMedia } from 'premid' + +const presence = new Presence({ + clientId: '1534742028368347156', +}) + +const TMDB_KEY = '8476a7ab80ad76f0936744df0430e67c' +const TMDB_IMG = 'https://image.tmdb.org/t/p/w500' + +enum ActivityAssets { + Logo = 'https://cinejoy.to/favicon.ico', +} + +function parsePath() { + const path = document.location.pathname + const parts = path.split('/').filter(Boolean) + + const type = parts.find(p => p === 'tv' || p === 'movie') + if (!type) + return null + + const typeIndex = parts.indexOf(type) + const idPart = parts[typeIndex + 1] + const idMatch = idPart?.match(/^\d+/) + const tmdbId = idMatch?.[0] + if (!tmdbId) + return null + + const seasonPart = parts[typeIndex + 2] + const episodePart = parts[typeIndex + 3] + const season = seasonPart?.match(/\d+/)?.[0] + const episode = episodePart?.match(/\d+/)?.[0] + + return { type, tmdbId, season, episode } +} + +let cache: { key: string, details: any } | null = null + +async function getTmdbDetails(type: string, tmdbId: string) { + const key = `${type}-${tmdbId}` + if (cache?.key === key) + return cache.details + + const res = await fetch( + `https://api.themoviedb.org/3/${type}/${tmdbId}?api_key=${TMDB_KEY}&language=en-US`, + ) + const data = await res.json() + cache = { key, details: data } + return data +} + +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: ActivityAssets.Logo, + details: 'Browsing Cinejoy', + } + + const parsed = parsePath() + const video = document.querySelector('video') + + if (parsed) { + try { + const data = await getTmdbDetails(parsed.type, parsed.tmdbId) + const title = data.title ?? data.name ?? 'Unknown' + const posterPath = data.poster_path + + presenceData.details = title + + if (parsed.type === 'tv' && parsed.season && parsed.episode) { + presenceData.state = `S${parsed.season}:E${parsed.episode}` + } + else if (parsed.type === 'movie' && data.release_date) { + presenceData.state = data.release_date.split('-')[0] + } + + if (posterPath) { + presenceData.largeImageKey = `${TMDB_IMG}${posterPath}` + } + } + catch (err) { + presenceData.details = 'Watching Cinejoy' + } + } + + if (video && video.readyState > 0) { + presenceData.smallImageKey = video.paused ? Assets.Pause : Assets.Play + presenceData.smallImageText = video.paused ? 'Paused' : 'Playing' + + if (!video.paused && Number.isFinite(video.duration)) { + [presenceData.startTimestamp, presenceData.endTimestamp] = getTimestampsFromMedia(video) + } + } + + presence.setActivity(presenceData) +}) \ No newline at end of file From 13d5730443304572082122275604350ef7900f8a Mon Sep 17 00:00:00 2001 From: lxzy Date: Thu, 6 Aug 2026 13:55:47 -0700 Subject: [PATCH 2/3] fix: address lint and metadata errors --- websites/C/Cinejoy/metadata.json | 4 ++-- websites/C/Cinejoy/presence.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/websites/C/Cinejoy/metadata.json b/websites/C/Cinejoy/metadata.json index 785336991d12..b55ac158f1bb 100644 --- a/websites/C/Cinejoy/metadata.json +++ b/websites/C/Cinejoy/metadata.json @@ -12,7 +12,7 @@ "url": "cinejoy.to", "regExp": "^https?[:][/][/]([a-z0-9-]+[.])*cinejoy[.]to[/]", "version": "1.0.0", - "logo": "https://cinejoy.to/favicon.ico", + "logo": "https://i.imgur.com/O3iQzCt.png", "thumbnail": "https://i.imgur.com/S4XjEAo.jpeg", "color": "#95FF50", "category": "videos", @@ -22,4 +22,4 @@ "series", "streaming" ] -} \ No newline at end of file +} diff --git a/websites/C/Cinejoy/presence.ts b/websites/C/Cinejoy/presence.ts index 285bb0f2e8a2..c0e834b0d859 100644 --- a/websites/C/Cinejoy/presence.ts +++ b/websites/C/Cinejoy/presence.ts @@ -77,7 +77,7 @@ presence.on('UpdateData', async () => { presenceData.largeImageKey = `${TMDB_IMG}${posterPath}` } } - catch (err) { + catch { presenceData.details = 'Watching Cinejoy' } } @@ -92,4 +92,4 @@ presence.on('UpdateData', async () => { } presence.setActivity(presenceData) -}) \ No newline at end of file +}) From ca0d71106cd28bb2e1b8f9ea5922dc1c1c92dda8 Mon Sep 17 00:00:00 2001 From: lxzy Date: Fri, 7 Aug 2026 01:43:50 -0700 Subject: [PATCH 3/3] fix: resize logo to 512x512 --- websites/C/Cinejoy/metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websites/C/Cinejoy/metadata.json b/websites/C/Cinejoy/metadata.json index b55ac158f1bb..053b4ff0b637 100644 --- a/websites/C/Cinejoy/metadata.json +++ b/websites/C/Cinejoy/metadata.json @@ -12,7 +12,7 @@ "url": "cinejoy.to", "regExp": "^https?[:][/][/]([a-z0-9-]+[.])*cinejoy[.]to[/]", "version": "1.0.0", - "logo": "https://i.imgur.com/O3iQzCt.png", + "logo": "https://i.imgur.com/3wpcyto.png", "thumbnail": "https://i.imgur.com/S4XjEAo.jpeg", "color": "#95FF50", "category": "videos",