Skip to content

Commit

Permalink
fix(api): filter out libraries that do not have any metadata agent or…
Browse files Browse the repository at this point in the history
… are not movie/show
  • Loading branch information
sct committed Dec 15, 2020
1 parent e08fa35 commit 01c179f
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions server/routes/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,22 @@ settingsRoutes.get('/plex/library', async (req, res) => {

const libraries = await plexapi.getLibraries();

const newLibraries: Library[] = libraries.map((library) => {
const existing = settings.plex.libraries.find(
(l) => l.id === library.key
);

return {
id: library.key,
name: library.title,
enabled: existing?.enabled ?? false,
};
});
const newLibraries: Library[] = libraries
// Remove libraries that are not movie or show
.filter((library) => library.type === 'movie' || library.type === 'show')
// Remove libraries that do not have a metadata agent set (usually personal video libraries)
.filter((library) => library.agent !== 'com.plexapp.agents.none')
.map((library) => {
const existing = settings.plex.libraries.find(
(l) => l.id === library.key
);

return {
id: library.key,
name: library.title,
enabled: existing?.enabled ?? false,
};
});

settings.plex.libraries = newLibraries;
}
Expand Down

0 comments on commit 01c179f

Please sign in to comment.