diff --git a/justWatchTest.js b/justWatchTest.js index 415be8f1..49825740 100644 --- a/justWatchTest.js +++ b/justWatchTest.js @@ -3,11 +3,8 @@ async function 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(); - // console.log(data); const justWatchURL = "https://www.justwatch.com" + data.items[0].full_path; - // console.log(data.items[0].scoring); - // console.log(data.items[0].offers.filter((x) => x.monetization_type != "flatrate" && x.monetization_type != "rent" && x.monetization_type != "buy")); - // console.log(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"))); + // 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")); // get the first offer of each provider offers = offers.filter((x, i) => offers.findIndex((y) => y.provider_id == x.provider_id) == i); @@ -17,12 +14,12 @@ async function getMovieInfo(movieTitle) { streamingLinks: offers, }; } +let movieTitle; +movieTitle = "The Thousand Years of Longing"; // not on amp.de but on amp.com +movieTitle = "Breaking Bad"; // on netflix +movieTitle = "Elemental"; // on dnp -// let movieTitle = "The Thousand Years of Longing"; -// let movieTitle = "Breaking Bad"; -// let movieTitle = "Elemental"; - -let movieTitle = "Suits"; // both netflix and amazon prime +movieTitle = "Suits"; // both netflix and amazon prime getMovieInfo(movieTitle).then((infos) => { console.log(JSON.stringify(infos)); });