|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
import NodePlexAPI from 'plex-api';
|
|
|
|
|
import { getSettings, Library, PlexSettings } from '../lib/settings';
|
|
|
|
|
import logger from '../logger';
|
|
|
|
|
|
|
|
|
|
export interface PlexLibraryItem {
|
|
|
|
|
ratingKey: string;
|
|
|
|
@ -145,11 +146,14 @@ class PlexAPI {
|
|
|
|
|
public async syncLibraries(): Promise<void> {
|
|
|
|
|
const settings = getSettings();
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
const libraries = await this.getLibraries();
|
|
|
|
|
|
|
|
|
|
const newLibraries: Library[] = libraries
|
|
|
|
|
// Remove libraries that are not movie or show
|
|
|
|
|
.filter((library) => library.type === 'movie' || library.type === '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) => {
|
|
|
|
@ -167,6 +171,15 @@ class PlexAPI {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
settings.plex.libraries = newLibraries;
|
|
|
|
|
} catch (e) {
|
|
|
|
|
logger.error('Failed to fetch Plex libraries', {
|
|
|
|
|
label: 'Plex API',
|
|
|
|
|
message: e.message,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
settings.plex.libraries = [];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
settings.save();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|