fix(backend): update jellyfin.ts for 10.8.0

This commit is contained in:
Aiden Vigue
2021-06-14 12:27:07 -04:00
parent 508fccae4e
commit e5c6b9cd74
2 changed files with 7 additions and 3 deletions

View File

@@ -151,7 +151,9 @@ class JellyfinAPI {
public async getLibraries(): Promise<JellyfinLibrary[]> { public async getLibraries(): Promise<JellyfinLibrary[]> {
try { try {
const account = await this.axios.get<any>('/Library/MediaFolders'); const account = await this.axios.get<any>(
`/Users/${this.userId ?? 'Me'}/Views`
);
const response: JellyfinLibrary[] = account.data.Items.filter( const response: JellyfinLibrary[] = account.data.Items.filter(
(Item: any) => { (Item: any) => {
@@ -176,7 +178,7 @@ class JellyfinAPI {
`Something went wrong while getting libraries from the Jellyfin server: ${e.message}`, `Something went wrong while getting libraries from the Jellyfin server: ${e.message}`,
{ label: 'Jellyfin API' } { label: 'Jellyfin API' }
); );
throw new Error('Invalid auth token'); return [];
} }
} }

View File

@@ -246,7 +246,7 @@ settingsRoutes.get('/jellyfin/library', async (req, res) => {
if (req.query.sync) { if (req.query.sync) {
const userRepository = getRepository(User); const userRepository = getRepository(User);
const admin = await userRepository.findOneOrFail({ const admin = await userRepository.findOneOrFail({
select: ['id', 'jellyfinAuthToken', 'jellyfinDeviceId'], select: ['id', 'jellyfinAuthToken', 'jellyfinDeviceId', 'jellyfinUserId'],
order: { id: 'ASC' }, order: { id: 'ASC' },
}); });
const jellyfinClient = new JellyfinAPI( const jellyfinClient = new JellyfinAPI(
@@ -255,6 +255,8 @@ settingsRoutes.get('/jellyfin/library', async (req, res) => {
admin.jellyfinDeviceId ?? '' admin.jellyfinDeviceId ?? ''
); );
jellyfinClient.setUserId(admin.jellyfinUserId ?? '');
const libraries = await jellyfinClient.getLibraries(); const libraries = await jellyfinClient.getLibraries();
const newLibraries: Library[] = libraries.map((library) => { const newLibraries: Library[] = libraries.map((library) => {