From 6193ae3301b45af7333eb057333571b2d716b284 Mon Sep 17 00:00:00 2001 From: Meffiu <42370647+Mefuuu@users.noreply.github.com> Date: Sat, 4 Nov 2023 08:31:42 +0100 Subject: [PATCH] feat(Vizjer): add Vizjer presence (#7717) * Add files via upload Signed-off-by: Meffiu <42370647+Mefuuu@users.noreply.github.com> * Add files via upload Signed-off-by: Meffiu <42370647+Mefuuu@users.noreply.github.com> * npm run lint Signed-off-by: Meffiu <42370647+Mefuuu@users.noreply.github.com> * Service name update Signed-off-by: Meffiu <42370647+Mefuuu@users.noreply.github.com> * Logo update Signed-off-by: Meffiu <42370647+Mefuuu@users.noreply.github.com> * Deleted comments Signed-off-by: Meffiu <42370647+Mefuuu@users.noreply.github.com> * document.URL to document.href replace Signed-off-by: Meffiu <42370647+Mefuuu@users.noreply.github.com> * iframe regex update Signed-off-by: Meffiu <42370647+Mefuuu@users.noreply.github.com> * fixes 512x512 logo replace return to document.URL cus .href does not exists Signed-off-by: Meffiu <42370647+Mefuuu@users.noreply.github.com> * fixes 512x512 logo update return to document.URL cus .href does not exist Signed-off-by: Meffiu <42370647+Mefuuu@users.noreply.github.com> * missclick Signed-off-by: Meffiu <42370647+Mefuuu@users.noreply.github.com> * URL to location.href replace Signed-off-by: Meffiu <42370647+Mefuuu@users.noreply.github.com> * logo quality enhance and iframe regex update Signed-off-by: Meffiu <42370647+Mefuuu@users.noreply.github.com> --------- Signed-off-by: Meffiu <42370647+Mefuuu@users.noreply.github.com> --- websites/V/Vizjer/iframe.ts | 13 +++ websites/V/Vizjer/metadata.json | 27 +++++ websites/V/Vizjer/presence.ts | 184 ++++++++++++++++++++++++++++++++ 3 files changed, 224 insertions(+) create mode 100644 websites/V/Vizjer/iframe.ts create mode 100644 websites/V/Vizjer/metadata.json create mode 100644 websites/V/Vizjer/presence.ts diff --git a/websites/V/Vizjer/iframe.ts b/websites/V/Vizjer/iframe.ts new file mode 100644 index 000000000000..3c8cefea1dac --- /dev/null +++ b/websites/V/Vizjer/iframe.ts @@ -0,0 +1,13 @@ +const iframe = new iFrame(); + +iframe.on("UpdateData", async () => { + const video = document.querySelector("video"); + + if (!isNaN(video?.duration)) { + iframe.send({ + current: video.currentTime, + duration: video.duration, + paused: video.paused, + }); + } +}); diff --git a/websites/V/Vizjer/metadata.json b/websites/V/Vizjer/metadata.json new file mode 100644 index 000000000000..674c427ece7a --- /dev/null +++ b/websites/V/Vizjer/metadata.json @@ -0,0 +1,27 @@ +{ + "$schema": "https://schemas.premid.app/metadata/1.9", + "author": { + "id": "334411435633541121", + "name": "meffiu" + }, + "service": "Vizjer", + "description": { + "en": "Polish site with free movies and series without registration.", + "pl": "Polska strona z darmowymi filmami i serialami bez rejestracji." + }, + "url": "vizjer.pl", + "version": "1.0.0", + "logo": "https://i.imgur.com/T8Nd7lj.png", + "thumbnail": "https://i.imgur.com/D1i1HI1.png", + "color": "#BABABA", + "category": "videos", + "tags": [ + "video", + "media", + "movies", + "series", + "tv" + ], + "iframe": true, + "iFrameRegExp": "prefulfilloverdoor[.]com|vidoza[.]net|vembed[.]net|upstream[.]to|streamvid[.]net|ds2play[.]com|doodstream[.]com|voe[.]sx|streamhide[.]to|vid-guard[.]com|mixdrop[.]co" +} \ No newline at end of file diff --git a/websites/V/Vizjer/presence.ts b/websites/V/Vizjer/presence.ts new file mode 100644 index 000000000000..5d306762dca0 --- /dev/null +++ b/websites/V/Vizjer/presence.ts @@ -0,0 +1,184 @@ +const presence = new Presence({ + clientId: "1167822908526170153", + }), + browsingTimestamp = Math.floor(Date.now() / 1000); + +let video = { + current: 0, + duration: 0, + paused: true, +}; + +const enum Assets { + Logo = "https://i.imgur.com/T8Nd7lj.png", +} + +presence.on( + "iFrameData", + (data: { current: number; duration: number; paused: boolean }) => { + video = data; + } +); + +presence.on("UpdateData", async () => { + const presenceData: PresenceData = { + largeImageKey: Assets.Logo, + startTimestamp: browsingTimestamp, + }, + { pathname, search, href } = document.location, + series = pathname.startsWith("/series/index/") ? pathname : null, + movies = pathname.startsWith("/filmy-online/") ? pathname : null; + switch (pathname) { + case "/wyszukiwanie": + if (search) { + presenceData.details = "Wyszukuje po frazie:"; + presenceData.state = search.split("=")[1]; + presenceData.smallImageKey = Assets.Search; + } + break; + case "/logowanie": + presenceData.details = "Przegląda stronę logowania..."; + presenceData.smallImageKey = Assets.Viewing; + break; + case "/rejestracja": + presenceData.details = "Przegląda stronę rejestracji..."; + presenceData.smallImageKey = Assets.Viewing; + break; + case "/regulamin": + presenceData.details = "Przegląda regulamin..."; + presenceData.smallImageKey = Assets.Viewing; + break; + case "/profil": + presenceData.details = "Przegląda swój profil..."; + presenceData.smallImageKey = Assets.Viewing; + break; + case "/twoje-materialy": + presenceData.details = "Przegląda swoje materiały..."; + presenceData.smallImageKey = Assets.Viewing; + break; + case movies: + presenceData.details = "Przegląda filmy online..."; + if (movies.includes("sort:date")) { + presenceData.details = + "Przegląda ostatnio zaaktualizowane filmy online..."; + } + if (movies.includes("sort:newlink")) + presenceData.details = "Przegląda ostatnio dodane filmy..."; + if (movies.includes("sort:vote")) + presenceData.details = "Przegląda filmy z największą liczbą głosów..."; + if (movies.includes("sort:premiere")) + presenceData.details = "Przegląda ostatnie premiery filmów..."; + if (movies.includes("sort:view")) + presenceData.details = "Przegląda filmy z największą liczbą odsłon..."; + if (movies.includes("sort:rate")) + presenceData.details = "Przegląda filmy z największą liczbą ocen..."; + presenceData.smallImageKey = Assets.Search; + presenceData.state = search + ? `Strona ${search.split("=")[1]}` + : "Strona 1"; + break; + case series: + presenceData.details = "Przegląda seriale online..."; + if (series.includes("sort:newest") || series.includes("sort:date")) + presenceData.details = "Przegląda najnowsze seriale online..."; + if (series.includes("sort:year")) + presenceData.details = "Przegląda ostatnie premiery seriali..."; + if (series.includes("sort:vote")) { + presenceData.details = + "Przegląda seriale z największą liczbą głosów..."; + } + if (series.includes("sort:view")) { + presenceData.details = + "Przegląda seriale z największą liczbą odsłon..."; + } + if (series.includes("sort:rate")) + presenceData.details = "Przegląda seriale z największą liczbą ocen..."; + presenceData.smallImageKey = Assets.Search; + presenceData.state = search + ? `Strona ${search.split("=")[1]}` + : "Strona 1"; + break; + case "/dla-dzieci/": + presenceData.details = "Przegląda filmy i seriale dla dzieci..."; + presenceData.state = search + ? `Strona ${search.split("=")[1]}` + : "Strona 1"; + presenceData.smallImageKey = Assets.Search; + break; + case "/premium": + presenceData.details = "Przegląda zakładkę premium..."; + presenceData.smallImageKey = Assets.Viewing; + break; + case "/ranking": + presenceData.details = "Przegląda ranking..."; + presenceData.smallImageKey = Assets.Viewing; + break; + case pathname.startsWith("/film/") ? pathname : null: + for (const info of document.querySelectorAll("div.info>ul")) { + if (info.children[0].textContent === "Rok: ") { + presenceData.details = `${ + document.querySelector("h2>span").textContent.split("/")[0] + } (${info.children[1].textContent})`; + } + } + presenceData.buttons = [{ label: "Oglądaj", url: href }]; + [presenceData.startTimestamp, presenceData.endTimestamp] = + presence.getTimestamps(video.current, video.duration); + presenceData.smallImageKey = Assets.Play; + presenceData.smallImageText = "Ogląda"; + if (video.paused) { + presenceData.smallImageKey = Assets.Pause; + presenceData.smallImageText = "Wstrzymano"; + delete presenceData.startTimestamp; + delete presenceData.endTimestamp; + } + break; + case pathname.startsWith("/serial-online/") ? pathname : null: { + if (document.querySelector("div.btn-group")) { + presenceData.details = document + .querySelectorAll("h2")[1] + .textContent.split("/")[0]; + const seasonepisode = document + .querySelector("h3") + .textContent.split(" ")[0], + regex = /\[s(\d+)e(\d+)\]/; + presenceData.state = `Sezon: ${ + seasonepisode.match(regex)[1] + } | Odcinek: ${seasonepisode.match(regex)[2]}`; + presenceData.buttons = [ + { label: "Oglądaj", url: href }, + { + label: "Cały serial", + url: document + .querySelector("div#single-poster>a") + .getAttribute("href"), + }, + ]; + [presenceData.startTimestamp, presenceData.endTimestamp] = + presence.getTimestamps(video.current, video.duration); + presenceData.smallImageKey = Assets.Play; + presenceData.smallImageText = "Ogląda"; + if (video.paused) { + presenceData.smallImageKey = Assets.Pause; + presenceData.smallImageText = "Wstrzymano"; + delete presenceData.startTimestamp; + delete presenceData.endTimestamp; + } + } else { + const infos = document.querySelector("div.info>ul").children; + presenceData.details = `${ + document.querySelectorAll("h2")[1].textContent.split("/")[0] + } (${infos[infos.length - 1].textContent})`; + presenceData.buttons = [{ label: "Zobacz serial", url: href }]; + } + break; + } + default: + presenceData.details = "Przegląda stronę główną..."; + presenceData.smallImageKey = Assets.Viewing; + break; + } + + if (!presenceData.details) presence.setActivity(); + else presence.setActivity(presenceData); +});