Skip to content

Commit

Permalink
justWatchAPI
Browse files Browse the repository at this point in the history
  • Loading branch information
Dreamlinerm committed Sep 15, 2023
1 parent ac5cb33 commit a9f42e5
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions firefox/skipper.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,13 @@ if (isPrimeVideo || isNetflix || isDisney || isHotstar) {
}
// justWatchAPI
async function getMovieInfo(movieTitle, locale = "en_US") {
console.log("getMovieInfo", movieTitle);
// console.log("getMovieInfo", movieTitle);
const url = `https://apis.justwatch.com/content/titles/${locale}/popular?language=en&body={"page_size":1,"page":1,"query":"${movieTitle}","content_types":["show","movie"]}`;
const response = await fetch(encodeURI(url));
const data = await response.json();
const justWatchURL = "https://www.justwatch.com" + data.items[0].full_path;
const justWatchURL = "https://www.justwatch.com" + data?.items?.[0].full_path;
// flatrate = free with subscription (netflix, amazon prime, disney+)
let offers = data.items[0].offers.filter((x) => x.monetization_type == "flatrate" && (x.package_short_name == "amp" || x.package_short_name == "nfx" || x.package_short_name == "dnp"));
let offers = data?.items?.[0].offers.filter((x) => x.monetization_type == "flatrate" && (x.package_short_name == "amp" || x.package_short_name == "nfx" || x.package_short_name == "dnp"));
// get the first offer of each provider
offers = offers.filter((x, i) => offers.findIndex((y) => y.provider_id == x.provider_id) == i);
return {
Expand Down Expand Up @@ -487,7 +487,7 @@ if (isPrimeVideo || isNetflix || isDisney || isHotstar) {
let titleCards = document.querySelectorAll(".title-card .boxart-container:not(.imdb)");
titleCards.forEach((card) => {
// let card = document.querySelector(".title-card .boxart-container");
let title = card.children?.[1]?.firstChild.textContent;
let title = card.children?.[1]?.firstChild?.textContent;
if (title) {
getMovieInfo(title).then((data) => {
if (data.scoring?.value) {
Expand All @@ -503,11 +503,13 @@ if (isPrimeVideo || isNetflix || isDisney || isHotstar) {
card.appendChild(div);
} else {
console.log("no scoring", title);
card.classList.add("imdb");
}
});
}
});
}
// NetflixJustWatchObserver.observe(document, config);
// setTimeout(function () {
Netflix_JustWatch();
// }, 1000);
Expand Down

0 comments on commit a9f42e5

Please sign in to comment.