Last active
September 16, 2022 16:29
-
-
Save thornbill/ae9a04af0b935ca438a9fc8702293b52 to your computer and use it in GitHub Desktop.
List all items and paths from a Jellyfin server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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