File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -107,16 +107,18 @@ interface WatchlistResponse {
107107 } ;
108108}
109109
110+ type PlexMetadataItem = {
111+ ratingKey : string ;
112+ type : 'movie' | 'show' ;
113+ title : string ;
114+ Guid ?: {
115+ id : `imdb://tt${number } ` | `tmdb://${number } ` | `tvdb://${number } `;
116+ } [ ] ;
117+ } ;
110118interface MetadataResponse {
111119 MediaContainer : {
112- Metadata : {
113- ratingKey : string ;
114- type : 'movie' | 'show' ;
115- title : string ;
116- Guid ?: {
117- id : `imdb://tt${number } ` | `tmdb://${number } ` | `tvdb://${number } `;
118- } [ ] ;
119- } [ ] ;
120+ Metadata ?: PlexMetadataItem [ ] ;
121+ Video ?: PlexMetadataItem [ ] ;
120122 } ;
121123}
122124
@@ -332,7 +334,17 @@ class PlexTvAPI extends ExternalAPI {
332334 }
333335 }
334336
335- const metadata = detailedResponse . MediaContainer . Metadata [ 0 ] ;
337+ const metadata =
338+ detailedResponse . MediaContainer . Metadata ?. [ 0 ] ??
339+ detailedResponse . MediaContainer . Video ?. [ 0 ] ;
340+
341+ if ( ! metadata ) {
342+ logger . warn (
343+ `Item with ratingKey ${ watchlistItem . ratingKey } returned no metadata, skipping.` ,
344+ { label : 'Plex.TV Metadata API' }
345+ ) ;
346+ return null ;
347+ }
336348
337349 const tmdbString = metadata . Guid ?. find ( ( guid ) =>
338350 guid . id . startsWith ( 'tmdb' )
You can’t perform that action at this time.
0 commit comments