Skip to content

Commit

Permalink
Update to 1.1.0.0
Browse files Browse the repository at this point in the history
Fixed minor bugs. Made code easier to use. Added commentation.
  • Loading branch information
Ephellon committed May 21, 2018
1 parent 4b1a318 commit a321795
Show file tree
Hide file tree
Showing 25 changed files with 282 additions and 133 deletions.
Binary file modified hhkmjeeccipbolailpomhjhmccnnjhkj.crx
Binary file not shown.
Binary file modified hhkmjeeccipbolailpomhjhmccnnjhkj.zip
Binary file not shown.
15 changes: 8 additions & 7 deletions src/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function addRadarr(request, sendResponse) {
'X-Api-Key': request.token,
...generateHeaders(request.basicAuth)
},
query = encodeURIComponent(`imdb:${ request.IMDbID }`);
query = encodeURIComponent(`imdb:${ request.IMDbID },tmdb:${ request.TMDbID }`);

fetch(`${ request.url }/lookup?term=${ query }`, { headers })
.then(response => response.json())
Expand All @@ -67,6 +67,7 @@ function addRadarr(request, sendResponse) {
qualityProfileId: request.QualityProfileId,
rootFolderPath: request.StoragePath,
imdbId: request.IMDbID,
tmdbId: request.TMDbID,
addOptions: {
searchForMovie: true,
},
Expand Down Expand Up @@ -120,7 +121,7 @@ function addSonarr(request, sendResponse) {
'X-Api-Key': request.token,
...generateHeaders(request.basicAuth)
},
query = encodeURIComponent(`imdb:${ request.IMDbID }`);
query = encodeURIComponent(`imdb:${ request.IMDbID },tvdb:${ request.TVDbID }`);

fetch(`${ request.url }/lookup?term=${ query }`, { headers })
.then(response => response.json())
Expand Down Expand Up @@ -237,11 +238,11 @@ function $serachPlex(connection, headers, options) {
// Weirdly enough Plex doesn't seem to have an easy way to filter those libraries so we invent our own hack.
let movies = hub.Metadata.filter(
meta =>
meta.Country ||
meta.Directory ||
meta.Genre ||
meta.Role ||
meta.Writer
meta.Country ||
meta.Directory ||
meta.Genre ||
meta.Role ||
meta.Writer
);

// This is messed up, but Plex's definition of a year is year when it was available,
Expand Down
12 changes: 7 additions & 5 deletions src/deps/amazon/cs.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,15 @@ async function initPlexThingy(type) {
let title = $title.textContent.replace(/\(.+?\)$/, '').trim(),
year = $year? $year.textContent.trim(): YEAR;

console.log({ title, year });

let Db = await getIDs({ title, year, APIType: type }),
let Db = await getIDs({ title, year, type }),
IMDbID = Db.imdb,
TVDbID = Db.thetvdb;
TMDbID = Db.tmdb,
TVDbID = Db.tvdb;

title = Db.title;
year = Db.year;

findPlexMedia({ type, title, year, button: $button, IMDbID, TVDbID });
findPlexMedia({ type, title, year, button: $button, IMDbID, TMDbID, TVDbID });
}

if (isMovie() || isShow()) {
Expand Down
10 changes: 7 additions & 3 deletions src/deps/fandango/cs.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,15 @@ async function initPlexThingy(type) {
let title = $title.textContent.trim().split(/\n+/)[0].trim(),
year = $year.textContent.replace(/.*(\d{4}).*/, '$1').trim();

let Db = await getIDs({ title, year }),
let Db = await getIDs({ title, year, type }),
IMDbID = Db.imdb,
TVDbID = Db.thetvdb;
TMDbID = Db.tmdb,
TVDbID = Db.tvdb;

findPlexMedia({ type, title, year, button: $button, IMDbID, TVDbID });
title = Db.title;
year = Db.year;

findPlexMedia({ type, title, year, button: $button, IMDbID, TMDbID, TVDbID });
}

if (isMovie()) {
Expand Down
12 changes: 10 additions & 2 deletions src/deps/flenix/cs.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,17 @@ async function initPlexThingy() {

let title = $title.innerText.trim(),
year = $date.innerText,
IMDbID = await getIDs({ title, year, type: 'imdb', meta });
type = 'movie';

let Db = await getIDs({ title, year, type }),
IMDbID = Db.imdb,
TMDbID = Db.tmdb,
TVDbID = Db.tvdb;

findPlexMedia({ title, year, button: $button, IMDbID, type: 'movie', remote: '/engine/ajax/get.php', locale: 'flenix' });
title = Db.title;
year = Db.year;

findPlexMedia({ title, year, button: $button, IMDbID, TMDbID, TVDbID, type, remote: '/engine/ajax/get.php', locale: 'flenix' });
}

function renderPlexButton() {
Expand Down
6 changes: 3 additions & 3 deletions src/deps/google/cs.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@
color: #ffffff!important;
}

.web-to-plex-wrapper, .web-to-plex-button--downloader {
.web-to-plex-wrapper, *:not(.web-to-plex-wrapper) > .web-to-plex-button--downloader {
background: #f45a26!important;
}

.web-to-plex-wrapper--found {
background-color: #e5a00d!important;
}

.web-to-plex-wrapper:hover, .web-to-plex-button--downloader:hover {
.web-to-plex-wrapper:hover, *:not(.web-to-plex-wrapper) > .web-to-plex-button--downloader:hover {
background-color: #f67e56!important;
}

.web-to-plex-wrapper--found:hover, .web-to-plex-button--found:hover {
.web-to-plex-wrapper--found:hover, *:not(.web-to-plex-wrapper--found) > .web-to-plex-button--found:hover {
background-color: #f8c022!important;
}

Expand Down
10 changes: 7 additions & 3 deletions src/deps/google/cs.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,15 @@ async function initPlexThingy(type) {

let title = $title.textContent.replace(/\(\s*(\d{4})\s*\).*?$/, '').trim(),
year = (RegExp.$1 || $year.textContent).replace(/^.*?(\d+)/, '$1').trim(),
Db = await getIDs({ title, year, APIType: type }),
Db = await getIDs({ title, year, type }),
IMDbID = Db.imdb,
TVDbID = Db.thetvdb;
TMDbID = Db.tmdb,
TVDbID = Db.tvdb;

findPlexMedia({ type, title, year, button: $button, IMDbID, TVDbID });
title = Db.title;
year = Db.year;

findPlexMedia({ type, title, year, button: $button, IMDbID, TMDbID, TVDbID });
}

parseOptions().then(() => {
Expand Down
12 changes: 9 additions & 3 deletions src/deps/hulu/cs.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,17 @@ async function initPlexThingy(type) {
.replace(/-+/g, ' ');
}

let Db = await getIDs({ title, year, APIType: type }),
title = title.toCaps();

let Db = await getIDs({ title, year, type }),
IMDbID = Db.imdb,
TVDbID = Db.thetvdb;
TMDbID = Db.tmdb,
TVDbID = Db.tvdb;

title = Db.title;
year = Db.year;

findPlexMedia({ type, title, year, button: $button, IMDbID, TVDbID });
findPlexMedia({ type, title, year, button: $button, IMDbID, TMDbID, TVDbID });
}

if (isMovie() || isShow()) {
Expand Down
7 changes: 4 additions & 3 deletions src/deps/imdb/cs.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,13 @@ async function initPlexShow() {

let title = $title.textContent.trim(),
year = dateMatch[1],
Db = await getIDs({ title, year, IMDbID }),
TVDbID = Db.thetvdb;
Db = await getIDs({ title, year, type: 'show', IMDbID }),
TMDbID = Db.tmdb,
TVDbID = Db.tvdb;

IMDbID = IMDbID || Db.imdb;

findPlexMedia({ type: 'show', title, year, button: $button, IMDbID, TVDbID });
findPlexMedia({ type: 'show', title, year, button: $button, IMDbID, TMDbID, TVDbID });
}

function addInListItem(el) {
Expand Down
12 changes: 8 additions & 4 deletions src/deps/itunes/cs.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,19 @@ async function initPlexThingy(type) {
if (!$button)
return;

let meta = document.querySelector('h1[itemprop="name"]'),
let meta = document.querySelector('h1[itemprop="name"], h1'),
title = meta.textContent.replace(/\s*\((\d+)\)\s*/, '').trim(),
year = +RegExp.$1;

let Db = await getIDs({ title, year, APIType: type }),
let Db = await getIDs({ title, year, type }),
IMDbID = Db.imdb,
TVDbID = Db.thetvdb;
TMDbID = Db.tmdb,
TVDbID = Db.tvdb;

findPlexMedia({ type, title, year, button: $button, IMDbID, TVDbID });
title = Db.title;
year = Db.year;

findPlexMedia({ type, title, year, button: $button, IMDbID, TMDbID, TVDbID });
}

if (isMovie() || isShow()) {
Expand Down
14 changes: 9 additions & 5 deletions src/deps/metacritic/cs.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,20 @@ async function initPlexThingy(type) {
`Could not extract ${ !$title? 'title': 'year' } from Metacritic`
);

let title = $title.textContent.trim(),
year = $date.textContent.replace(/.*(\d{4}).*$/, '$1').trim();
let title = $title.textContent.replace(/\s+/g, ' ').trim(),
year = $date.textContent.replace(/\s+/g, ' ').replace(/.*(\d{4}).*$/, '$1').trim();

let Db = await getIDs({ title, year, APIType: type }),
let Db = await getIDs({ title, year, type }),
IMDbID = Db.imdb,
TVDbID = Db.thetvdb;
TMDbID = Db.tmdb,
TVDbID = Db.tvdb;

title = Db.title;
year = Db.year;

type = type === 'tv'? 'show': type;

findPlexMedia({ title, year, button: $button, type, IMDbID, TVDbID, txt: 'title', hov: 'null' });
findPlexMedia({ title, year, button: $button, type, IMDbID, TMDbID, TVDbID, txt: 'title', hov: 'null' });
}

function renderPlexButton() {
Expand Down
10 changes: 7 additions & 3 deletions src/deps/tmdb/cs.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,17 @@ async function initPlexThingy(type) {
year = $date.textContent.trim(),
apid = window.location.pathname.replace(/\/(?:movie|tv)\/(\d+).*/, '$1');

let Db = await getIDs({ title, year, APIType: type, APIID: apid }),
let Db = await getIDs({ title, year, TMDbID: apid, APIType: type, APIID: apid }),
IMDbID = Db.imdb,
TVDbID = Db.thetvdb;
TMDbID = Db.tmdb,
TVDbID = Db.tvdb;

title = Db.title;
year = Db.year;

type = type === 'tv'? 'show': type;

findPlexMedia({ title, year, button: $button, type, IMDbID, TVDbID, txt: 'title', hov: 'null' });
findPlexMedia({ title, year, button: $button, type, IMDbID, TMDbID, TVDbID, txt: 'title', hov: 'null' });
}

function renderPlexButton() {
Expand Down
26 changes: 20 additions & 6 deletions src/deps/trakt/cs.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ function getTVDbID() {
return $link.href.replace(/^.*?thetvdb.com\/.+(?:(?:series)?id=(\d+)).*?$/, '$1');
}

function getTMDbID() {
let $link = document.querySelector(
// HTTPS and HTTP
'[href*="themoviedb.org/"]'
);

if ($link)
return $link.href.replace(/^.*?themoviedb.org\/(?:movie|tv)\/(\d+).*?$/, '$1');
}

function init() {
if (isMoviePage() || isShowPage()) {
wait(
Expand Down Expand Up @@ -72,19 +82,23 @@ async function initPlexThingy(type) {
if (!$title || !$year)
return modifyPlexButton($button, 'error', `Could not extract ${ !$title? 'title': 'year' } from Trakt`);

let title = $title.textContent.replace(/(.+)(\d{4}).*?$/, '$1').trim(),
let title = $title.textContent.replace(/(.+)(\d{4}).*?$/, '$1').replace(/\s*\:\s*Season.*$/i, '').trim(),
year = (RegExp.$2 || $year.textContent).trim(),
IMDbID = getIMDbID(),
TMDbID = getTMDbID(),
TVDbID = getTVDbID();

if(!IMDbID || !TVDbID) {
let Db = await getIDs({ title, year, IMDbID });
if((!IMDbID && !TMDbID) || !TVDbID) {
let Db = await getIDs({ title, year, type, IMDbID, TMDbID, TVDbID });

IMDbID = IMDbID || Db.imdb;
TVDbID = TVDbID || Db.thetvdb;
IMDbID = IMDbID || Db.imdb,
TMDbID = TMDbID || Db.tmdb,
TVDbID = TVDbID || Db.tvdb;
title = Db.title;
year = Db.year;
}

findPlexMedia({ type, title, year, button: $button, IMDbID, TVDbID });
findPlexMedia({ type, title, year, button: $button, IMDbID, TMDbID, TVDbID });
}

parseOptions().then(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/deps/tvdb/cs.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function initPlexThingy() {
return modifyPlexButton(
$button,
'error',
`Could not extract ${ !$title? 'title': 'year' } from TheTVDb`
`Could not extract title from TheTVDb`
),
null;

Expand Down
10 changes: 7 additions & 3 deletions src/deps/tvmaze/cs.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,15 @@ async function initPlexThingy() {

let title = $title.innerText.trim(),
year = $date.innerText.replace(/\((\d+).+\)/, '$1'),
Db = await getIDs({ APIID: $apid }),
Db = await getIDs({ title, year, type: 'tv', APIID: $apid }),
IMDbID = Db.imdb,
TVDbID = Db.thetvdb;
TMDbID = Db.tmdb,
TVDbID = Db.tvdb;

findPlexMedia({ title, year, button: $button, type: 'show', IMDbID, TVDbID });
title = Db.title;
year = Db.year;

findPlexMedia({ title, year, button: $button, type: 'show', IMDbID, TMDbID, TVDbID });
}

function renderPlexButton() {
Expand Down
10 changes: 7 additions & 3 deletions src/deps/verizon/cs.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,15 @@ async function initPlexThingy(type) {
let title = $title.textContent.trim(),
year = $year.textContent.slice(0, 4).trim();

let Db = await getIDs({ title, year, APIType: type }),
let Db = await getIDs({ title, year, type }),
IMDbID = Db.imdb,
TVDbID = Db.thetvdb;
TMDbID = Db.tmdb,
TVDbID = Db.tvdb;

findPlexMedia({ type, title, year, button: $button, IMDbID, TVDbID });
title = Db.title;
year = Db.year;

findPlexMedia({ type, title, year, button: $button, IMDbID, TMDbID, TVDbID });
}

parseOptions().then(() => {
Expand Down
4 changes: 4 additions & 0 deletions src/deps/vrv/cs.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
color: #f45a26 !important;
}

.web-to-plex-button:nth-child(2) {
margin-left: 0.625rem;
}

.web-to-plex-button:hover {
background-color: #f67e56;
box-shadow: inset 0 0 0 0.125rem #f67e56!important;
Expand Down

0 comments on commit a321795

Please sign in to comment.