mirror of
https://github.com/fallenbagel/jellyseerr.git
synced 2025-12-23 18:29:19 -05:00
fix(api): catch error when watchlist item doesn't exist anymore
This commit is contained in:
@@ -312,12 +312,25 @@ class PlexTvAPI extends ExternalAPI {
|
||||
const watchlistDetails = await Promise.all(
|
||||
(cachedWatchlist?.response.MediaContainer.Metadata ?? []).map(
|
||||
async (watchlistItem) => {
|
||||
const detailedResponse = await this.getRolling<MetadataResponse>(
|
||||
`/library/metadata/${watchlistItem.ratingKey}`,
|
||||
{
|
||||
baseURL: 'https://discover.provider.plex.tv',
|
||||
let detailedResponse: MetadataResponse;
|
||||
try {
|
||||
detailedResponse = await this.getRolling<MetadataResponse>(
|
||||
`/library/metadata/${watchlistItem.ratingKey}`,
|
||||
{
|
||||
baseURL: 'https://discover.provider.plex.tv',
|
||||
}
|
||||
);
|
||||
} catch (e) {
|
||||
if (e.response?.status === 404) {
|
||||
logger.warn(
|
||||
`Item with ratingKey ${watchlistItem.ratingKey} not found, it may have been removed from the server.`,
|
||||
{ label: 'Plex.TV Metadata API' }
|
||||
);
|
||||
return null;
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
const metadata = detailedResponse.MediaContainer.Metadata[0];
|
||||
|
||||
@@ -343,7 +356,9 @@ class PlexTvAPI extends ExternalAPI {
|
||||
)
|
||||
);
|
||||
|
||||
const filteredList = watchlistDetails.filter((detail) => detail.tmdbId);
|
||||
const filteredList = watchlistDetails.filter(
|
||||
(detail) => detail?.tmdbId
|
||||
) as PlexWatchlistItem[];
|
||||
|
||||
return {
|
||||
offset,
|
||||
|
||||
Reference in New Issue
Block a user