Security News
New Proposed CISA Mandate Would Require Critical Infrastructure to Report Ransom Payments Within 24 Hours
CISA has proposed a set of new rules that would require critical infrastructure to report cyber incidents and ransom payments.
plex-api-oauth
Advanced tools
An NPM Module designed to make Plex Media Server and plex.tv API calls easier to implement in JavaScript projects
Weekly downloads
Readme
An NPM Module designed to make Plex Media Server and plex.tv API calls easier to implement in JavaScript and React projects
https://www.npmjs.com/package/plex-api-oauth
This is a JavaScript Module written to take the OAuth Module written by @Dmbob https://github.com/Dmbob/plex-oauth and incorporate it into a front end friend frame work to make development of Plex API Based applications better
Examples Assume React Syntax
LoadPlexSession:
Function returns an object that contains the plexClientInformation and plexTVAuthToken keys/values according to how they were created
const loadedSession = LoadPlexSession();
if (loadedSession.plexClientInformation == null){
loadedSession.plexClientInformation = CreatePlexClientInformation();
}
const [plexClientInformation, setPlexClientInformation] = useState(
loadedSession.plexClientInformation
);
const [plexTVAuthToken, setPlexTVAuthToken] = useState(
loadedSession.plexTVAuthToken
);
async function PlexLoginButton() {
const tempPlexTVAuthToken = await PlexLogin(plexClientInformation);
const tempPlexTVUserData = await GetPlexUserData(
plexClientInformation,
tempPlexTVAuthToken
);
const tempPlexServers = await GetPlexServers(
plexClientInformation,
tempPlexTVAuthToken
);
const tempPlexLibraries = await GetPlexLibraries(tempPlexServers);
setPlexTVAuthToken(tempPlexTVAuthToken);
setPlexServers(tempPlexServers);
setPlexTVUserData(tempPlexTVUserData);
setPlexLibraries(tempPlexLibraries);
SavePlexSession(plexClientInformation, tempPlexTVAuthToken);
}
async function Refresh() {
const tempPlexTVUserData = await GetPlexUserData(
plexClientInformation,
plexTVAuthToken
);
const tempPlexServers = await GetPlexServers(
plexClientInformation,
plexTVAuthToken
);
const tempPlexDevices = await GetPlexDevices(
plexClientInformation,
plexTVAuthToken
);
const tempPlexLibraries = await GetPlexLibraries(tempPlexServers);
UpdateHubs(tempPlexServers, tempPlexLibraries);
setPlexServers(tempPlexServers);
setPlexDevices(tempPlexDevices);
setPlexTVUserData(tempPlexTVUserData);
setPlexLibraries(tempPlexLibraries);
setIsRefreshing(false);
}
async function UpdateLibrary() {
setIsLoading(true);
const returnObject = await GetLibraryPages(
plexServers,
plexLibraries,
topic,
pageNumber,
250
);
console.log(returnObject);
const tempItemArray = Array.from([
...new Set([...libraryItems, ...returnObject.items]),
]);
setLibraryItems(tempItemArray);
setLibraryHasMore(returnObject.hasMore);
setIsLoading(false);
}
const observer = useRef();
const lastLibraryItem = useCallback(
(node) => {
if (isLoading) return;
if (observer.current) observer.current.disconnect();
observer.current = new IntersectionObserver((entries) => {
if (entries[0].isIntersecting && libraryHasMore) {
setPageNumber(pageNumber + 1);
}
});
if (node) observer.current.observe(node);
console.log(node);
},
[isLoading, libraryHasMore]
);
if (libraryItems?.length === index + 100) {
return (
<Grid item xs="12" key={Obj.guid + index}>
<ListItem ref={lastLibraryItem}>
<ListItemAvatar>
<Avatar alt={NoArt} src={Obj.thumb} />
</ListItemAvatar>
<Typography variant="h6" noWrap>
{Obj.title} - {Obj.grandparentTitle} -{' '}
{Obj.parentTitle}
</Typography>
</ListItem>
</Grid>
);
}
const observer = useRef();
const lastLibraryItem = useCallback(
(node) => {
if (isLoading) return;
if (observer.current) observer.current.disconnect();
observer.current = new IntersectionObserver((entries) => {
if (entries[0].isIntersecting && libraryHasMore) {
setPageNumber(pageNumber + 1);
}
});
if (node) observer.current.observe(node);
console.log(node);
},
[isLoading, libraryHasMore]
);
async function UpdateHubs(plexClientInformation, plexServers, plexLibraries) {
const tempMusicHubs = await GetMusicHub(
plexClientInformation,
plexServers, // No Auth Token is needed since the server objects have their own access tokens
plexLibraries
);
setMusicHubs(tempMusicHubs);
}
Accepts: input values
Generates the Client Information to uniquely identify the Authenticated client Save between sessions for consistency
input = {product:"LukeHagar.com"}
plexClientInformation = CreatePlexClientInformation(input);
Accepts: plexClientInformation
If command is run in a browser window it will open the new login window automatically
plexTVAuthToken = PlexLogin(plexClientInformation);
Accepts: plexClientInformation, plexTVAuthToken
Queries the plex.tv api to get information on the authenticated user
plexUserData = GetPlexUserData(plexClientInformation, plexTVAuthToken);
Accepts an Object with partial client values, will populate the remaining ones left blank if needed
plexServers = GetPlexServers(plexClientInformation, plexTVAuthToken);
Accepts an Object with partial client values, will populate the remaining ones left blank if needed
input = {product:"LukeHagar.com"}
plexClientInformation = CreatePlexClientInformation(input);
Accepts an Object with partial client values, will populate the remaining ones left blank if needed
input = {product:"LukeHagar.com"}
plexClientInformation = CreatePlexClientInformation(input);
Accepts an Object with partial client values, will populate the remaining ones left blank if needed
input = {product:"LukeHagar.com"}
plexClientInformation = CreatePlexClientInformation(input);
Accepts an Object with partial client values, will populate the remaining ones left blank if needed
input = {product:"LukeHagar.com"}
plexClientInformation = CreatePlexClientInformation(input);
Accepts an Object with partial client values, will populate the remaining ones left blank if needed
input = {product:"LukeHagar.com"}
plexClientInformation = CreatePlexClientInformation(input);
Accepts an Object with partial client values, will populate the remaining ones left blank if needed
input = {product:"LukeHagar.com"}
plexClientInformation = CreatePlexClientInformation(input);
Accepts an Object with partial client values, will populate the remaining ones left blank if needed
input = {product:"LukeHagar.com"}
plexClientInformation = CreatePlexClientInformation(input);
Accepts an Object with partial client values, will populate the remaining ones left blank if needed
input = {product:"LukeHagar.com"}
plexClientInformation = CreatePlexClientInformation(input);
Accepts an Object with partial client values, will populate the remaining ones left blank if needed
input = {product:"LukeHagar.com"}
plexClientInformation = CreatePlexClientInformation(input);
Accepts an Object with partial client values, will populate the remaining ones left blank if needed
input = {product:"LukeHagar.com"}
plexClientInformation = CreatePlexClientInformation(input);
Accepts an Object with partial client values, will populate the remaining ones left blank if needed
input = {product:"LukeHagar.com"}
plexClientInformation = CreatePlexClientInformation(input);
Accepts an Object with partial client values, will populate the remaining ones left blank if needed
input = {product:"LukeHagar.com"}
plexClientInformation = CreatePlexClientInformation(input);
Accepts an Object with partial client values, will populate the remaining ones left blank if needed
input = {product:"LukeHagar.com"}
plexClientInformation = CreatePlexClientInformation(input);
Accepts an Object with partial client values, will populate the remaining ones left blank if needed
input = {product:"LukeHagar.com"}
plexClientInformation = CreatePlexClientInformation(input);
Accepts an Object with partial client values, will populate the remaining ones left blank if needed
input = {product:"LukeHagar.com"}
plexClientInformation = CreatePlexClientInformation(input);
Accepts an Object with partial client values, will populate the remaining ones left blank if needed
input = {product:"LukeHagar.com"}
plexClientInformation = CreatePlexClientInformation(input);
Accepts an Object with partial client values, will populate the remaining ones left blank if needed
input = {product:"LukeHagar.com"}
plexClientInformation = CreatePlexClientInformation(input);
FAQs
An NPM Module designed to make Plex Media Server and plex.tv API calls easier to implement in JavaScript projects
The npm package plex-api-oauth receives a total of 7 weekly downloads. As such, plex-api-oauth popularity was classified as not popular.
We found that plex-api-oauth demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISA has proposed a set of new rules that would require critical infrastructure to report cyber incidents and ransom payments.
Security News
Redis is no longer OSS, breaking its explicit commitment to remain under the BSD 3-Clause License forever. This has angered contributors who are now working to fork the software.
Product
Socket AI now enables 'AI detected potential malware' alerts by default, ensuring users benefit from AI-powered state-of-the-art malware detection without needing to opt-in.