Skip to content

Instantly share code, notes, and snippets.

@henrik

henrik/README.md

Created May 7, 2021
Embed
What would you like to do?
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