From 4c7d6317c897502e66e107aac621f7528570b847 Mon Sep 17 00:00:00 2001 From: Barnabas Balogh Date: Thu, 5 Feb 2026 20:14:24 +0100 Subject: [PATCH] refactor: code cleanup --- .../bbara/purefin/client/JellyfinApiClient.kt | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/app/src/main/java/hu/bbara/purefin/client/JellyfinApiClient.kt b/app/src/main/java/hu/bbara/purefin/client/JellyfinApiClient.kt index ee71a02..7129281 100644 --- a/app/src/main/java/hu/bbara/purefin/client/JellyfinApiClient.kt +++ b/app/src/main/java/hu/bbara/purefin/client/JellyfinApiClient.kt @@ -224,6 +224,26 @@ class JellyfinApiClient @Inject constructor( return result.content.items } + suspend fun getNextEpisodes(episodeId: UUID, count: Int = 10): List { + if (!ensureConfigured()) { + return emptyList() + } + // TODO pass complete Episode object not only an id + val episodeInfo = getItemInfo(episodeId) ?: return emptyList() + val seriesId = episodeInfo.seriesId ?: return emptyList() + val nextUpEpisodesResult = api.tvShowsApi.getEpisodes( + userId = getUserId(), + seriesId = seriesId, + enableUserData = true, + startItemId = episodeId, + limit = count + 1 + ) + //Remove first element as we need only the next episodes + val nextUpEpisodes = nextUpEpisodesResult.content.items.drop(1) + Log.d("getNextEpisodes", nextUpEpisodes.toString()) + return nextUpEpisodes + } + suspend fun getMediaSources(mediaId: UUID): List { val result = api.mediaInfoApi .getPostedPlaybackInfo( @@ -253,26 +273,6 @@ class JellyfinApiClient @Inject constructor( return result.content.mediaSources } - suspend fun getNextEpisodes(episodeId: UUID, count: Int = 10): List { - if (!ensureConfigured()) { - return emptyList() - } - // TODO pass complete Episode object not only an id - val episodeInfo = getItemInfo(episodeId) ?: return emptyList() - val seriesId = episodeInfo.seriesId ?: return emptyList() - val nextUpEpisodesResult = api.tvShowsApi.getEpisodes( - userId = getUserId(), - seriesId = seriesId, - enableUserData = true, - startItemId = episodeId, - limit = count + 1 - ) - //Remove first element as we need only the next episodes - val nextUpEpisodes = nextUpEpisodesResult.content.items.drop(1) - Log.d("getNextEpisodes", nextUpEpisodes.toString()) - return nextUpEpisodes - } - suspend fun getMediaPlaybackUrl(mediaId: UUID, mediaSourceId: String? = null): String? { if (!ensureConfigured()) { return null