Skip to content

Instantly share code, notes, and snippets.

@thornbill
Last active September 16, 2022 16:29
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 thornbill/ae9a04af0b935ca438a9fc8702293b52 to your computer and use it in GitHub Desktop.
Save thornbill/ae9a04af0b935ca438a9fc8702293b52 to your computer and use it in GitHub Desktop.
List all items and paths from a Jellyfin server
import { Jellyfin } from '@jellyfin/sdk';
import { getItemsApi } from '@jellyfin/sdk/lib/utils/api/items-api.js';
import { ItemFields } from '@jellyfin/sdk/lib/generated-client/models/item-fields.js';
const jellyfin = new Jellyfin({
clientInfo: {
name: 'Jellyfin Listing',
version: '1.0.0'
},
deviceInfo: {
name: 'PC',
id: 'cd66bfae-97ba-4f0b-a072-8bce63015811' // Randomly generated guid v4
}
});
(async () => {
const api = jellyfin.createApi('SERVER_ADDRESS');
const auth = await api.authenticateUserByName('USERNAME', 'PASSWORD');
const user = auth.data.User;
const items = await getItemsApi(api).getItemsByUserId({
userId: user.Id,
fields: [ ItemFields.Path ],
recursive: true
});
items.data.Items.forEach(item => {
console.log(`${item.Id}\t${item.Name}\t${item.Path}`);
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment