fix: recently added albums are now correctly marked as available when using Plex as the media server
This commit is contained in:
@@ -230,12 +230,19 @@ class PlexAPI {
|
||||
options: { addedAt: number } = {
|
||||
addedAt: Date.now() - 1000 * 60 * 60,
|
||||
},
|
||||
mediaType: 'movie' | 'show' | 'artist'
|
||||
mediaType: 'movie' | 'show' | 'album'
|
||||
): Promise<PlexLibraryItem[]> {
|
||||
let typeCode = '1';
|
||||
if (mediaType === 'show') {
|
||||
typeCode = '4';
|
||||
} else if (mediaType === 'album') {
|
||||
typeCode = '9';
|
||||
}
|
||||
|
||||
const response = await this.plexClient.query<PlexLibraryResponse>({
|
||||
uri: `/library/sections/${id}/all?type=${
|
||||
mediaType === 'show' ? '4' : '1'
|
||||
}&sort=addedAt%3Adesc&addedAt>>=${Math.floor(options.addedAt / 1000)}`,
|
||||
uri: `/library/sections/${id}/all?type=${typeCode}&sort=addedAt%3Adesc&addedAt>>=${Math.floor(
|
||||
options.addedAt / 1000
|
||||
)}`,
|
||||
extraHeaders: {
|
||||
'X-Plex-Container-Start': `0`,
|
||||
'X-Plex-Container-Size': `500`,
|
||||
|
||||
@@ -586,6 +586,11 @@ class BaseScanner<T> {
|
||||
} else {
|
||||
let hasChanges = false;
|
||||
|
||||
if (existing.status !== MediaStatus.AVAILABLE && !processing) {
|
||||
existing.status = MediaStatus.AVAILABLE;
|
||||
hasChanges = true;
|
||||
}
|
||||
|
||||
if (serviceId && !existing.serviceId) {
|
||||
existing.serviceId = serviceId;
|
||||
hasChanges = true;
|
||||
|
||||
@@ -97,7 +97,7 @@ class PlexScanner
|
||||
'info',
|
||||
{ lastScan: library.lastScan }
|
||||
);
|
||||
const mappedType = library.type === 'music' ? 'artist' : library.type;
|
||||
const mappedType = library.type === 'music' ? 'album' : library.type;
|
||||
const libraryItems = await this.plexClient.getRecentlyAdded(
|
||||
library.id,
|
||||
library.lastScan
|
||||
|
||||
Reference in New Issue
Block a user