Skip to content
Permalink
Browse files

Fix authentication and scrobble issues

  • Loading branch information...
rafaelgssa committed Jul 23, 2019
1 parent 5e3be85 commit d2160a3a9e57afab5173a9a07a2e20ff9cf9edd7
Showing with 53 additions and 9 deletions.
  1. +1 −0 .vscode
  2. +5 −5 README.md
  3. +1 −1 package.json
  4. +3 −1 scripts/generateManifest.js
  5. +11 −0 src/class/Request.js
  6. +16 −0 src/class/Shared.js
  7. +15 −1 src/modules/background/index.js
  8. +1 −1 src/settings.js
@@ -34,31 +34,31 @@
* [Development](#development)

### What is Trakt?
Automatically scrobble TV show episodes and movies you are watching to Trakt.tv! Keep a history of everything you've watched! Sign up for a free account at [Trakt.tv](http://trakt.tv) and get a ton of features.
Automatically scrobble TV show episodes and movies you are watching to Trakt.tv! Keep a history of everything you've watched! Sign up for a free account at [Trakt.tv](https://trakt.tv) and get a ton of features.

### Why do I need this extension?
Trakt.tv has a [lot of plugins](http://trakt.tv/downloads) to automatically scrobble the movies and episodes you watch from your media center.
Trakt.tv has a [lot of plugins](https://trakt.tv/downloads) to automatically scrobble the movies and episodes you watch from your media center.
But there are none for Netflix.
This extension allows you to scrobble from Netflix to Trakt.tv. Cool, isn't it?

### How does traktflix work?
Unfortunately Netflix doesn't provide a public API, so the movie or episode info is extracted from the HTML of the player.

### Limitations
This extension only works with Netflix HTML player and new layout. If you are in the [old layout](http://www.netflix.com/WiHome), please open the [new one](http://www.netflix.com/browse).
This extension only works with Netflix HTML player and new layout. If you are in the [old layout](https://www.netflix.com/WiHome), please open the [new one](https://www.netflix.com/browse).
See this link for more info: https://help.netflix.com/en/node/23742

### Problems
If you find any problems or have suggestions or questions, feel free to [open an issue](https://github.com/tegon/traktflix/issues/new)

### Development
Create an application in [Trakt API](http://trakt.tv/oauth/applications/new).
Create an application in [Trakt API](https://trakt.tv/oauth/applications/new).

Don't forget to check `/scrobble` permission.

In `Redirect uri:` put `https://www.netflix.com/Activate`

In `Javascript (cors) origins:` put `http://www.netflix.com, moz-extension:// and chrome-extension://`
In `Javascript (cors) origins:` put `https://www.netflix.com, moz-extension:// and chrome-extension://`

Copy the `config.json` example file and change Trakt.tv credentials:
```bash
@@ -1,7 +1,7 @@
{
"name": "traktflix",
"description": "A Trakt.tv scrobbler for Netflix.",
"version": "2.0.8",
"version": "2.0.9",
"dependencies": {
"flux": "^2.1.1",
"material-design-lite": "^1.3.0",
@@ -68,12 +68,14 @@ module.exports = function (browserName) {
]
};

const bextJson = require(`${ROOT_PATH}/bext.json`);

switch (browserName) {
case `chrome`:
manifest.key = bextJson.chrome.extensionKey;
manifest.permissions.push(`declarativeContent`);
break;
case `firefox`:
const bextJson = require(`${ROOT_PATH}/bext.json`);
manifest.browser_specific_settings = {
gecko: {
id: bextJson.firefox.extensionId
@@ -1,8 +1,19 @@
import Settings from '../settings';
import BrowserStorage from './BrowserStorage';
import Shared from './Shared';

class Request {
async _send(options) {
if (!Shared.isBackgroundPage() && !options.url.match(location.host)) {
try {
const response = await browser.runtime.sendMessage({ type: `request`, options: JSON.stringify(options) });
options.success(response);
} catch (error) {
options.error(error.status, error.responseText, error.options);
}
return;
}

const storage = await BrowserStorage.get(`data`);
const xhr = new XMLHttpRequest();
xhr.open(options.method, options.url, true);
@@ -0,0 +1,16 @@
class Shared {
constructor() {
this.backgroundPage = false;
}

setBackgroundPage(backgroundPage) {
this.backgroundPage = backgroundPage;
}

isBackgroundPage() {
return !!this.backgroundPage;
}
}

const shared = new Shared();
export default shared;
@@ -5,6 +5,10 @@ import BrowserStorage from '../../class/BrowserStorage';
import Oauth from '../../class/Oauth';
import Permissions from '../../class/Permissions';
import Rollbar from '../../class/Rollbar';
import Request from '../../class/Request';
import Shared from '../../class/Shared';

Shared.setBackgroundPage(true);

/* global analytics */
/**
@@ -64,7 +68,7 @@ if (chrome && chrome.declarativeContent) {
}

browser.runtime.onMessage.addListener((request, sender) => {
return new Promise(async resolve => {
return new Promise(async (resolve, reject) => {
switch (request.type) {
case `getApiDefs`:
// noinspection JSIgnoredPromiseFromCall
@@ -140,6 +144,16 @@ browser.runtime.onMessage.addListener((request, sender) => {
});
}
break;
case `request`: {
const options = JSON.parse(request.options);
try {
const response = await Request.sendAndWait(options);
resolve(response);
} catch (error) {
reject(error);
}
return;
}
}
resolve();
});
@@ -1,5 +1,5 @@
const settings = {
authorizeUri: `http://trakt.tv/oauth/authorize`,
authorizeUri: `https://trakt.tv/oauth/authorize`,
apiUri: `https://api.trakt.tv`,
redirectUri: `https://www.netflix.com/Activate`,
clientId: `@@clientId`,

0 comments on commit d2160a3

Please sign in to comment.
You can’t perform that action at this time.