From 0dc682edcdb30f35139012afc4d4e8ecc705bdf7 Mon Sep 17 00:00:00 2001 From: Bruno Ramos <37979213+Kuriel23@users.noreply.github.com> Date: Sun, 9 Mar 2025 20:30:21 +0000 Subject: [PATCH 1/4] feat(Hulu): add watching to activity chore(Hulu): add strings feat(Hulu): remove deprecated functions --- websites/H/Hulu/Hulu.json | 30 ++++++++++++++++ websites/H/Hulu/metadata.json | 9 +++-- websites/H/Hulu/presence.ts | 66 +++++++++++++++++++++++------------ 3 files changed, 80 insertions(+), 25 deletions(-) create mode 100644 websites/H/Hulu/Hulu.json diff --git a/websites/H/Hulu/Hulu.json b/websites/H/Hulu/Hulu.json new file mode 100644 index 000000000000..663171b620f9 --- /dev/null +++ b/websites/H/Hulu/Hulu.json @@ -0,0 +1,30 @@ +{ + "Hulu.viewNetwork": { + "description": "User is looking at a TV network.", + "message": "Viewing Network:" + }, + "Hulu.viewSportEpisode": { + "description": "User is watching a sports episode.", + "message": "Viewing Sports Episode:" + }, + "Hulu.viewSportTeam": { + "description": "User is viewing info about a sports team.", + "message": "Viewing Sports Team:" + }, + "Hulu.viewMyStuff": { + "description": "User is accessing their saved content.", + "message": "Viewing My Stuff" + }, + "Hulu.viewMyDVR": { + "description": "User is viewing their recorded shows.", + "message": "Viewing My DVR:" + }, + "Hulu.onHulu": { + "description": "User is viewing on Hulu.", + "message": "On Hulu" + }, + "Hulu.viewWatchHistory": { + "description": "User is looking at their watch history.", + "message": "Viewing Watch History" + } +} diff --git a/websites/H/Hulu/metadata.json b/websites/H/Hulu/metadata.json index 5fdf4e4c53ef..a20be324e9ac 100644 --- a/websites/H/Hulu/metadata.json +++ b/websites/H/Hulu/metadata.json @@ -13,6 +13,10 @@ { "name": "GURRMAN375D", "id": "446528923535278082" + }, + { + "name": "kuriel.", + "id": "354233941550694400" } ], "service": "Hulu", @@ -21,7 +25,8 @@ "en": "Watch current hit shows, classic series and acclaimed movies instantly with Hulu.", "fr": "Regardez des émissions à succès, des séries classiques et des films acclamés instantanément avec Hulu.", "nl": "Bekijk huidige hitshows, klassieke series en veelgeprezen films direct met Hulu.", - "pt-br": "Assista shows de sucesso, séries clássicas e filmes aclamados instanteamente com Hulu.", + "pt": "Veja programas de sucesso, séries clássicas e filmes aclamados instantaneamente com Hulu.", + "pt-br": "Assista shows de sucesso, séries clássicas e filmes aclamados instantaneamente com Hulu.", "ro": "Vizionează spectacolele de succes, seriale clasice și filme apreciate instantaneu cu Hulu.", "uk": "Дивіться поточні хітові шоу, класичні серіали та відомі фільми миттєво з Hulu." }, @@ -29,7 +34,7 @@ "hulu.com", "www.hulu.com" ], - "version": "1.3.35", + "version": "1.3.36", "logo": "https://cdn.rcd.gg/PreMiD/websites/H/Hulu/assets/logo.png", "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/H/Hulu/assets/thumbnail.jpg", "color": "#66AA33", diff --git a/websites/H/Hulu/presence.ts b/websites/H/Hulu/presence.ts index 3fcf9ca113a0..fe6b0a27eb4d 100644 --- a/websites/H/Hulu/presence.ts +++ b/websites/H/Hulu/presence.ts @@ -1,4 +1,4 @@ -import { Assets } from 'premid' +import { ActivityType, Assets, getTimestamps } from 'premid' const presence = new Presence({ clientId: '607719679011848220', @@ -8,6 +8,20 @@ const strings = presence.getStrings({ pause: 'general.paused', live: 'general.live', search: 'general.searching', + viewMovie: 'general.viewMovie', + viewCategory: 'general.viewCategory', + viewGenre: 'general.viewGenre', + viewSeries: 'general.viewSeries', + watchingLive: 'general.watchingLive', + watching: 'general.watching', + browsing: 'general.browsing', + viewNetwork: 'Hulu.viewNetwork', + viewSportEpisode: 'Hulu.viewSportEpisode', + viewSportTeam: 'Hulu.viewSportTeam', + viewMyStuff: 'Hulu.viewMyStuff', + viewMyDVR: 'Hulu.viewMyDVR', + onHulu: 'Hulu.onHulu', + viewWatchHistory: 'Hulu.viewWatchHistory', }) function capitalize(text: string): string { @@ -21,6 +35,7 @@ presence.on('UpdateData', async () => { let video: HTMLVideoElement | null = null let details let state + let name let smallImageKey let smallImageText let startTimestamp @@ -32,13 +47,13 @@ presence.on('UpdateData', async () => { elapsed = Math.floor(Date.now() / 1000) } - details = 'Browsing' + details = await (strings.browsing) startTimestamp = elapsed if (path.includes('/hub')) { header = document.querySelector('.Hub__title') title = document.querySelector('.SimpleModalNav__title') - details = 'Viewing Category' + details = await (strings.viewCategory) if (header) { state = header.textContent if (title) @@ -48,7 +63,7 @@ presence.on('UpdateData', async () => { else if (path.includes('/genre')) { header = document.querySelector('.Hub__title') title = document.querySelector('.SimpleModalNav__title') - details = 'Viewing Genre' + details = await (strings.viewGenre) if (header) { state = header.textContent if (title) @@ -58,7 +73,7 @@ presence.on('UpdateData', async () => { else if (path.includes('/series')) { title = document.querySelector('.Masthead__title') item = document.querySelector('.Subnav__item.active') - details = 'Viewing Series' + details = await (strings.viewSeries) if (title) { state = title.textContent if (item) @@ -68,7 +83,7 @@ presence.on('UpdateData', async () => { else if (path.includes('/movie')) { title = document.querySelector('.Masthead__title') item = document.querySelector('.Subnav__item.active') - details = 'Viewing Movie' + details = await (strings.viewMovie) if (title) { state = title.textContent if (item) @@ -80,7 +95,7 @@ presence.on('UpdateData', async () => { '.SimpleModalNav__brandImage', ) item = document.querySelector('.Subnav__item.active') - details = 'Viewing Network' + details = await (strings.viewNetwork) if (brand) { state = brand.alt if (item) @@ -90,7 +105,7 @@ presence.on('UpdateData', async () => { else if (path.includes('/sports_episode')) { title = document.querySelector('.Masthead__title') item = document.querySelector('.Subnav__item.active') - details = 'Viewing Sports Episode' + details = await (strings.viewSportEpisode) if (title) { state = title.textContent if (item) @@ -100,7 +115,7 @@ presence.on('UpdateData', async () => { else if (path.includes('/sports_team')) { title = document.querySelector('.Masthead__title') item = document.querySelector('.Subnav__item.active') - details = 'Viewing Sports Team' + details = await (strings.viewSportTeam) if (title) { state = title.textContent if (item) @@ -109,7 +124,7 @@ presence.on('UpdateData', async () => { } else if (path.includes('/search')) { const input = document.querySelector('.cu-search-input') - details = 'Searching' + details = (await strings).search smallImageKey = Assets.Search smallImageText = (await strings).search if (input && input.value.length > 0) @@ -120,7 +135,7 @@ presence.on('UpdateData', async () => { '.LiveGuide__filter-item--selected', ) title = document.querySelector('.ModalHeader__showname') - details = 'Viewing Live' + details = await (strings.watchingLive) if (category) { state = capitalize(category.textContent!) if (title) @@ -128,11 +143,11 @@ presence.on('UpdateData', async () => { } } else if (path.includes('/my-stuff')) { - details = 'Viewing My Stuff' + details = await (strings.viewMyStuff) } else if (path.includes('/manage-dvr')) { item = document.querySelector('.Subnav__item.active') - details = 'Viewing My DVR' + details = await (strings.viewMyDVR) if (item) state = capitalize(item.textContent!) } @@ -141,14 +156,16 @@ presence.on('UpdateData', async () => { if (video) { title = document.querySelector('.metadata-area__second-line') const content = document.querySelector('.metadata-area__third-line') - const timestamps = presence.getTimestamps( + const timestamps = getTimestamps( Math.floor(video.currentTime), Math.floor(video.duration), ) const live = timestamps[1] === Infinity - details = 'Watching' - if (title) - details = title.textContent + details = await (strings.watching) + if (title) { + details = await (strings.onHulu) + name = title.textContent + } if (content?.textContent && content.textContent.length > 0) state = content.textContent @@ -171,7 +188,7 @@ presence.on('UpdateData', async () => { } else { video = document.querySelector('video#content-video-player') - details = 'Viewing Watch History' + details = await (strings.viewWatchHistory) if (video) { title = document.querySelector( '#web-player-app div.PlayerMetadata__titleText', @@ -179,14 +196,16 @@ presence.on('UpdateData', async () => { const content = document.querySelector( '#web-player-app div.PlayerMetadata__subTitle', ) - const timestamps = presence.getTimestamps( + const timestamps = getTimestamps( Math.floor(video.currentTime), Math.floor(video.duration), ) const live = timestamps[1] === Infinity - details = 'Watching' - if (title) - details = title.textContent + details = await (strings.watching) + if (title) { + details = await (strings.onHulu) + name = title.textContent + } if (content?.textContent && content.textContent.length > 0) state = content.textContent @@ -212,7 +231,9 @@ presence.on('UpdateData', async () => { presence.setActivity( { + type: ActivityType.Watching, details, + name, state, largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/H/Hulu/assets/logo.png', smallImageKey, @@ -220,6 +241,5 @@ presence.on('UpdateData', async () => { startTimestamp, endTimestamp, }, - video ? !video.paused : true, ) }) From 56da8423060494a74d2325021b6fa5b0cf699242 Mon Sep 17 00:00:00 2001 From: Bruno Ramos <37979213+Kuriel23@users.noreply.github.com> Date: Sun, 9 Mar 2025 20:42:45 +0000 Subject: [PATCH 2/4] chore(Hulu): linting --- websites/H/Hulu/presence.ts | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/websites/H/Hulu/presence.ts b/websites/H/Hulu/presence.ts index fe6b0a27eb4d..bc9f7b2cb282 100644 --- a/websites/H/Hulu/presence.ts +++ b/websites/H/Hulu/presence.ts @@ -35,7 +35,7 @@ presence.on('UpdateData', async () => { let video: HTMLVideoElement | null = null let details let state - let name + let name: string | undefined; let smallImageKey let smallImageText let startTimestamp @@ -47,13 +47,13 @@ presence.on('UpdateData', async () => { elapsed = Math.floor(Date.now() / 1000) } - details = await (strings.browsing) + details = (await strings).browsing startTimestamp = elapsed if (path.includes('/hub')) { header = document.querySelector('.Hub__title') title = document.querySelector('.SimpleModalNav__title') - details = await (strings.viewCategory) + details = (await strings).viewCategory if (header) { state = header.textContent if (title) @@ -63,7 +63,7 @@ presence.on('UpdateData', async () => { else if (path.includes('/genre')) { header = document.querySelector('.Hub__title') title = document.querySelector('.SimpleModalNav__title') - details = await (strings.viewGenre) + details = (await strings).viewGenre if (header) { state = header.textContent if (title) @@ -73,7 +73,7 @@ presence.on('UpdateData', async () => { else if (path.includes('/series')) { title = document.querySelector('.Masthead__title') item = document.querySelector('.Subnav__item.active') - details = await (strings.viewSeries) + details = (await strings).viewSeries if (title) { state = title.textContent if (item) @@ -83,7 +83,7 @@ presence.on('UpdateData', async () => { else if (path.includes('/movie')) { title = document.querySelector('.Masthead__title') item = document.querySelector('.Subnav__item.active') - details = await (strings.viewMovie) + details = (await strings).viewMovie if (title) { state = title.textContent if (item) @@ -95,7 +95,7 @@ presence.on('UpdateData', async () => { '.SimpleModalNav__brandImage', ) item = document.querySelector('.Subnav__item.active') - details = await (strings.viewNetwork) + details = (await strings).viewNetwork if (brand) { state = brand.alt if (item) @@ -105,7 +105,7 @@ presence.on('UpdateData', async () => { else if (path.includes('/sports_episode')) { title = document.querySelector('.Masthead__title') item = document.querySelector('.Subnav__item.active') - details = await (strings.viewSportEpisode) + details = (await strings).viewSportEpisode if (title) { state = title.textContent if (item) @@ -115,7 +115,7 @@ presence.on('UpdateData', async () => { else if (path.includes('/sports_team')) { title = document.querySelector('.Masthead__title') item = document.querySelector('.Subnav__item.active') - details = await (strings.viewSportTeam) + details = (await strings).viewSportTeam if (title) { state = title.textContent if (item) @@ -135,7 +135,7 @@ presence.on('UpdateData', async () => { '.LiveGuide__filter-item--selected', ) title = document.querySelector('.ModalHeader__showname') - details = await (strings.watchingLive) + details = (await strings).watchingLive if (category) { state = capitalize(category.textContent!) if (title) @@ -143,11 +143,11 @@ presence.on('UpdateData', async () => { } } else if (path.includes('/my-stuff')) { - details = await (strings.viewMyStuff) + details = (await strings).viewMyStuff } else if (path.includes('/manage-dvr')) { item = document.querySelector('.Subnav__item.active') - details = await (strings.viewMyDVR) + details = (await strings).viewMyDVR if (item) state = capitalize(item.textContent!) } @@ -161,9 +161,9 @@ presence.on('UpdateData', async () => { Math.floor(video.duration), ) const live = timestamps[1] === Infinity - details = await (strings.watching) + details = (await strings).watching if (title) { - details = await (strings.onHulu) + details = (await strings).onHulu name = title.textContent } @@ -188,7 +188,7 @@ presence.on('UpdateData', async () => { } else { video = document.querySelector('video#content-video-player') - details = await (strings.viewWatchHistory) + details = (await strings).viewWatchHistory if (video) { title = document.querySelector( '#web-player-app div.PlayerMetadata__titleText', @@ -201,9 +201,9 @@ presence.on('UpdateData', async () => { Math.floor(video.duration), ) const live = timestamps[1] === Infinity - details = await (strings.watching) + details = (await strings).watching if (title) { - details = await (strings.onHulu) + details = (await strings).onHulu name = title.textContent } From 95b589b7ffafa21d9d7b649d1ebba78d64462100 Mon Sep 17 00:00:00 2001 From: Bruno Ramos <37979213+Kuriel23@users.noreply.github.com> Date: Sun, 9 Mar 2025 20:44:41 +0000 Subject: [PATCH 3/4] chore(Hulu): linting --- websites/H/Hulu/presence.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websites/H/Hulu/presence.ts b/websites/H/Hulu/presence.ts index bc9f7b2cb282..88cb58c94a3f 100644 --- a/websites/H/Hulu/presence.ts +++ b/websites/H/Hulu/presence.ts @@ -164,7 +164,7 @@ presence.on('UpdateData', async () => { details = (await strings).watching if (title) { details = (await strings).onHulu - name = title.textContent + name = title?.textContent } if (content?.textContent && content.textContent.length > 0) @@ -204,7 +204,7 @@ presence.on('UpdateData', async () => { details = (await strings).watching if (title) { details = (await strings).onHulu - name = title.textContent + name = title?.textContent } if (content?.textContent && content.textContent.length > 0) From f6ddd91be8ea9383e1aaecf7127a1d9d8e14101b Mon Sep 17 00:00:00 2001 From: Bruno Ramos <37979213+Kuriel23@users.noreply.github.com> Date: Sun, 9 Mar 2025 21:15:09 +0000 Subject: [PATCH 4/4] chore(Hulu): linting --- websites/H/Hulu/presence.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/websites/H/Hulu/presence.ts b/websites/H/Hulu/presence.ts index 88cb58c94a3f..747eaebe02b3 100644 --- a/websites/H/Hulu/presence.ts +++ b/websites/H/Hulu/presence.ts @@ -35,7 +35,7 @@ presence.on('UpdateData', async () => { let video: HTMLVideoElement | null = null let details let state - let name: string | undefined; + let name: string | undefined let smallImageKey let smallImageText let startTimestamp @@ -164,7 +164,7 @@ presence.on('UpdateData', async () => { details = (await strings).watching if (title) { details = (await strings).onHulu - name = title?.textContent + name = title?.textContent as string | undefined } if (content?.textContent && content.textContent.length > 0) @@ -204,7 +204,7 @@ presence.on('UpdateData', async () => { details = (await strings).watching if (title) { details = (await strings).onHulu - name = title?.textContent + name = title?.textContent as string | undefined } if (content?.textContent && content.textContent.length > 0)