This commit is contained in:
luke-hagar-sp
2022-07-22 20:40:11 -05:00
parent b2c7832873
commit 5942c95bc3
2 changed files with 18 additions and 8 deletions

View File

@@ -2,7 +2,9 @@ import { PlexOauth, IPlexClientDetails } from "plex-oauth";
import v4 from "uuid/dist/v4"; import v4 from "uuid/dist/v4";
import axios from "axios"; import axios from "axios";
import qs from "qs"; import qs from "qs";
var PlexAPIOauth = /** @class */ function ( class PlexAPIOauth {
constructor(
clientId, clientId,
product = "Plex-API-OAuth", product = "Plex-API-OAuth",
device = "Web Client", device = "Web Client",
@@ -10,6 +12,13 @@ var PlexAPIOauth = /** @class */ function (
forwardUrl = "", forwardUrl = "",
platform = "Web" platform = "Web"
) { ) {
this.clientId = clientId;
this.product = product
this.device = device
this.version = version
this.forwardUrl = forwardUrl
this.platform = platform
if (clientId === null) { if (clientId === null) {
var clientId = localStorage.getItem("plex-client-id"); //Defaults to last used ClientId from any previous runs var clientId = localStorage.getItem("plex-client-id"); //Defaults to last used ClientId from any previous runs
} }
@@ -39,12 +48,15 @@ var PlexAPIOauth = /** @class */ function (
console.log("Plex DataBase:"); console.log("Plex DataBase:");
console.log(plexData); console.log(plexData);
function openInNewTab(url) { }
openInNewTab(url) {
var separateWindow = window.open(url, "_blank"); var separateWindow = window.open(url, "_blank");
separateWindow?.focus; separateWindow?.focus;
} }
var clientInformation = { plexClientInformation = {
clientIdentifier: clientId, // This is a unique identifier used to identify your app with Plex. - If none is provided a new one is generated and saved locally clientIdentifier: clientId, // This is a unique identifier used to identify your app with Plex. - If none is provided a new one is generated and saved locally
product: product, // Name of your application - Defaults to Plex-API-OAuth product: product, // Name of your application - Defaults to Plex-API-OAuth
device: device, // The type of device your application is running on - Defaults to "Web Client" device: device, // The type of device your application is running on - Defaults to "Web Client"
@@ -53,7 +65,7 @@ var PlexAPIOauth = /** @class */ function (
platform: platform, // Platform your application runs on - Defaults to 'Web' platform: platform, // Platform your application runs on - Defaults to 'Web'
}; };
var plexOauth = new PlexOauth(clientInformation); plexOauth = new PlexOauth(plexClientInformation);
// Get hosted UI URL and Pin Id // Get hosted UI URL and Pin Id
async function plexLogin() { async function plexLogin() {
@@ -159,6 +171,4 @@ var PlexAPIOauth = /** @class */ function (
return plexData.plexLibraries; return plexData.plexLibraries;
} }
}; };
module.exports = { export { PlexAPIOauth };
PlexAPIOauth: PlexAPIOauth,
};

View File

@@ -1,6 +1,6 @@
{ {
"name": "plex-api-oauth", "name": "plex-api-oauth",
"version": "1.0.2", "version": "1.0.3",
"description": "An NPM Module designed to make Plex Media Server and plex.tv API calls easier to implement in JavaScript and React projects", "description": "An NPM Module designed to make Plex Media Server and plex.tv API calls easier to implement in JavaScript and React projects",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {