Skip to content

Commit

Permalink
Upgrade to 4.0 (BETA)
Browse files Browse the repository at this point in the history
Please see SpaceK33z#55, or the /change.log file for changes made.
  • Loading branch information
Ephellon committed Nov 14, 2018
1 parent 3a7ea4d commit 3d4115c
Show file tree
Hide file tree
Showing 90 changed files with 1,286 additions and 1,840 deletions.
65 changes: 36 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
# Web to Plex ![Icon](src/img/48.png)
# Web to Plex (BETA Channel) ![Icon](src/img/48.png)

![Logo](src/img/256.png)

This browser extension searches your [Plex Media Server (PMS)](https://www.plex.tv/downloads/) for matching media on sites like [IMDb](https://imdb.com), letting you immediately open the movie or TV show in Plex, if it is available. If the item isn't found on your PMS, then a download button is added instead.

Optionally, you can configure [Sonarr](https://sonarr.tv/) (TV Shows), [Radarr](https://radarr.video/) (Movies), [Watcher 3](https://nosmokingbandit.github.io/) (Movies), and/or [CouchPotato](https://couchpota.to/) (Both) in the extension's options. After that, you can immediately add a TV show or movie to CouchPotato/Sonarr/Radarr with one click, right from your favorite site.
Optionally, you can configure [Sonarr](https://sonarr.tv/) (TV Shows), [Radarr](https://radarr.video/) (Movies), [Watcher 3](https://nosmokingbandit.github.io/) (Movies), and/or [CouchPotato](https://couchpota.to/) (Both) in the extension's options. After that, you can immediately add a TV show or movie to CouchPotato/Sonarr/Radarr/Watcher with one click, right from your favorite site.

If you don't feel like actually downloading the movie, or want a simple watchlist, you can also use the built-in "Plex It!" feature to bookmark the current page.

![Examples](example.png)

----

## Status: 426 (UPGR-RQ)
## Status: 307 (TEMP-RD)

Getting the repo ready for a pull request.
This is the BETA (testing) version, please visit [Web to Plex](https://github.com/SpaceK33z/web-to-plex) for the stable version.

----

Expand All @@ -28,11 +30,14 @@ Getting the repo ready for a pull request.
- Offers search options via right-click (context menu)
- Right-click | Web to Plex | Find "Show/Movie (Year)"
- Offers a Plex-like GUI
- Web to Plex button
- Settings page
- Pop-up page
- Offers a status via the browser badge
- Orange: item is available/found
- Grey: item is unavailable/not found
- Offers a status via the browser badge and button
- Orange/Yellow: item is on Plex
- Blue (button): item isn't on Plex, but can be sent for
- Grey (badge)/Red (button): item is unavailable/not found
- Grey (button): item is loading
- Offers an easy login feature
- Offers an API login feature
- Offers a "Direct Plex URL" feature
Expand All @@ -42,27 +47,29 @@ Getting the repo ready for a pull request.

*Given in order of completion*

1. [Movieo](http://movieo.me/) ([button location](button-locations/movieo.png))
2. [IMDb](http://imdb.com/) ([button location](button-locations/imdb.png))
3. [Trakt.tv](https://trakt.tv/) ([button location](button-locations/trakt.png))
4. [Letterboxd](https://letterboxd.com/) ([button location](button-locations/letterboxd.png))
5. [Flenix](https://flenix.co/)<sup>1/5</sup> ([button locations](button-locations/flenix.png))
6. [TV Maze](http://www.tvmaze.com/) ([button location](button-locations/tvmaze.png))
7. [The TVDb](https://www.thetvdb.com/) ([button location](button-locations/tvdb.png))
8. [The MovieDb](https://www.themoviedb.org/) ([button location](button-locations/tmdb.png))
9. [VRV](https://vrv.co/)<sup>2</sup> ([button location](button-locations/vrv.png))
10. [Hulu](https://hulu.com/)<sup>2/3/4</sup> ([button location](button-locations/hulu.png))
11. [Google Play Store](https://play.google.com/store/movies/) ([button location](button-locations/google.png))
12. [iTunes](https://itunes.apple.com/)<sup>3/5</sup> ([button location](button-locations/itunes.png))
13. [Metacritic](http://www.metacritic.com/)<sup>4</sup> ([button location](button-locations/metacritic.png))
14. [Fandango](https://www.fandango.com/) ([button location](button-locations/fandango.png))
15. [Amazon](https://www.amazon.com/)<sup>5</sup> ([button location](button-locations/amazon.png))
16. [Vudu](https://www.vudu.com/) ([button location](button-locations/vudu.png))
17. [Verizon](https://www.tv.verizon.com/) ([button location](button-locations/verizon.png))
18. [CouchPotato](http://couchpotato.life/) ([button location](button-locations/couch-potato.png))
19. [Rotten Tomatoes](https://www.rottentomatoes.com/) ([button location](button-locations/rotten-tomatoes.png))
20. [ShowRSS](https://showrss.info/)<sup>1</sup> (no button location)
21. [Netflix](https://netflix.com/)<sup>3</sup> ([button location](button-locations/netflix.png))
1. [Movieo](http://movieo.me/)
2. [IMDb](http://imdb.com/)
3. [Trakt.tv](https://trakt.tv/)
4. [Letterboxd](https://letterboxd.com/)
5. [Flenix](https://flenix.co/)<sup>1/5</sup> (no longer supported)
- Replaced with #22 (GoStream)
6. [TV Maze](http://www.tvmaze.com/)
7. [The TVDb](https://www.thetvdb.com/)
8. [The MovieDb](https://www.themoviedb.org/)
9. [VRV](https://vrv.co/)<sup>2</sup>
10. [Hulu](https://hulu.com/)<sup>2/3/4</sup>
11. [Google Play Store](https://play.google.com/store/movies/)
12. [iTunes](https://itunes.apple.com/)<sup>3/5</sup>
13. [Metacritic](http://www.metacritic.com/)<sup>4</sup>
14. [Fandango](https://www.fandango.com/)
15. [Amazon](https://www.amazon.com/)<sup>5</sup>
16. [Vudu](https://www.vudu.com/)
17. [Verizon](https://www.tv.verizon.com/)
18. [CouchPotato](http://couchpotato.life/)
19. [Rotten Tomatoes](https://www.rottentomatoes.com/)
20. [ShowRSS](https://showrss.info/)<sup>1</sup> (button isn't meant to appear)
21. [Netflix](https://netflix.com/)<sup>3</sup>
22. [GoStream](hhtps://gostream.site/)

*Notes*

Expand All @@ -78,7 +85,7 @@ Getting the repo ready for a pull request.

## En Progress sites (may add support):

- Nothing here... for now
- [Shana Project](http://shanaproject.com/)

## Installing Web to Plex

Expand Down
Binary file removed button-locations/amazon.png
Binary file not shown.
Binary file removed button-locations/couch-potato.png
Binary file not shown.
Binary file removed button-locations/fandango.png
Binary file not shown.
Binary file removed button-locations/flenix.png
Binary file not shown.
Binary file removed button-locations/google.png
Binary file not shown.
Binary file removed button-locations/hulu.png
Binary file not shown.
Binary file removed button-locations/imdb.png
Binary file not shown.
Binary file removed button-locations/itunes.png
Binary file not shown.
Binary file removed button-locations/letterboxd.png
Binary file not shown.
Binary file removed button-locations/metacritic.png
Binary file not shown.
Binary file removed button-locations/movieo.png
Binary file not shown.
Binary file removed button-locations/netflix.png
Binary file not shown.
Binary file removed button-locations/rotten-tomatoes.png
Binary file not shown.
Binary file removed button-locations/tmdb.png
Binary file not shown.
Binary file removed button-locations/trakt.png
Binary file not shown.
Binary file removed button-locations/tvdb.png
Binary file not shown.
Binary file removed button-locations/tvmaze.png
Binary file not shown.
Binary file removed button-locations/verizon.png
Binary file not shown.
Binary file removed button-locations/vrv.png
Binary file not shown.
Binary file removed button-locations/vudu.png
Binary file not shown.
18 changes: 18 additions & 0 deletions change.log
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,25 @@

## v3.1.2.0 / unreleased

- Complete overhaul of button UI
- Instead of individual buttons and locations, there is a single location (bottom left)
- The button can be right-clicked (contextmenu) for more options
- Added new icons to reflect above-mentioned changes
- Fixed `String..toCaps` in `/utils.js`
- Fixed Flenix's `isMoviePageReady():boolean`
- Fixed #57
- changed IMDb to use the found year instead of the "release year", e.g. "Del Playa (2017 - USA)" v. "Del Playa (2015)" (same movie, different year)
- Made minor bug changes to `/utils.js`
- if a title wasn't passed to `findPlexMedia` the script would continue and fail
- Removed `/adblockplus.txt`
- Fixed a bug in `/manifest.json`
- The entry for 'VRV' was missing the `/sites/common.css` link
- Suppressed minor errors in `/utils.js`
- When a movie/show isn't found (given a blank page), then fire a silent error event
- Added `furnish` to `/utils.js`
- use as `document.furnish(element:string, ?attributes:object, ...children:Element)`
- returns an `Element` with the declared attributes, and children
- e.g. `div = document.furnish('div#id.class[attr]', { onclick: () => {} }, document.furnish('a[href]'))`
- Added `queryBy` to `/utils.js`
- use as `document.queryBy(selectors:string)`
- returns an `Array` that is in the same order as the selectors
Expand All @@ -279,3 +292,8 @@
document.queryBy('body, script, head'); // => [<body>, <script>, <head>]
document.querySelectorAll('body, script, head'); // => [<head>, <body>, <script>]
```


## TODO

- Add [The Shana Project](http://www.shanaproject.com/)?
Binary file modified example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src.crx
Binary file not shown.
Binary file modified src.zip
Binary file not shown.
101 changes: 61 additions & 40 deletions src/background.js
Original file line number Diff line number Diff line change
@@ -1,53 +1,64 @@
/* global chrome */
let external = {},
parentItem,
saveItem,
terminal =
// { error: m => m, info: m => m, log: m => m, warn: m => m } ||
// { error: m => m, info: m => m, log: m => m, warn: m => m, group: m => m, groupEnd: m => m } ||
console;

let date = new Date(),
YEAR = date.getFullYear(),
let date = (new Date),
YEAR = date.getFullYear(),
MONTH = date.getMonth() + 1,
DATE = date.getDate();
DATE = date.getDate();

// Create a Crypto-Key
// new Key(number:integer, string) -> string
class Key {
constructor(length = 8, symbol = '') {
let values = [];

window.crypto.getRandomValues(new Uint32Array(16)).forEach((value, index, array) => values.push(value.toString(36)));

return this.value = values.join(symbol);
return this.length = length, this.value = values.join(symbol);
}

rehash(length) {
return this.value = new Key(length);
rehash(length, symbol) {
if(length)
/* Do nothing */;
else
length = this.length;

return this.value = new Key(length, symbol);
}
}

// Session key
let SessionKey = new Key(16);
// Session instances
let SessionKey = new Key(16), // create a session key
SessionState = false; // has this been run already?

// Object{username, password} => Object
function generateHeaders(auth) {
// Generate request headers (for fetches)
// generateHeaders({username, password}) -> object
function generateHeaders(credentials) {
let headers = { Accept: 'application/json' };

if (!auth)
if (!credentials)
return headers;

return {
Authorization: `Basic ${ btoa(`${ auth.username }:${ auth.password }`) }`,
Authorization: `Basic ${ btoa(`${ credentials.username }:${ credentials.password }`) }`,
...headers
};
}

// Object{MovieOrShowID, MovieOrShowTitle, MovieOrShowType, MovieOrShowIDProvider, MovieOrShowYear, LinkURL, FileType} => undefined
// Change the badge status
// changeStatus({MovieOrShowID, MovieOrShowTitle, MovieOrShowType, MovieOrShowIDProvider, MovieOrShowYear, LinkURL, FileType}) -> undefined
function changeStatus({ id, tt, ty, pv, yr, ur = '', ft = '' }) {

let tl = tt.replace(/\-/g, ' ').replace(/[\s\:]{2,}/g, ' - ').replace(/[^\w\s\-\']+/g, ''),
// File friendly title
st = tt.replace(/[\-\s]+/g, '-').replace(/[^\w\-]+/g, ''),
// Search friendly title
xx = /[it]m/i.test(pv)? 'FX': 'GG';
xx = /[it]m/i.test(pv)? 'GX': 'GG';

id = (id && !/^tt-?$/i.test(id)? id: '') + '';
id = id.replace(/^.*\b(tt\d+)\b.*$/, '$1').replace(/^.*\bid=(\d+)\b.*$/, '$1').replace(/^.*(?:movie|tv|(?:tv-?)?(?:shows?|series|episodes?))\/(\d+).*$/, '$1');
Expand Down Expand Up @@ -77,7 +88,7 @@ function changeStatus({ id, tt, ty, pv, yr, ur = '', ft = '' }) {
});

chrome.contextMenus.update('W2P-XX', {
title: `Find on ${ (xx == 'FX'? 'Flenix': 'Google') }`,
title: `Find on ${ (xx == 'GX'? 'GoStream': 'Google') }`,
checked: false
});
}
Expand All @@ -104,6 +115,7 @@ function addCouchpotato(request, sendResponse) {
headers: generateHeaders(request.basicAuth)
})
.then(response => response.json())
.catch(error => sendResponse({ error: 'Item not found', location: 'addCouchpotato => fetch.then.catch', silent: true }))
.then(response => {
sendResponse({ success: response.success });
})
Expand All @@ -124,6 +136,7 @@ function addWatcher(request, sendResponse) {

fetch(debug.url = `${ request.url }?apikey=${ request.token }&mode=addmovie&${ query }=${ id }`)
.then(response => response.json())
.catch(error => sendResponse({ error: 'Movie not found', location: 'addWatcher => fetch.then.catch', silent: true }))
.then(response => {
if((response.response + "") == "true")
return sendResponse({
Expand Down Expand Up @@ -153,6 +166,7 @@ function addRadarr(request, sendResponse) {

fetch(debug.url = `${ request.url }lookup/${ query }=${ id }&apikey=${ request.token }`)
.then(response => response.json())
.catch(error => sendResponse({ error: 'Movie not found', location: 'addRadarr => fetch.then.catch', silent: true }))
.then(data => {
let body,
props = {
Expand Down Expand Up @@ -239,6 +253,7 @@ function addSonarr(request, sendResponse) {

fetch(debug.url = `${ request.url }lookup?apikey=${ request.token }&term=${ query }`)
.then(response => response.json())
.catch(error => sendResponse({ error: 'TV Show not found', location: 'addSonarr => fetch.then.catch', silent: true }))
.then(data => {
if (!data instanceof Array || !data.length) {
throw new Error('TV Show not found');
Expand Down Expand Up @@ -441,15 +456,15 @@ chrome.contextMenus.onClicked.addListener((item) => {
`thetvdb.com/search?q=${ p(tl) }`;
break;
case 'xx':
url = external.X == 'FX'?
`flenix.tv/?do=search&story=${ p(tt) }&min_year=${ yr || 1990 }&filter=true&max_year=${ yr }&min_imdb=0&max_imdb=10&cat=1&order=date&g-recaptcha-response=${ SessionKey.value }`:
url = external.X == 'GX'?
`gostream.site/?s=${ p(tl) }`:
`google.com/search?q="${ p(tl, ' ') } ${ yr }"+${ pv }db`;
break;
case 'dl':
dnl = true;
url = external.U;
break;
default: return;
default: return; break;
}

if(!dnl)
Expand All @@ -474,7 +489,8 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
ft = id.tail || '';
id = id[pv + 'ID'] || id[pv.toLowerCase() + 'Id'];

changeStatus({ id, tt, yr, ty, pv, ur, ft });
if(tt && yr && ty)
changeStatus({ id, tt, yr, ty, pv, ur, ft });

try {
switch (request.type) {
Expand Down Expand Up @@ -512,31 +528,36 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
}
});

parentItem = chrome.contextMenus.create({
id: 'W2P',
title: 'Web to Plex'
});
if(SessionState === false) {
SessionState = true;

saveItem = chrome.contextMenus.create({
id: 'W2P-DL',
title: 'Nothing to Save'
});
parentItem = chrome.contextMenus.create({
id: 'W2P',
title: 'Web to Plex'
});

saveItem = chrome.contextMenus.create({
id: 'W2P-DL',
title: 'Nothing to Save'
});

// Standard search engines
for(let array = 'IM TM TV'.split(' '), DL = {}, length = array.length, index = 0, item; index < length; index++)
chrome.contextMenus.create({
id: 'W2P-' + (item = array[index]),
parentId: parentItem,
title: `Using ${ item }Db`,
type: 'checkbox',
checked: true // implement a way to use the checkboxes?
});

// Standard search engines
for(let array = 'IM TM TV'.split(' '), DL = {}, length = array.length, index = 0, item; index < length; index++)
// Non-standard search engines
chrome.contextMenus.create({
id: 'W2P-' + (item = array[index]),
id: 'W2P-XX',
parentId: parentItem,
title: `Using ${ item }Db`,
title: `Using best guess`,
type: 'checkbox',
checked: true // implement a way to use the checkboxes?
});

// Non-standard search engines
chrome.contextMenus.create({
id: 'W2P-XX',
parentId: parentItem,
title: `Using best guess`,
type: 'checkbox',
checked: true // implement a way to use the checkboxes?
});
}
Binary file added src/img/close.16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/img/close.48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/img/gostream.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/img/hide.16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/img/hide.48.png
Binary file added src/img/null.png
Binary file added src/img/plexit.16.png
Binary file added src/img/plexit.48.png
Binary file added src/img/reload.16.png
Binary file added src/img/reload.48.png
Binary file added src/img/settings.16.png
Binary file added src/img/settings.48.png
Binary file added src/img/show.16.png
Binary file added src/img/show.48.png
Loading

0 comments on commit 3d4115c

Please sign in to comment.