Skip to content

Commit

Permalink
improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Dreamlinerm committed Oct 27, 2023
1 parent abcc723 commit 506b325
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions firefox/skipper.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ if (isPrimeVideo || isNetflix || isDisney || isHotstar) {
}
}
// ...args
const date = new Date();
function log(...args) {
const date = new Date();
console.log(date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds(), ...args);
}
// set DB Cache if cache size under 2MB
Expand All @@ -209,6 +209,7 @@ if (isPrimeVideo || isNetflix || isDisney || isHotstar) {
}
// browser.storage.local.set({ DBCache: {} });
// justWatchAPI
const today = date.toISOString().split("T")[0];
async function getMovieInfo(title, card, Rating = true) {
// justwatch api
// const url = `https://apis.justwatch.com/content/titles/${locale}/popular?language=en&body={"page_size":1,"page":1,"query":"${title}","content_types":["show","movie"]}`;
Expand Down Expand Up @@ -237,9 +238,22 @@ if (isPrimeVideo || isNetflix || isDisney || isHotstar) {
// const compiledData = { jWURL, score, streamLinks: offers };

// themoviedb
const compiledData = { score: data?.results?.[0]?.vote_average };
let compiledData = {};
// for (movie of data?.results) {
// if (movie.title.toLowerCase().includes(title.toLowerCase())) {
// compiledData = { score: movie?.vote_average, release_date: movie?.release_date, date: today, db: "tmdb" };
// break;
// }
// }
const movie = data?.results?.[0];
compiledData = { score: movie?.vote_average, release_date: movie?.release_date, date: today, db: "tmdb" };
DBCache[title] = compiledData;
if (!compiledData?.score) log("no Score found", title, data);
if (!compiledData?.score) {
log("no Score found", title, data);
}
// else {
// log("Score found", title);
// }
if (Rating) setRatingOnCard(card, compiledData, title);
else {
setAlternativesOnCard(card, compiledData, title);
Expand All @@ -265,7 +279,8 @@ if (isPrimeVideo || isNetflix || isDisney || isHotstar) {
// let card = document.querySelectorAll(".title-card .boxart-container:not(.imdb)");
let title;
if (isNetflix) title = card?.children?.[1]?.firstChild?.textContent.split(" – ")[0];
else if (isDisney) title = card?.getAttribute("alt");
// S2: E3 remove this part
else if (isDisney) title = card?.getAttribute("alt").replace(/(S\d+:\sE\d+\s)/g, "");
// amazon
// remove everything after - in the title
else title = card.getAttribute("data-card-title").split(" - ")[0].split(" – ")[0]; //Amazon
Expand Down

0 comments on commit 506b325

Please sign in to comment.