Skip to content

Commit

Permalink
Adjust Jellyseerr structure
Browse files Browse the repository at this point in the history
  • Loading branch information
Schaka committed Jan 14, 2024
1 parent a7cdfe2 commit 7c196cc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class JellyseerrService(
fun cleanupRequests(items: List<LibraryItem>) {
val allRequests = getAllRequests()
for (item: LibraryItem in items) {
var requests: List<RequestResponse> =
var requests: List<RequestResponse> =
// TV show
if (item.season != null) {
allRequests.filter { req -> mediaMatches(item, req) && req.seasons?.any { it.seasonNumber == item.season } ?: false }
Expand Down Expand Up @@ -52,12 +52,12 @@ class JellyseerrService(

private fun mediaTypeMatches(item: LibraryItem, candidate: RequestResponse): Boolean {
// Found TV show, both request and potential media have seasons
if (item.season != null && candidate.seasons?.isNotEmpty() == true) {
if (item.season != null && (candidate.type == "tv" || candidate.seasons?.isNotEmpty() == true)) {
return true
}

// No seasons? Found a movie
if (item.season == null && candidate.seasons.isNullOrEmpty()) {
if (item.season == null && (candidate.type == "movie" || candidate.seasons.isNullOrEmpty())) {
return true
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ data class RequestResponse(
val is4k: Boolean,
val media: Media,
val modifiedBy: ModifiedBy?,
val profileId: Int,
val profileId: Int?,
val requestedBy: ModifiedBy,
val rootFolder: String,
val serverId: Int,
val rootFolder: String?,
val serverId: Int?,
val status: Int,
val updatedAt: String,
val seasons: List<RequestSeason>?
val seasons: List<RequestSeason>?,
val type: String?
)

0 comments on commit 7c196cc

Please sign in to comment.