Skip to content

Commit

Permalink
movieTitle
Browse files Browse the repository at this point in the history
  • Loading branch information
Dreamlinerm committed Sep 15, 2023
1 parent e882022 commit 17c552d
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions justWatchTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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));
});

0 comments on commit 17c552d

Please sign in to comment.