File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -206,6 +206,19 @@ class Media {
206206 Object . assign ( this , init ) ;
207207 }
208208
209+ public resetServiceData ( ) : void {
210+ this . serviceId = null ;
211+ this . serviceId4k = null ;
212+ this . externalServiceId = null ;
213+ this . externalServiceId4k = null ;
214+ this . externalServiceSlug = null ;
215+ this . externalServiceSlug4k = null ;
216+ this . ratingKey = null ;
217+ this . ratingKey4k = null ;
218+ this . jellyfinMediaId = null ;
219+ this . jellyfinMediaId4k = null ;
220+ }
221+
209222 @AfterLoad ( )
210223 public setPlexUrls ( ) : void {
211224 const { machineId, webAppUrl } = getSettings ( ) . plex ;
Original file line number Diff line number Diff line change @@ -70,13 +70,33 @@ class WatchlistSync {
7070 response . items . map ( ( i ) => i . tmdbId )
7171 ) ;
7272
73+ const watchlistTmdbIds = response . items . map ( ( i ) => i . tmdbId ) ;
74+
75+ const requestRepository = getRepository ( MediaRequest ) ;
76+ const existingAutoRequests = await requestRepository
77+ . createQueryBuilder ( 'request' )
78+ . leftJoinAndSelect ( 'request.media' , 'media' )
79+ . where ( 'request.requestedBy = :userId' , { userId : user . id } )
80+ . andWhere ( 'request.isAutoRequest = true' )
81+ . andWhere ( 'media.tmdbId IN (:...tmdbIds)' , { tmdbIds : watchlistTmdbIds } )
82+ . getMany ( ) ;
83+
84+ const autoRequestedTmdbIds = new Set (
85+ existingAutoRequests
86+ . filter ( ( r ) => r . media != null )
87+ . map ( ( r ) => `${ r . media . mediaType } :${ r . media . tmdbId } ` )
88+ ) ;
89+
7390 const unavailableItems = response . items . filter (
74- // If we can find watchlist items in our database that are also available, we should exclude them
7591 ( i ) =>
92+ ! autoRequestedTmdbIds . has (
93+ `${ i . type === 'show' ? MediaType . TV : MediaType . MOVIE } :${ i . tmdbId } `
94+ ) &&
7695 ! mediaItems . find (
7796 ( m ) =>
7897 m . tmdbId === i . tmdbId &&
79- ( ( m . status !== MediaStatus . UNKNOWN && m . mediaType === 'movie' ) ||
98+ ( m . status === MediaStatus . BLOCKLISTED ||
99+ ( m . status !== MediaStatus . UNKNOWN && m . mediaType === 'movie' ) ||
80100 ( m . mediaType === 'tv' && m . status === MediaStatus . AVAILABLE ) )
81101 )
82102 ) ;
Original file line number Diff line number Diff line change @@ -174,7 +174,12 @@ mediaRoutes.delete(
174174 where : { id : Number ( req . params . id ) } ,
175175 } ) ;
176176
177- await mediaRepository . remove ( media ) ;
177+ if ( media . status === MediaStatus . BLOCKLISTED ) {
178+ media . resetServiceData ( ) ;
179+ await mediaRepository . save ( media ) ;
180+ } else {
181+ await mediaRepository . remove ( media ) ;
182+ }
178183
179184 return res . status ( 204 ) . send ( ) ;
180185 } catch ( e ) {
You can’t perform that action at this time.
0 commit comments