From f732788687975510bbf2f8a77ea98c2bf6f70d2a Mon Sep 17 00:00:00 2001 From: Pulkit Pareek Date: Wed, 9 Oct 2024 15:51:12 +0530 Subject: [PATCH] Fix: Video Player Changed --- script.js | 10 +++++----- script.min.js | 14 +++++++++++++- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/script.js b/script.js index a753760..688e58a 100644 --- a/script.js +++ b/script.js @@ -51,7 +51,7 @@ function fetchAndShow() { let imageAndInfo = ""; if (result.qid === "movie" && result.i) { - imageAndInfo = ` + imageAndInfo = ` ${result.l}

${result.l}

@@ -59,7 +59,7 @@ function fetchAndShow() {
`; } else if (result.qid === "tvSeries" && result.i) { - imageAndInfo = ` + imageAndInfo = ` ${result.l}

${result.l}

@@ -88,7 +88,7 @@ function setAll(imdb, title, season, episode, type) { a.setAttribute("title", title); a.setAttribute("class", "links"); a.setAttribute("IMDB", imdb); - a.setAttribute("href", "https://multiembed.mov/directstream.php?video_id=" + imdb); + a.setAttribute("href", "https://www.2embed.cc/embed/" + imdb); a.setAttribute("target", "_blank"); a.click(); } else if (imdb && title && episode && !type) { @@ -103,7 +103,7 @@ function setAll(imdb, title, season, episode, type) { a.setAttribute("IMDB", imdb); a.setAttribute( "href", - `https://multiembed.mov/directstream.php?video_id=${imdb}&s=${season}&e=${episode}` + `https://www.2embed.cc/embedtv/${imdb}&s=${season}&e=${episode}` ); a.setAttribute("target", "_blank"); a.click(); @@ -337,7 +337,7 @@ function setVideo(element) { minimumIntegerDigits: 2, useGrouping: false, }); - episodesData += `
E${formatedEpisodeNumber}. ${episode.name}`; + episodesData += `E${formatedEpisodeNumber}. ${episode.name}`; } episodeContainer.innerHTML = episodesData; diff --git a/script.min.js b/script.min.js index be212f9..23da92a 100644 --- a/script.min.js +++ b/script.min.js @@ -1 +1,13 @@ -function scrollToTop(){const c=document.documentElement.scrollTop||document.body.scrollTop;c>0&&(window.requestAnimationFrame(scrollToTop),window.scrollTo(0,c-c/8))}const htmlBody=document.querySelector("html, body"),results=document.querySelector("#results"),scrollToResults=()=>{const resultsTop=results.offsetTop;htmlBody.scrollTo({top:resultsTop,behavior:"smooth"})},searchInput=document.getElementById("search-input"),searchButton=document.getElementById("search-button"),resultsContainer=document.getElementById("results"),corsProxy="https://cors-anywhere.pulkitpareekofficial.workers.dev/?url=";function optimisedImageUrl(url){return url.replace("._V1_.","._V1_QL75_UX160_.")}function fetchAndShow(){const query=encodeURIComponent(searchInput.value),url=`${corsProxy}https://v3.sg.media-imdb.com/suggestion/x/${query}.json`;Pace.restart(),fetch(url).then(response=>response.json()).then(data=>{const results=data.d;resultsContainer.innerHTML="",results.forEach(result=>{if(result.i&&("movie"===result.qid||"tvSeries"===result.qid)){const resultElem=document.createElement("div");resultElem.classList.add("result"),resultElem.setAttribute("IMDB",result.id);let imageAndInfo="";"movie"===result.qid&&result.i?imageAndInfo=`\n ${result.l}\n
\n

${result.l}

\n

${result.s}

\n
\n
`:"tvSeries"===result.qid&&result.i&&(imageAndInfo=`\n ${result.l}\n
\n

${result.l}

\n

${result.s}

\n
\n
`),resultElem.innerHTML=imageAndInfo,resultsContainer.appendChild(resultElem)}})})}function setAll(imdb,title,season,episode,type){if(imdb&&title&&!season&&!episode&&type){let a=document.createElement("a");a.setAttribute("onClick","setUrl(this); return setVideo(this);"),a.setAttribute("url",`imdb=${imdb}&type=movie&title=${title.replace(/ /g,"_")}`),a.setAttribute("isWebSeries","false"),a.setAttribute("title",title),a.setAttribute("class","links"),a.setAttribute("IMDB",imdb),a.setAttribute("href","https://multiembed.mov/directstream.php?video_id="+imdb),a.setAttribute("target","_blank"),a.click()}else if(imdb&&title&&episode&&!type){let a=document.createElement("a");a.setAttribute("onClick","setUrl(this); return setVideo(this);"),console.log("season setall",season,"episode",episode),a.setAttribute("url",`imdb=${imdb}&season=${season}&episode=${episode}`),a.setAttribute("isWebSeries","true"),a.setAttribute("title",title),a.setAttribute("class","links"),a.setAttribute("IMDB",imdb),a.setAttribute("href",`https://multiembed.mov/directstream.php?video_id=${imdb}&s=${season}&e=${episode}`),a.setAttribute("target","_blank"),a.click()}}const fetchTitle=async imdbID=>{const url=`${corsProxy}https://v3.sg.media-imdb.com/suggestion/x/${imdbID}.json`;try{const response=await fetch(url),data=await response.json(),title=data.d[0].l;return title}catch(error){console.error(error)}};function setUrl(element){let search=element.getAttribute("url");window.history.replaceState({},"",`?${search.replace(/%20/g,"+")}`)}function fillSearchInput(){let searchParams=new URLSearchParams(window.location.search),search=searchParams.get("search"),season=searchParams.get("season"),episode=searchParams.get("episode"),imdb=searchParams.get("imdb"),type=searchParams.get("type");if(!search||season||episode||imdb)!imdb||!type||search||episode||season?imdb&&!search&&episode&&season&&(console.log("season",season,"episode",episode),fetchTitle(imdb).then(title=>setAll(imdb,title,season,episode,type)).catch(error=>console.error(error)),console.log("season",season,"episode",episode)):fetchTitle(imdb).then(title=>setAll(imdb,title,season,episode,type)).catch(error=>console.error(error));else{search=search.replace(/\+/g,"%20");const searchInput=document.querySelector("#search-input");searchInput.value=search,fetchAndShow()}}function updateURL(input){let search=input.value;search?window.history.replaceState({},"",`?search=${encodeURIComponent(search).replace(/%20/g,"+")}`):window.history.replaceState({},"",window.location.pathname)}function highlightCards(){let searchParams,imdb_id=new URLSearchParams(window.location.search).get("imdb");try{document.querySelectorAll(".result").forEach((function(card){card.className="result"})),document.querySelector(`div[IMDB=${imdb_id}]`).className="result hoverClass"}catch(error){}}let timer;function episodeHighlight(cssidentification="s1e1"){document.querySelectorAll(".episodes").forEach((function(episode){episode.className="episodes"})),document.querySelector(`.episodes[cssidentification='${cssidentification}']`).className="episodes selected"}function setVideo(element){const iframe=document.getElementById("iframe"),video=document.getElementById("video");iframe.src=element.getAttribute("href"),video.style.display="block";const webSeriesData=document.getElementById("webSeriesData"),tmdbApiKey="b6b677eb7d4ec17f700e3d4dfc31d005",imdbID=element.getAttribute("IMDB");if(Pace.restart(),scrollToTop(),window.dispatchEvent(new PopStateEvent("popstate")),"false"==element.getAttribute("isWebSeries")&&"links"==element.className&&(webSeriesData.innerHTML=""),""!==element.getAttribute("title")&&(document.title=element.getAttribute("title")),element.className.includes("episode")&&(episodeHighlight(element.getAttribute("cssidentification")),console.log("clicked")),"true"==element.getAttribute("isWebSeries")){async function printEpisodes(){const response=await fetch(`https://api.themoviedb.org/3/find/${imdbID}?api_key=${tmdbApiKey}&language=en-US&external_source=imdb_id`),data=await response.json(),showId=data.tv_results[0].id,seasonsData=await fetch(`https://api.themoviedb.org/3/tv/${showId}?api_key=${tmdbApiKey}&language=en-US`),seasonsDataJSON=await seasonsData.json(),numberOfSeasons=seasonsDataJSON.number_of_seasons;webSeriesData.innerHTML+="

Seasons:

";for(let seasonNumber=1;seasonNumber<=numberOfSeasons;seasonNumber++){webSeriesData.innerHTML+=`

Season ${seasonNumber}:


`;let episodeContainer=document.createElement("div");episodeContainer.classList.add("episode-container");let episodesData="";const episodesDataResponse=await fetch(`https://api.themoviedb.org/3/tv/${showId}/season/${seasonNumber}?api_key=${tmdbApiKey}&language=en-US`),episodesDataJSON=await episodesDataResponse.json();for(const episode of episodesDataJSON.episodes){const episodeNumber=episode.episode_number;let formatedEpisodeNumber=episodeNumber.toLocaleString("en-US",{minimumIntegerDigits:2,useGrouping:!1});episodesData+=`E${formatedEpisodeNumber}. ${episode.name}`}episodeContainer.innerHTML=episodesData,webSeriesData.appendChild(episodeContainer),episodeHighlight()}let searchParams=new URLSearchParams(window.location.search),season=searchParams.get("season"),episode=searchParams.get("episode");season&&episode?document.querySelector(`a[cssIdentification="s${season}e${episode}"]`).click():season&&!episode?document.querySelector(`a[cssIdentification="s${season}e1"]`).click():document.querySelector('a[cssIdentification="s1e1"]').click()}webSeriesData.innerHTML="",printEpisodes()}function gtag(){dataLayer.push(arguments)}return window.dataLayer=window.dataLayer||[],gtag("js",new Date),gtag("config","G-THTQ9GZQ0J"),highlightCards(),!1}fillSearchInput(),window.onpopstate=function(){let searchParams=new URLSearchParams(window.location.search),search=searchParams.get("search"),imdb=searchParams.get("imdb");if(search||imdb){let elements=document.getElementsByClassName("information");for(let i=0;i0&&(window.requestAnimationFrame(scrollToTop),window.scrollTo(0,e-e/8))}const htmlBody=document.querySelector("html, body"),results=document.querySelector("#results"),scrollToResults=()=>{let e=results.offsetTop;htmlBody.scrollTo({top:e,behavior:"smooth"})},searchInput=document.getElementById("search-input"),searchButton=document.getElementById("search-button"),resultsContainer=document.getElementById("results"),corsProxy="https://cors-anywhere.pulkitpareekofficial.workers.dev/?url=";function optimisedImageUrl(e){return e.replace("._V1_.","._V1_QL75_UX160_.")}function fetchAndShow(){let e=encodeURIComponent(searchInput.value),t=`${corsProxy}https://v3.sg.media-imdb.com/suggestion/x/${e}.json`;Pace.restart(),fetch(t).then(e=>e.json()).then(e=>{let t=e.d;resultsContainer.innerHTML="",t.forEach(e=>{if(e.i&&("movie"===e.qid||"tvSeries"===e.qid)){let t=document.createElement("div");t.classList.add("result"),t.setAttribute("IMDB",e.id);let s="";"movie"===e.qid&&e.i?s=` + ${e.l} +
+

${e.l}

+

${e.s}

+
+
`:"tvSeries"===e.qid&&e.i&&(s=` + ${e.l} +
+

${e.l}

+

${e.s}

+
+
`),t.innerHTML=s,resultsContainer.appendChild(t)}})})}function setAll(e,t,s,i,l){if(e&&t&&!s&&!i&&l){let r=document.createElement("a");r.setAttribute("onClick","setUrl(this); return setVideo(this);"),r.setAttribute("url",`imdb=${e}&type=movie&title=${t.replace(/ /g,"_")}`),r.setAttribute("isWebSeries","false"),r.setAttribute("title",t),r.setAttribute("class","links"),r.setAttribute("IMDB",e),r.setAttribute("href","https://www.2embed.cc/embed/"+e),r.setAttribute("target","_blank"),r.click()}else if(e&&t&&i&&!l){let a=document.createElement("a");a.setAttribute("onClick","setUrl(this); return setVideo(this);"),console.log("season setall",s,"episode",i),a.setAttribute("url",`imdb=${e}&season=${s}&episode=${i}`),a.setAttribute("isWebSeries","true"),a.setAttribute("title",t),a.setAttribute("class","links"),a.setAttribute("IMDB",e),a.setAttribute("href",`https://www.2embed.cc/embedtv/${e}&s=${s}&e=${i}`),a.setAttribute("target","_blank"),a.click()}}const fetchTitle=async e=>{let t=`${corsProxy}https://v3.sg.media-imdb.com/suggestion/x/${e}.json`;try{let s=await fetch(t),i=await s.json(),l=i.d[0].l;return l}catch(r){console.error(r)}};function setUrl(e){let t=e.getAttribute("url");window.history.replaceState({},"",`?${t.replace(/%20/g,"+")}`)}function fillSearchInput(){let e=new URLSearchParams(window.location.search),t=e.get("search"),s=e.get("season"),i=e.get("episode"),l=e.get("imdb"),r=e.get("type");if(!t||s||i||l)!l||!r||t||i||s?l&&!t&&i&&s&&(console.log("season",s,"episode",i),fetchTitle(l).then(e=>setAll(l,e,s,i,r)).catch(e=>console.error(e)),console.log("season",s,"episode",i)):fetchTitle(l).then(e=>setAll(l,e,s,i,r)).catch(e=>console.error(e));else{t=t.replace(/\+/g,"%20");let a=document.querySelector("#search-input");a.value=t,fetchAndShow()}}function updateURL(e){let t=e.value;t?window.history.replaceState({},"",`?search=${encodeURIComponent(t).replace(/%20/g,"+")}`):window.history.replaceState({},"",window.location.pathname)}function highlightCards(){let e=new URLSearchParams(window.location.search).get("imdb");try{document.querySelectorAll(".result").forEach(function(e){e.className="result"}),document.querySelector(`div[IMDB=${e}]`).className="result hoverClass"}catch(t){}}fillSearchInput(),window.onpopstate=function(){let e=new URLSearchParams(window.location.search),t=e.get("search"),s=e.get("imdb");if(t||s){let i=document.getElementsByClassName("information");for(let l=0;lSeasons:";for(let c=1;c<=o;c++){i.innerHTML+=`

Season ${c}:


`;let d=document.createElement("div");d.classList.add("episode-container");let u="",h=await fetch(`https://api.themoviedb.org/3/tv/${s}/season/${c}?api_key=${l}&language=en-US`),p=await h.json();for(let m of p.episodes){let g=m.episode_number,b=g.toLocaleString("en-US",{minimumIntegerDigits:2,useGrouping:!1});u+=`E${b}. ${m.name}`}d.innerHTML=u,i.appendChild(d),episodeHighlight()}let f=new URLSearchParams(window.location.search),y=f.get("season"),v=f.get("episode");y&&v?document.querySelector(`a[cssIdentification="s${y}e${v}"]`).click():y&&!v?document.querySelector(`a[cssIdentification="s${y}e1"]`).click():document.querySelector('a[cssIdentification="s1e1"]').click()}i.innerHTML="",a()}function n(){dataLayer.push(arguments)}return window.dataLayer=window.dataLayer||[],n("js",new Date),n("config","G-THTQ9GZQ0J"),highlightCards(),!1}searchInput.addEventListener("keyup",function(){let e=this;clearTimeout(timer),timer=setTimeout(function(){updateURL(e),fetchAndShow(),window.dispatchEvent(new PopStateEvent("popstate")),scrollToResults()},500)}),searchButton.addEventListener("click",function(){fetchAndShow(),scrollToResults(),window.dispatchEvent(new PopStateEvent("popstate"))}); \ No newline at end of file