Skip to content

Instantly share code, notes, and snippets.

@henrik
Created May 7, 2021 23:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save henrik/0c9a6bbb26288b1555692925e523c671 to your computer and use it in GitHub Desktop.
Save henrik/0c9a6bbb26288b1555692925e523c671 to your computer and use it in GitHub Desktop.
Export Plex library titles via Node

I wanted to export all titles from the Plex library on my Mac and couldn't find a good tool.

This is a tiny, quick-and-dirty Node JS script, using node-plex-api.

It assumes you have node and npm installed.

Then just download this "script.js" and run:

npm install plex-api --save
node script.js your_plex_username your_plex_password > plex.txt
const PlexAPI = require("plex-api");
const client = new PlexAPI({hostname: "127.0.0.1", username: process.argv[2], password: process.argv[3]})
client.query("/library/sections").then(function (data) {
data.MediaContainer.Directory.forEach(function(section) {
client.query("/library/sections/"+section.key+"/all").then(function (data2) {
console.log("# " + section.title)
data2.MediaContainer.Metadata.forEach(function(item) {
console.log(item.title)
})
console.log("\n")
})
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment