File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -312,12 +312,25 @@ class PlexTvAPI extends ExternalAPI {
312312 const watchlistDetails = await Promise . all (
313313 ( cachedWatchlist ?. response . MediaContainer . Metadata ?? [ ] ) . map (
314314 async ( watchlistItem ) => {
315- const detailedResponse = await this . getRolling < MetadataResponse > (
316- `/library/metadata/${ watchlistItem . ratingKey } ` ,
317- {
318- baseURL : 'https://discover.provider.plex.tv' ,
315+ let detailedResponse : MetadataResponse ;
316+ try {
317+ detailedResponse = await this . getRolling < MetadataResponse > (
318+ `/library/metadata/${ watchlistItem . ratingKey } ` ,
319+ {
320+ baseURL : 'https://discover.provider.plex.tv' ,
321+ }
322+ ) ;
323+ } catch ( e ) {
324+ if ( e . response ?. status === 404 ) {
325+ logger . warn (
326+ `Item with ratingKey ${ watchlistItem . ratingKey } not found, it may have been removed from the server.` ,
327+ { label : 'Plex.TV Metadata API' }
328+ ) ;
329+ return null ;
330+ } else {
331+ throw e ;
319332 }
320- ) ;
333+ }
321334
322335 const metadata = detailedResponse . MediaContainer . Metadata [ 0 ] ;
323336
@@ -343,7 +356,9 @@ class PlexTvAPI extends ExternalAPI {
343356 )
344357 ) ;
345358
346- const filteredList = watchlistDetails . filter ( ( detail ) => detail . tmdbId ) ;
359+ const filteredList = watchlistDetails . filter (
360+ ( detail ) => detail ?. tmdbId
361+ ) as PlexWatchlistItem [ ] ;
347362
348363 return {
349364 offset,
You can’t perform that action at this time.
0 commit comments