mirror of
https://github.com/LukeHagar/plex-api-oauth.git
synced 2025-12-06 12:37:50 +00:00
Cleaning dependancies
This commit is contained in:
2160
package-lock.json
generated
2160
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
13
package.json
13
package.json
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "plex-api-oauth",
|
"name": "plex-api-oauth",
|
||||||
"version": "1.1.103",
|
"version": "1.1.114",
|
||||||
"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": "./src/index.js",
|
"main": "./src/index.js",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
@@ -13,18 +13,9 @@
|
|||||||
"axios": "^0.27.2",
|
"axios": "^0.27.2",
|
||||||
"plex-oauth": "^2.0.2",
|
"plex-oauth": "^2.0.2",
|
||||||
"qs": "^6.11.0",
|
"qs": "^6.11.0",
|
||||||
"react": "^18.2.0",
|
|
||||||
"react-infinite-scroller": "^1.2.6",
|
|
||||||
"ts-mocha": "^10.0.0",
|
|
||||||
"typescript": "^4.7.4",
|
|
||||||
"uuid": "^8.3.2"
|
"uuid": "^8.3.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/expect": "^24.3.0",
|
"mocha": "^10.0.0"
|
||||||
"@types/mocha": "^9.1.1",
|
|
||||||
"@types/qs": "^6.9.7",
|
|
||||||
"@types/uuid": "^8.3.4",
|
|
||||||
"mocha": "^10.0.0",
|
|
||||||
"request": "^2.88.2"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import { PlexOauth } from "plex-oauth";
|
|||||||
import { v4 } from "uuid";
|
import { v4 } from "uuid";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import qs from "qs";
|
import qs from "qs";
|
||||||
import { useState, useEffect } from "react";
|
|
||||||
|
|
||||||
export async function PlexLogin(plexClientInformation) {
|
export async function PlexLogin(plexClientInformation) {
|
||||||
var plexOauth = new PlexOauth(plexClientInformation);
|
var plexOauth = new PlexOauth(plexClientInformation);
|
||||||
@@ -172,14 +171,10 @@ export async function GetPlexServers(plexClientInformation, plexTVAuthToken) {
|
|||||||
export async function GetPlexLibraries(plexServers, plexLibraries) {
|
export async function GetPlexLibraries(plexServers, plexLibraries) {
|
||||||
let libraryArray = [];
|
let libraryArray = [];
|
||||||
for (const server of plexServers) {
|
for (const server of plexServers) {
|
||||||
let connectionUri = server.relayConnection;
|
|
||||||
if (server.localConnection) {
|
|
||||||
connectionUri = server.localConnection;
|
|
||||||
}
|
|
||||||
let response = await axios({
|
let response = await axios({
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url:
|
url:
|
||||||
connectionUri.uri +
|
server.preferredConnection.uri +
|
||||||
"/library/sections/?" +
|
"/library/sections/?" +
|
||||||
qs.stringify({
|
qs.stringify({
|
||||||
"X-Plex-Token": server.accessToken,
|
"X-Plex-Token": server.accessToken,
|
||||||
@@ -190,13 +185,23 @@ export async function GetPlexLibraries(plexServers, plexLibraries) {
|
|||||||
});
|
});
|
||||||
for (const library of response.data.MediaContainer.Directory) {
|
for (const library of response.data.MediaContainer.Directory) {
|
||||||
libraryArray.push({
|
libraryArray.push({
|
||||||
server: server,
|
server: server.clientIdentifier,
|
||||||
allowSync: library.allowSync,
|
allowSync: library.allowSync,
|
||||||
art: library.art,
|
art: library.art,
|
||||||
composite: library.composite,
|
composite: library.composite,
|
||||||
filters: library.filters,
|
filters: library.filters,
|
||||||
refreshing: library.refreshing,
|
refreshing: library.refreshing,
|
||||||
thumb: library.thumb,
|
thumb:
|
||||||
|
server.preferredConnection.uri +
|
||||||
|
"/photo/:/transcode?" +
|
||||||
|
qs.stringify({
|
||||||
|
width: 240,
|
||||||
|
height: 240,
|
||||||
|
minSize: 1,
|
||||||
|
upscale: 1,
|
||||||
|
url: library.thumb + "?X-Plex-Token=" + server.accessToken,
|
||||||
|
"X-Plex-Token": server.accessToken,
|
||||||
|
}),
|
||||||
key: library.key,
|
key: library.key,
|
||||||
type: library.type,
|
type: library.type,
|
||||||
title: library.title,
|
title: library.title,
|
||||||
@@ -221,14 +226,10 @@ export async function GetPlexLibraries(plexServers, plexLibraries) {
|
|||||||
export async function GetPlexMovieLibraries(plexServers, plexLibraries) {
|
export async function GetPlexMovieLibraries(plexServers, plexLibraries) {
|
||||||
let libraryArray = [];
|
let libraryArray = [];
|
||||||
for (const server of plexServers) {
|
for (const server of plexServers) {
|
||||||
let connectionUri = server.relayConnection;
|
|
||||||
if (server.localConnection) {
|
|
||||||
connectionUri = server.localConnection;
|
|
||||||
}
|
|
||||||
let response = await axios({
|
let response = await axios({
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url:
|
url:
|
||||||
connectionUri.uri +
|
server.preferredConnection.uri +
|
||||||
"/library/sections/?" +
|
"/library/sections/?" +
|
||||||
qs.stringify({
|
qs.stringify({
|
||||||
"X-Plex-Token": server.accessToken,
|
"X-Plex-Token": server.accessToken,
|
||||||
@@ -247,7 +248,17 @@ export async function GetPlexMovieLibraries(plexServers, plexLibraries) {
|
|||||||
composite: library.composite,
|
composite: library.composite,
|
||||||
filters: library.filters,
|
filters: library.filters,
|
||||||
refreshing: library.refreshing,
|
refreshing: library.refreshing,
|
||||||
thumb: library.thumb,
|
thumb:
|
||||||
|
server.preferredConnection.uri +
|
||||||
|
"/photo/:/transcode?" +
|
||||||
|
qs.stringify({
|
||||||
|
width: 240,
|
||||||
|
height: 240,
|
||||||
|
minSize: 1,
|
||||||
|
upscale: 1,
|
||||||
|
url: library.thumb + "?X-Plex-Token=" + server.accessToken,
|
||||||
|
"X-Plex-Token": server.accessToken,
|
||||||
|
}),
|
||||||
key: library.key,
|
key: library.key,
|
||||||
type: library.type,
|
type: library.type,
|
||||||
title: library.title,
|
title: library.title,
|
||||||
@@ -272,14 +283,10 @@ export async function GetPlexMovieLibraries(plexServers, plexLibraries) {
|
|||||||
export async function GetPlexMusicLibraries(plexServers, plexLibraries) {
|
export async function GetPlexMusicLibraries(plexServers, plexLibraries) {
|
||||||
let libraryArray = [];
|
let libraryArray = [];
|
||||||
for (const server of plexServers) {
|
for (const server of plexServers) {
|
||||||
let connectionUri = server.relayConnection;
|
|
||||||
if (server.localConnection) {
|
|
||||||
connectionUri = server.localConnection;
|
|
||||||
}
|
|
||||||
let response = await axios({
|
let response = await axios({
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url:
|
url:
|
||||||
connectionUri.uri +
|
server.preferredConnection.uri +
|
||||||
"/library/sections/?" +
|
"/library/sections/?" +
|
||||||
qs.stringify({
|
qs.stringify({
|
||||||
"X-Plex-Token": server.accessToken,
|
"X-Plex-Token": server.accessToken,
|
||||||
@@ -298,7 +305,17 @@ export async function GetPlexMusicLibraries(plexServers, plexLibraries) {
|
|||||||
composite: library.composite,
|
composite: library.composite,
|
||||||
filters: library.filters,
|
filters: library.filters,
|
||||||
refreshing: library.refreshing,
|
refreshing: library.refreshing,
|
||||||
thumb: library.thumb,
|
thumb:
|
||||||
|
server.preferredConnection.uri +
|
||||||
|
"/photo/:/transcode?" +
|
||||||
|
qs.stringify({
|
||||||
|
width: 240,
|
||||||
|
height: 240,
|
||||||
|
minSize: 1,
|
||||||
|
upscale: 1,
|
||||||
|
url: library.thumb + "?X-Plex-Token=" + server.accessToken,
|
||||||
|
"X-Plex-Token": server.accessToken,
|
||||||
|
}),
|
||||||
key: library.key,
|
key: library.key,
|
||||||
type: library.type,
|
type: library.type,
|
||||||
title: library.title,
|
title: library.title,
|
||||||
@@ -323,14 +340,10 @@ export async function GetPlexMusicLibraries(plexServers, plexLibraries) {
|
|||||||
export async function GetPlexTVShowLibraries(plexServers, plexLibraries) {
|
export async function GetPlexTVShowLibraries(plexServers, plexLibraries) {
|
||||||
let libraryArray = [];
|
let libraryArray = [];
|
||||||
for (const server of plexServers) {
|
for (const server of plexServers) {
|
||||||
let connectionUri = server.relayConnection;
|
|
||||||
if (server.localConnection) {
|
|
||||||
connectionUri = server.localConnection;
|
|
||||||
}
|
|
||||||
let response = await axios({
|
let response = await axios({
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url:
|
url:
|
||||||
connectionUri.uri +
|
server.preferredConnection.uri +
|
||||||
"/library/sections/?" +
|
"/library/sections/?" +
|
||||||
qs.stringify({
|
qs.stringify({
|
||||||
"X-Plex-Token": server.accessToken,
|
"X-Plex-Token": server.accessToken,
|
||||||
@@ -349,7 +362,17 @@ export async function GetPlexTVShowLibraries(plexServers, plexLibraries) {
|
|||||||
composite: library.composite,
|
composite: library.composite,
|
||||||
filters: library.filters,
|
filters: library.filters,
|
||||||
refreshing: library.refreshing,
|
refreshing: library.refreshing,
|
||||||
thumb: library.thumb,
|
thumb:
|
||||||
|
server.preferredConnection.uri +
|
||||||
|
"/photo/:/transcode?" +
|
||||||
|
qs.stringify({
|
||||||
|
width: 240,
|
||||||
|
height: 240,
|
||||||
|
minSize: 1,
|
||||||
|
upscale: 1,
|
||||||
|
url: library.thumb + "?X-Plex-Token=" + server.accessToken,
|
||||||
|
"X-Plex-Token": server.accessToken,
|
||||||
|
}),
|
||||||
key: library.key,
|
key: library.key,
|
||||||
type: library.type,
|
type: library.type,
|
||||||
title: library.title,
|
title: library.title,
|
||||||
@@ -377,19 +400,17 @@ export async function GetPlexMovies(
|
|||||||
plexLibraries
|
plexLibraries
|
||||||
) {
|
) {
|
||||||
let movieLibraryContent = [];
|
let movieLibraryContent = [];
|
||||||
for (const server of servers) {
|
for (const server of plexServers) {
|
||||||
let connectionUri = server.relayConnection;
|
|
||||||
if (server.localConnection) {
|
|
||||||
connectionUri = server.localConnection;
|
|
||||||
}
|
|
||||||
for (const library of plexLibraries.filter(
|
for (const library of plexLibraries.filter(
|
||||||
(Obj) =>
|
(Obj) => Obj.server === server.clientIdentifier && Obj.type === "movie"
|
||||||
Obj.server.clientIdentifier === server.clientIdentifier &&
|
|
||||||
Obj.type === "movie"
|
|
||||||
)) {
|
)) {
|
||||||
let response = await axios({
|
let response = await axios({
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url: connectionUri.uri + "/library/sections/" + library?.key + "/all",
|
url:
|
||||||
|
server.preferredConnection.uri +
|
||||||
|
"/library/sections/" +
|
||||||
|
library?.key +
|
||||||
|
"/all",
|
||||||
params: {
|
params: {
|
||||||
type: 1,
|
type: 1,
|
||||||
...searchParams,
|
...searchParams,
|
||||||
@@ -403,8 +424,8 @@ export async function GetPlexMovies(
|
|||||||
console.debug(response.data);
|
console.debug(response.data);
|
||||||
for (const data of response.data.MediaContainer.Metadata) {
|
for (const data of response.data.MediaContainer.Metadata) {
|
||||||
movieLibraryContent.push({
|
movieLibraryContent.push({
|
||||||
server: server,
|
server: server.clientIdentifier,
|
||||||
library: library,
|
library: library.uuid,
|
||||||
ratingKey: data.ratingKey,
|
ratingKey: data.ratingKey,
|
||||||
key: data.key,
|
key: data.key,
|
||||||
guid: data.guid,
|
guid: data.guid,
|
||||||
@@ -417,7 +438,17 @@ export async function GetPlexMovies(
|
|||||||
audienceRating: data.audienceRating,
|
audienceRating: data.audienceRating,
|
||||||
year: data.year,
|
year: data.year,
|
||||||
tagline: data.tagline,
|
tagline: data.tagline,
|
||||||
thumb: data.thumb,
|
thumb:
|
||||||
|
server.preferredConnection.uri +
|
||||||
|
"/photo/:/transcode?" +
|
||||||
|
qs.stringify({
|
||||||
|
width: 240,
|
||||||
|
height: 240,
|
||||||
|
minSize: 1,
|
||||||
|
upscale: 1,
|
||||||
|
url: data.thumb + "?X-Plex-Token=" + server.accessToken,
|
||||||
|
"X-Plex-Token": server.accessToken,
|
||||||
|
}),
|
||||||
art: data.art,
|
art: data.art,
|
||||||
duration: data.duration,
|
duration: data.duration,
|
||||||
originallyAvailableAt: data.originallyAvailableAt,
|
originallyAvailableAt: data.originallyAvailableAt,
|
||||||
@@ -446,18 +477,16 @@ export async function GetPlexArtists(
|
|||||||
) {
|
) {
|
||||||
let artistLibraryContent = [];
|
let artistLibraryContent = [];
|
||||||
for (const server of plexServers) {
|
for (const server of plexServers) {
|
||||||
let connectionUri = server.relayConnection;
|
|
||||||
if (server.localConnection) {
|
|
||||||
connectionUri = server.localConnection;
|
|
||||||
}
|
|
||||||
for (const library of plexLibraries.filter(
|
for (const library of plexLibraries.filter(
|
||||||
(Obj) =>
|
(Obj) => Obj.server === server.clientIdentifier && Obj.type === "artist"
|
||||||
Obj.server.clientIdentifier === server.clientIdentifier &&
|
|
||||||
Obj.type === "artist"
|
|
||||||
)) {
|
)) {
|
||||||
let response = await axios({
|
let response = await axios({
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url: connectionUri.uri + "/library/sections/" + library?.key + "/all",
|
url:
|
||||||
|
server.preferredConnection.uri +
|
||||||
|
"/library/sections/" +
|
||||||
|
library?.key +
|
||||||
|
"/all",
|
||||||
headers: { accept: "application/json" },
|
headers: { accept: "application/json" },
|
||||||
params: {
|
params: {
|
||||||
type: 8,
|
type: 8,
|
||||||
@@ -470,8 +499,8 @@ export async function GetPlexArtists(
|
|||||||
console.debug(response.data);
|
console.debug(response.data);
|
||||||
for (const data of response.data.MediaContainer.Metadata) {
|
for (const data of response.data.MediaContainer.Metadata) {
|
||||||
artistLibraryContent.push({
|
artistLibraryContent.push({
|
||||||
server: server,
|
server: server.clientIdentifier,
|
||||||
library: library,
|
library: library.uuid,
|
||||||
ratingKey: data.ratingKey,
|
ratingKey: data.ratingKey,
|
||||||
key: data.key,
|
key: data.key,
|
||||||
guid: data.guid,
|
guid: data.guid,
|
||||||
@@ -479,7 +508,17 @@ export async function GetPlexArtists(
|
|||||||
title: data.title,
|
title: data.title,
|
||||||
summary: data.summary,
|
summary: data.summary,
|
||||||
index: data.index,
|
index: data.index,
|
||||||
thumb: data.thumb,
|
thumb:
|
||||||
|
server.preferredConnection.uri +
|
||||||
|
"/photo/:/transcode?" +
|
||||||
|
qs.stringify({
|
||||||
|
width: 240,
|
||||||
|
height: 240,
|
||||||
|
minSize: 1,
|
||||||
|
upscale: 1,
|
||||||
|
url: data.thumb + "?X-Plex-Token=" + server.accessToken,
|
||||||
|
"X-Plex-Token": server.accessToken,
|
||||||
|
}),
|
||||||
art: data.art,
|
art: data.art,
|
||||||
addedAt: data.addedAt,
|
addedAt: data.addedAt,
|
||||||
updatedAt: data.updatedAt,
|
updatedAt: data.updatedAt,
|
||||||
@@ -500,18 +539,16 @@ export async function GetPlexAlbums(
|
|||||||
) {
|
) {
|
||||||
let albumLibraryContent = [];
|
let albumLibraryContent = [];
|
||||||
for (const server of plexServers) {
|
for (const server of plexServers) {
|
||||||
let connectionUri = server.relayConnection;
|
|
||||||
if (server.localConnection) {
|
|
||||||
connectionUri = server.localConnection;
|
|
||||||
}
|
|
||||||
for (const library of plexLibraries.filter(
|
for (const library of plexLibraries.filter(
|
||||||
(Obj) =>
|
(Obj) => Obj.server === server.clientIdentifier && Obj.type === "artist"
|
||||||
Obj.server.clientIdentifier === server.clientIdentifier &&
|
|
||||||
Obj.type === "artist"
|
|
||||||
)) {
|
)) {
|
||||||
let response = await axios({
|
let response = await axios({
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url: connectionUri.uri + "/library/sections/" + library?.key + "/all",
|
url:
|
||||||
|
server.preferredConnection.uri +
|
||||||
|
"/library/sections/" +
|
||||||
|
library?.key +
|
||||||
|
"/all",
|
||||||
headers: { accept: "application/json" },
|
headers: { accept: "application/json" },
|
||||||
params: {
|
params: {
|
||||||
type: 9,
|
type: 9,
|
||||||
@@ -524,8 +561,8 @@ export async function GetPlexAlbums(
|
|||||||
console.debug(response.data);
|
console.debug(response.data);
|
||||||
for (const data of response.data.MediaContainer.Metadata) {
|
for (const data of response.data.MediaContainer.Metadata) {
|
||||||
albumLibraryContent.push({
|
albumLibraryContent.push({
|
||||||
server: server,
|
server: server.clientIdentifier,
|
||||||
library: library,
|
library: library.uuid,
|
||||||
addedAt: data.addedAt,
|
addedAt: data.addedAt,
|
||||||
guid: data.guid,
|
guid: data.guid,
|
||||||
index: data.index,
|
index: data.index,
|
||||||
@@ -540,7 +577,17 @@ export async function GetPlexAlbums(
|
|||||||
parentTitle: data.parentTitle,
|
parentTitle: data.parentTitle,
|
||||||
ratingKey: data.ratingKey,
|
ratingKey: data.ratingKey,
|
||||||
summary: data.summary,
|
summary: data.summary,
|
||||||
thumb: data.thumb,
|
thumb:
|
||||||
|
server.preferredConnection.uri +
|
||||||
|
"/photo/:/transcode?" +
|
||||||
|
qs.stringify({
|
||||||
|
width: 240,
|
||||||
|
height: 240,
|
||||||
|
minSize: 1,
|
||||||
|
upscale: 1,
|
||||||
|
url: data.thumb + "?X-Plex-Token=" + server.accessToken,
|
||||||
|
"X-Plex-Token": server.accessToken,
|
||||||
|
}),
|
||||||
title: data.title,
|
title: data.title,
|
||||||
type: data.type,
|
type: data.type,
|
||||||
updatedAt: data.updatedAt,
|
updatedAt: data.updatedAt,
|
||||||
@@ -559,18 +606,16 @@ export async function GetPlexSongs(
|
|||||||
) {
|
) {
|
||||||
let songLibraryContent = [];
|
let songLibraryContent = [];
|
||||||
for (const server of plexServers) {
|
for (const server of plexServers) {
|
||||||
let connectionUri = server.relayConnection;
|
|
||||||
if (server.localConnection) {
|
|
||||||
connectionUri = server.localConnection;
|
|
||||||
}
|
|
||||||
for (const library of plexLibraries.filter(
|
for (const library of plexLibraries.filter(
|
||||||
(Obj) =>
|
(Obj) => Obj.server === server.clientIdentifier && Obj.type === "artist"
|
||||||
Obj.server.clientIdentifier === server.clientIdentifier &&
|
|
||||||
Obj.type === "artist"
|
|
||||||
)) {
|
)) {
|
||||||
let response = await axios({
|
let response = await axios({
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url: connectionUri.uri + "/library/sections/" + library?.key + "/all",
|
url:
|
||||||
|
server.preferredConnection.uri +
|
||||||
|
"/library/sections/" +
|
||||||
|
library?.key +
|
||||||
|
"/all",
|
||||||
headers: { accept: "application/json" },
|
headers: { accept: "application/json" },
|
||||||
params: {
|
params: {
|
||||||
type: 10,
|
type: 10,
|
||||||
@@ -605,7 +650,17 @@ export async function GetPlexSongs(
|
|||||||
summary: data.summary,
|
summary: data.summary,
|
||||||
index: data.index,
|
index: data.index,
|
||||||
parentIndex: data.parentIndex,
|
parentIndex: data.parentIndex,
|
||||||
thumb: data.thumb,
|
thumb:
|
||||||
|
server.preferredConnection.uri +
|
||||||
|
"/photo/:/transcode?" +
|
||||||
|
qs.stringify({
|
||||||
|
width: 240,
|
||||||
|
height: 240,
|
||||||
|
minSize: 1,
|
||||||
|
upscale: 1,
|
||||||
|
url: data.thumb + "?X-Plex-Token=" + server.accessToken,
|
||||||
|
"X-Plex-Token": server.accessToken,
|
||||||
|
}),
|
||||||
parentThumb: data.parentThumb,
|
parentThumb: data.parentThumb,
|
||||||
grandparentThumb: data.grandparentThumb,
|
grandparentThumb: data.grandparentThumb,
|
||||||
duration: data.duration,
|
duration: data.duration,
|
||||||
@@ -628,19 +683,16 @@ export async function GetPlexShows(
|
|||||||
) {
|
) {
|
||||||
let tvShowLibraryContent = [];
|
let tvShowLibraryContent = [];
|
||||||
for (const server of plexServers) {
|
for (const server of plexServers) {
|
||||||
let connectionUri = server.relayConnection;
|
|
||||||
if (server.localConnection) {
|
|
||||||
connectionUri = server.localConnection;
|
|
||||||
}
|
|
||||||
for (const showLibrary of plexLibraries.filter(
|
for (const showLibrary of plexLibraries.filter(
|
||||||
(Obj) =>
|
(Obj) => Obj.server === server.clientIdentifier && Obj.type === "show"
|
||||||
Obj.server.clientIdentifier === server.clientIdentifier &&
|
|
||||||
Obj.type === "show"
|
|
||||||
)) {
|
)) {
|
||||||
let response = await axios({
|
let response = await axios({
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url:
|
url:
|
||||||
connectionUri.uri + "/library/sections/" + showLibrary?.key + "/all",
|
server.preferredConnection.uri +
|
||||||
|
"/library/sections/" +
|
||||||
|
showLibrary?.key +
|
||||||
|
"/all",
|
||||||
headers: { accept: "application/json" },
|
headers: { accept: "application/json" },
|
||||||
params: {
|
params: {
|
||||||
type: 2,
|
type: 2,
|
||||||
@@ -668,7 +720,17 @@ export async function GetPlexShows(
|
|||||||
audienceRating: data.audienceRating,
|
audienceRating: data.audienceRating,
|
||||||
year: data.year,
|
year: data.year,
|
||||||
tagline: data.tagline,
|
tagline: data.tagline,
|
||||||
thumb: data.thumb,
|
thumb:
|
||||||
|
server.preferredConnection.uri +
|
||||||
|
"/photo/:/transcode?" +
|
||||||
|
qs.stringify({
|
||||||
|
width: 240,
|
||||||
|
height: 240,
|
||||||
|
minSize: 1,
|
||||||
|
upscale: 1,
|
||||||
|
url: data.thumb + "?X-Plex-Token=" + server.accessToken,
|
||||||
|
"X-Plex-Token": server.accessToken,
|
||||||
|
}),
|
||||||
art: data.art,
|
art: data.art,
|
||||||
theme: data.theme,
|
theme: data.theme,
|
||||||
duration: data.duration,
|
duration: data.duration,
|
||||||
@@ -699,19 +761,16 @@ export async function GetPlexSeasons(
|
|||||||
) {
|
) {
|
||||||
let seasonArray = [];
|
let seasonArray = [];
|
||||||
for (const server of plexServers) {
|
for (const server of plexServers) {
|
||||||
let connectionUri = server.relayConnection;
|
|
||||||
if (server.localConnection) {
|
|
||||||
connectionUri = server.localConnection;
|
|
||||||
}
|
|
||||||
for (const showLibrary of plexLibraries.filter(
|
for (const showLibrary of plexLibraries.filter(
|
||||||
(Obj) =>
|
(Obj) => Obj.server === server.clientIdentifier && Obj.type === "show"
|
||||||
Obj.server.clientIdentifier === server.clientIdentifier &&
|
|
||||||
Obj.type === "show"
|
|
||||||
)) {
|
)) {
|
||||||
let response = await axios({
|
let response = await axios({
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url:
|
url:
|
||||||
connectionUri.uri + "/library/sections/" + showLibrary?.key + "/all",
|
server.preferredConnection.uri +
|
||||||
|
"/library/sections/" +
|
||||||
|
showLibrary?.key +
|
||||||
|
"/all",
|
||||||
headers: { accept: "application/json" },
|
headers: { accept: "application/json" },
|
||||||
params: {
|
params: {
|
||||||
type: 3,
|
type: 3,
|
||||||
@@ -736,19 +795,16 @@ export async function GetPlexEpisodes(
|
|||||||
) {
|
) {
|
||||||
let episodeLibrary = [];
|
let episodeLibrary = [];
|
||||||
for (const server of plexServers) {
|
for (const server of plexServers) {
|
||||||
let connectionUri = server.relayConnection;
|
|
||||||
if (server.localConnection) {
|
|
||||||
connectionUri = server.localConnection;
|
|
||||||
}
|
|
||||||
for (const showLibrary of plexLibraries.filter(
|
for (const showLibrary of plexLibraries.filter(
|
||||||
(Obj) =>
|
(Obj) => Obj.server === server.clientIdentifier && Obj.type === "show"
|
||||||
Obj.server.clientIdentifier === server.clientIdentifier &&
|
|
||||||
Obj.type === "show"
|
|
||||||
)) {
|
)) {
|
||||||
let response = await axios({
|
let response = await axios({
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url:
|
url:
|
||||||
connectionUri.uri + "/library/sections/" + showLibrary?.key + "/all",
|
server.preferredConnection.uri +
|
||||||
|
"/library/sections/" +
|
||||||
|
showLibrary?.key +
|
||||||
|
"/all",
|
||||||
headers: { accept: "application/json" },
|
headers: { accept: "application/json" },
|
||||||
params: {
|
params: {
|
||||||
type: 4,
|
type: 4,
|
||||||
@@ -874,3 +930,135 @@ export async function GetLibraryPages(
|
|||||||
}
|
}
|
||||||
return { items, hasMore };
|
return { items, hasMore };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function GetMusicHub(
|
||||||
|
plexClientinformation,
|
||||||
|
plexServers,
|
||||||
|
plexLibraries
|
||||||
|
) {
|
||||||
|
let hubs = [];
|
||||||
|
for (const server of plexServers) {
|
||||||
|
for (const musicLibrary of plexLibraries.filter(
|
||||||
|
(Obj) => Obj.server === server.clientIdentifier && Obj.type === "artist"
|
||||||
|
)) {
|
||||||
|
let response = await axios({
|
||||||
|
method: "GET",
|
||||||
|
url:
|
||||||
|
server.preferredConnection.uri +
|
||||||
|
"/hubs/sections/" +
|
||||||
|
musicLibrary?.key,
|
||||||
|
headers: { accept: "application/json" },
|
||||||
|
params: {
|
||||||
|
count: 12,
|
||||||
|
includeLibraryPlaylists: 1,
|
||||||
|
includeStations: 1,
|
||||||
|
includeRecentChannels: 1,
|
||||||
|
includeMeta: 1,
|
||||||
|
includeExternalMetadata: 1,
|
||||||
|
excludeFields: "summary",
|
||||||
|
"X-Plex-Product": plexClientinformation.product,
|
||||||
|
"X-Plex-Version": plexClientinformation.version,
|
||||||
|
"X-Plex-Client-Identifier": plexClientinformation.clientIdentifier,
|
||||||
|
"X-Plex-Token": server?.accessToken,
|
||||||
|
},
|
||||||
|
}).catch((err) => {
|
||||||
|
throw err;
|
||||||
|
});
|
||||||
|
console.debug(response.data);
|
||||||
|
|
||||||
|
for (const hub of response.data.MediaContainer.Hub) {
|
||||||
|
let hubMetaData = [];
|
||||||
|
if (hub.size > 1) {
|
||||||
|
for (const metaDataEntry of hub.Metadata) {
|
||||||
|
let metaEntry = {
|
||||||
|
Genre: metaDataEntry.Genre,
|
||||||
|
addedAt: metaDataEntry.addedAt,
|
||||||
|
guid: metaDataEntry.guid,
|
||||||
|
index: metaDataEntry.index,
|
||||||
|
key: metaDataEntry.key,
|
||||||
|
librarySectionID: metaDataEntry.librarySectionID,
|
||||||
|
librarySectionKey: metaDataEntry.librarySectionKey,
|
||||||
|
librarySectionTitle: metaDataEntry.librarySectionTitle,
|
||||||
|
loudnessAnalysisVersion: metaDataEntry.loudnessAnalysisVersion,
|
||||||
|
musicAnalysisVersion: metaDataEntry.musicAnalysisVersion,
|
||||||
|
originallyAvailableAt: metaDataEntry.originallyAvailableAt,
|
||||||
|
parentGuid: metaDataEntry.parentGuid,
|
||||||
|
parentKey: metaDataEntry.parentKey,
|
||||||
|
parentRatingKey: metaDataEntry.parentRatingKey,
|
||||||
|
parentThumb: metaDataEntry.parentThumb,
|
||||||
|
parentTitle: metaDataEntry.parentTitle,
|
||||||
|
ratingKey: metaDataEntry.ratingKey,
|
||||||
|
studio: metaDataEntry.studio,
|
||||||
|
thumb:
|
||||||
|
server.preferredConnection.uri +
|
||||||
|
"/photo/:/transcode?" +
|
||||||
|
qs.stringify({
|
||||||
|
width: 240,
|
||||||
|
height: 240,
|
||||||
|
minSize: 1,
|
||||||
|
upscale: 1,
|
||||||
|
url:
|
||||||
|
metaDataEntry.thumb + "?X-Plex-Token=" + server.accessToken,
|
||||||
|
"X-Plex-Token": server.accessToken,
|
||||||
|
}),
|
||||||
|
title: metaDataEntry.title,
|
||||||
|
type: metaDataEntry.type,
|
||||||
|
updatedAt: metaDataEntry.updatedAt,
|
||||||
|
year: metaDataEntry.year,
|
||||||
|
};
|
||||||
|
if (metaDataEntry.type === "playlist") {
|
||||||
|
metaEntry = {
|
||||||
|
addedAt: metaDataEntry.addedAt,
|
||||||
|
thumb:
|
||||||
|
server.preferredConnection.uri +
|
||||||
|
"/photo/:/transcode?" +
|
||||||
|
qs.stringify({
|
||||||
|
width: 240,
|
||||||
|
height: 240,
|
||||||
|
minSize: 1,
|
||||||
|
upscale: 1,
|
||||||
|
url:
|
||||||
|
metaDataEntry.composite +
|
||||||
|
"?X-Plex-Token=" +
|
||||||
|
server.accessToken,
|
||||||
|
"X-Plex-Token": server.accessToken,
|
||||||
|
}),
|
||||||
|
duration: metaDataEntry.duration,
|
||||||
|
guid: metaDataEntry.guid,
|
||||||
|
icon: metaDataEntry.icon,
|
||||||
|
key: metaDataEntry.key,
|
||||||
|
lastViewedAt: metaDataEntry.lastViewedAt,
|
||||||
|
leafCount: metaDataEntry.leafCount,
|
||||||
|
playlistType: metaDataEntry.playlistType,
|
||||||
|
ratingKey: metaDataEntry.ratingKey,
|
||||||
|
smart: metaDataEntry.smart,
|
||||||
|
title: metaDataEntry.title,
|
||||||
|
titleSort: metaDataEntry.titleSort,
|
||||||
|
type: metaDataEntry.type,
|
||||||
|
updatedAt: metaDataEntry.updatedAt,
|
||||||
|
viewCount: metaDataEntry.viewCount,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (metaDataEntry.type !== "station") {
|
||||||
|
hubMetaData.push(metaEntry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
hubs.push({
|
||||||
|
Metadata: hubMetaData,
|
||||||
|
context: hub.context,
|
||||||
|
hubIdentifier: hub.hubIdentifier,
|
||||||
|
hubKey: hub.hubKey,
|
||||||
|
key: hub.key,
|
||||||
|
more: hub.more,
|
||||||
|
promoted: hub.promoted || null,
|
||||||
|
size: hub.size,
|
||||||
|
style: hub.style,
|
||||||
|
title: hub.title,
|
||||||
|
type: hub.type,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return hubs;
|
||||||
|
}
|
||||||
|
|||||||
@@ -18,4 +18,5 @@ export {
|
|||||||
GetLibraryPages,
|
GetLibraryPages,
|
||||||
LoadPlexSession,
|
LoadPlexSession,
|
||||||
SavePlexSession,
|
SavePlexSession,
|
||||||
|
GetMusicHub,
|
||||||
} from "./PlexAPIOAuth/PlexAPIOAuth.js";
|
} from "./PlexAPIOAuth/PlexAPIOAuth.js";
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { strict as assert } from "assert";
|
import { strict as assert } from "assert";
|
||||||
import {
|
import {
|
||||||
CreatePlexClientInformation,
|
CreatePlexClientInformation,
|
||||||
GeneratePlexClientInformation,
|
|
||||||
PlexLogin,
|
PlexLogin,
|
||||||
GetPlexUserData,
|
GetPlexUserData,
|
||||||
} from "../src/index.js";
|
} from "../src/index.js";
|
||||||
|
|||||||
Reference in New Issue
Block a user