You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/main/kotlin/com/github/schaka/janitorr/jellystat/JellystatRestService.kt
+7-5
Original file line number
Diff line number
Diff line change
@@ -33,11 +33,13 @@ class JellystatRestService(
33
33
// TODO: if at all possible, we shouldn't populate the list with media server ids differently, but recognize a season and treat show as a whole as per application properties
34
34
// example: grab show id for season id, get watchHistory based on show instead of season
35
35
36
-
for (item in items.filter { it.mediaServerId !=null }) {
36
+
for (item in items.filter { it.mediaServerIds.isNotEmpty() }) {
37
37
// every movie, show, season and episode has its own unique ID, so every request will only consider what's passed to it here
38
-
val watchHistory = jellystatClient.getRequests(ItemRequest(item.mediaServerId!!))
39
-
.filter { it.PlaybackDuration>60 }
40
-
.maxByOrNull { toDate(it.ActivityDateInserted) } // most recent date
38
+
val watchHistory = item.mediaServerIds
39
+
.map(::ItemRequest)
40
+
.flatMap(jellystatClient::getRequests)
41
+
.filter { it.PlaybackDuration>60 }
42
+
.maxByOrNull { toDate(it.ActivityDateInserted) } // most recent date
41
43
42
44
// only count view if at least one minute of content was watched - could be user adjustable later
43
45
if (watchHistory !=null) {
@@ -48,7 +50,7 @@ class JellystatRestService(
48
50
}
49
51
50
52
if (log.isTraceEnabled) {
51
-
for (item in items.filter { it.mediaServerId ==null }) {
53
+
for (item in items.filter { it.mediaServerIds.isEmpty() }) {
52
54
log.trace("Could not find any matching media server id for ${item.filePath} IMDB: ${item.imdbId} TMDB: ${item.tmdbId} TVDB: ${item.tvdbId} Season: ${item.season}")
0 commit comments