web-to-plex
web-to-plex copied to clipboard
BETA Scripts
A place to test scripts that require special access or instances.
Pass the Popcorn (Invitation Only)
Translation of @inonprince's /ptp.js
// Pass the Popcorn requires: api
let plugin = {
"url": "*://*.passthepopcorn.me/torrents.php",
"ready": () => !$('.page__main-content').empty,
"timeout": 3000,
"init": async(ready) => {
let _title, _year, _image, R = RegExp;
let title, year, image, TMDbID,
type = 'movie',
IMDbID = script.getIMDbID(),
OBJECT;
await fetch(`https://api.themoviedb.org/3/find/${ IMDbID }?api_key=${ configuration.TMDbAPI }&external_source=imdb_id`)
.then(r => r.json())
.then(json => {
let results = json.movie_results;
if(json && results && results.length) {
results = results.filter(o => o.id && o.title && o.release_date)[0];
title = results.title;
year = results.release_date.slice(0, 4) | 0;
TMDbID = results.id;
}
if(!TMDbID || !title)
throw `Unable to get information for "${ IMDbID }"`;
IS_DONE = top.IS_DONE = true;
return OBJECT = { type, title, year, IMDbID, TMDbID };
})
.catch(error => { throw error });
if(IS_DONE && OBJECT)
return OBJECT;
return plugin.timeout;
},
"getIMDbID": () => {
let link = $('#imdb-title-link').first;
if(link)
return link.href.replace(/^[^]+(tt\d+)\b[^]*$/, '$1');
},
},
IS_DONE = top.IS_DONE = (top.IS_DONE || false);
Indomovie (Indonesian site)
let plugin = {
"url": "*://*.indomovietv.*/(?!tag|$)",
// TLD changes often: net, org
"ready": () => !$('[itemprop="name"i]:not(meta), [itemprop="datePublished"i]').empty,
"timeout": 1000,
"init": (ready) => {
let _title, _year, _image, R = RegExp;
let title = $('[itemprop="name"i]:not(meta)').first,
year = $('[itemprop="datePublished"i]').first,
image = $('[itemprop="image"i]').first,
type = 'movie';
title = title.textContent;
year = +year.textContent.replace(/[^]*(\d{4})[^]*/, '$1');
image = image.src;
// auto-prompt downloading for the user
let links = $('[class~="idtabs"i] [href^="#div"i]');
if(links.length > 1) {
OLOAD_EVENTS.push(setTimeout(
() => Notify('update', 'Finding download links...', 3000),
500
));
links.forEach((link, index, array) => OLOAD_EVENTS.push(setTimeout(
() => {
link.click();
if(index == links.length -1)
OLOAD_EVENTS.push(setTimeout(
() => Notify('update', 'No download links found'),
7000
));
},
index * 4500
)));
}
return { type, title, year, image };
},
},
OLOAD_EVENTS = [];
top.addEventListener('message', request => {
try {
request = request.data;
if(request)
if(request.from || request.found)
OLOAD_EVENTS.forEach(timeout => clearTimeout(timeout));
} catch(error) {
throw error;
}
});
Plugin API is pretty solid, will close soon. The only "fix" would be getting async calls to work correctly
Message passing, maybe, but the function must return a value... I'll make a switch for this to work?