Skip to content

Commit

Permalink
Merge pull request #11 from sjafferali/fix_match
Browse files Browse the repository at this point in the history
Check for mediatype before ID checks.
  • Loading branch information
Schaka authored Feb 28, 2024
2 parents 273164b + 9633d69 commit 9cfa468
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ class JellyseerrRestService(
}

private fun mediaMatches(item: LibraryItem, candidate: RequestResponse): Boolean {
// Check if the media type is the same before checking anything else
if (!mediaTypeMatches(item, candidate)) {
return false
}

// Match between Radarr ID or Sonarr ID and the ID Jellyseerr stores for Radarr/Sonarr
// TODO: Maybe grab the Jellyfin ID here to make deletion in Jellyfin easier down the line?
Expand All @@ -55,8 +59,8 @@ class JellyseerrRestService(

// Fallback, match by meta data
val imdbMatches = candidate.media.imdbId != null && (candidate.media.imdbId == item.imdbId)
val tmdbMatches = candidate.media.tmdbId != null && mediaTypeMatches(item, candidate) && (candidate.media.tmdbId == item.tmdbId)
val tvdbMatches = candidate.media.tvdbId != null && mediaTypeMatches(item, candidate) && (candidate.media.tvdbId == item.tvdbId)
val tmdbMatches = candidate.media.tmdbId != null && (candidate.media.tmdbId == item.tmdbId)
val tvdbMatches = candidate.media.tvdbId != null && (candidate.media.tvdbId == item.tvdbId)
return imdbMatches || tmdbMatches || tvdbMatches
}

Expand Down Expand Up @@ -90,4 +94,4 @@ class JellyseerrRestService(
return allRequests
}

}
}

0 comments on commit 9cfa468

Please sign in to comment.