Skip to content

Commit 551501f

Browse files
Add support for server plugin (#1384)
## Description PR to add support for a Wholphin server plugin: https://github.com/damontecres/jellyfin-plugin-wholphin Note: The plugin is not required to use Wholphin. It adds features the server admin can use to set default settings like the home page or eventually Seerr connection info. ### Changes Wholphin will use the home page settings in order of: 1. Saved on the device locally 2. Saved on the server in the user's profile settings (display preferences) 3. Provided by `jellyfin-plugin-wholphin` 4. Default fallback: combined continue watching & recently added in libraries Under customize home page, you can now see the "source" of the home settings. This also allows to pick a different source Finally, instead of the home customization being saved in the background only locally, if there are any changes, a dialog is shown with options to save locally, server-side user profile, or discard. So overall, it's more clear where the home page settings are from and where the user wants to save them. ### Install [See instructions here](https://github.com/damontecres/Wholphin/releases/tag/develop-server-plugin) ### Related issues Related to #598 ### Testing WIP ## Screenshots N/A ## AI or LLM usage None --------- Co-authored-by: Mario Reisinger <marioreisinger95@gmail.com>
1 parent e273195 commit 551501f

20 files changed

Lines changed: 2331 additions & 858 deletions

File tree

‎app/schemas/com.github.damontecres.wholphin.data.AppDatabase/41.json‎

Lines changed: 841 additions & 0 deletions
Large diffs are not rendered by default.

‎app/src/main/java/com/github/damontecres/wholphin/data/AppDatabase.kt‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ import java.util.UUID
5151
RememberedTab::class,
5252
SeriesTrackChoice::class,
5353
],
54-
version = 40,
54+
version = 41,
5555
exportSchema = true,
5656
autoMigrations = [
5757
AutoMigration(3, 4),
@@ -71,6 +71,7 @@ import java.util.UUID
7171
AutoMigration(33, 34),
7272
AutoMigration(34, 35),
7373
AutoMigration(35, 40),
74+
AutoMigration(40, 41),
7475
],
7576
)
7677
@TypeConverters(Converters::class)

‎app/src/main/java/com/github/damontecres/wholphin/data/ServerRepository.kt‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ class ServerRepository
7272
}
7373
}
7474

75+
val serverPluginInstalled = MutableStateFlow<Boolean>(false)
76+
7577
/**
7678
* Adds a server to the app database and updated the [ApiClient] to the server's URL
7779
*

‎app/src/main/java/com/github/damontecres/wholphin/data/model/HomeRowConfig.kt‎

Lines changed: 87 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
@file:UseSerializers(UUIDSerializer::class)
1+
@file:UseSerializers(
2+
UUIDSerializer::class,
3+
DateTimeSerializer::class,
4+
)
25

36
package com.github.damontecres.wholphin.data.model
47

@@ -7,11 +10,15 @@ import com.github.damontecres.wholphin.ui.AspectRatio
710
import com.github.damontecres.wholphin.ui.Cards
811
import com.github.damontecres.wholphin.ui.components.ViewOptionImageType
912
import com.github.damontecres.wholphin.ui.data.SortAndDirection
13+
import kotlinx.datetime.LocalDateTime
1014
import kotlinx.serialization.SerialName
1115
import kotlinx.serialization.Serializable
1216
import kotlinx.serialization.UseSerializers
1317
import org.jellyfin.sdk.model.api.BaseItemKind
18+
import org.jellyfin.sdk.model.api.ItemSortBy
19+
import org.jellyfin.sdk.model.api.SortOrder
1420
import org.jellyfin.sdk.model.api.request.GetItemsRequest
21+
import org.jellyfin.sdk.model.serializer.DateTimeSerializer
1522
import org.jellyfin.sdk.model.serializer.UUIDSerializer
1623
import java.util.UUID
1724

@@ -174,19 +181,45 @@ sealed interface HomeRowConfig {
174181
}
175182

176183
/**
177-
* An arbitrary [GetItemsRequest] allowing to query for anything
184+
* An arbitrary [HomeGetItemsFilter] allowing to query for most anything
178185
*/
179186
@Serializable
180187
@SerialName("GetItems")
181188
data class GetItems(
182189
val name: String,
183-
val getItems: GetItemsRequest,
190+
val filter: HomeGetItemsFilter,
184191
override val viewOptions: HomeRowViewOptions = HomeRowViewOptions(),
185192
) : HomeRowConfig {
186193
override fun updateViewOptions(viewOptions: HomeRowViewOptions): GetItems = this.copy(viewOptions = viewOptions)
187194
}
195+
196+
/**
197+
* Fetch items from an arbitrary Jellyfin endpoint that returns a QueryResult<BaseItemDto>.
198+
* Lets third-party plugins (e.g. home-sections) contribute rows without Wholphin needing
199+
* specific knowledge of them.
200+
*
201+
* Headers/Query are a list of [KeyValueEntry] (not a Map) because the server-side plugin
202+
* config is persisted as XML, which doesn't support IDictionary.
203+
*/
204+
@Serializable
205+
@SerialName("CustomEndpoint")
206+
data class CustomEndpoint(
207+
val endpoint: String,
208+
val title: String,
209+
val headers: List<KeyValueEntry>? = null,
210+
val query: List<KeyValueEntry>? = null,
211+
override val viewOptions: HomeRowViewOptions = HomeRowViewOptions(),
212+
) : HomeRowConfig {
213+
override fun updateViewOptions(viewOptions: HomeRowViewOptions): CustomEndpoint = this.copy(viewOptions = viewOptions)
214+
}
188215
}
189216

217+
@Serializable
218+
data class KeyValueEntry(
219+
val key: String,
220+
val value: String,
221+
)
222+
190223
/**
191224
* Root class for home page settings
192225
*
@@ -241,3 +274,54 @@ data class HomeRowViewOptions(
241274
)
242275
}
243276
}
277+
278+
/**
279+
* Subset of [GetItemsFilter]
280+
*/
281+
@Serializable
282+
data class HomeGetItemsFilter(
283+
val sortBy: List<ItemSortBy>? = null,
284+
val sortOrder: List<SortOrder>? = null,
285+
val ids: List<UUID>? = null,
286+
val minCommunityRating: Double? = null,
287+
val minCriticRating: Double? = null,
288+
val recursive: Boolean? = null,
289+
val searchTerm: String? = null,
290+
val parentId: UUID? = null,
291+
val includeItemTypes: List<BaseItemKind>? = null,
292+
val isFavorite: Boolean? = null,
293+
val isPlayed: Boolean? = null,
294+
val officialRatings: Collection<String>? = null,
295+
val tags: List<String>? = null,
296+
val years: List<Int>? = null,
297+
val personIds: List<UUID>? = null,
298+
val minOfficialRating: String? = null,
299+
val hasOfficialRating: Boolean? = null,
300+
val studioIds: List<UUID>? = null,
301+
val genreIds: List<UUID>? = null,
302+
val minPremiereDate: LocalDateTime? = null,
303+
val maxPremiereDate: LocalDateTime? = null,
304+
) {
305+
fun asGetItemsRequest() =
306+
GetItemsRequest(
307+
sortBy = sortBy,
308+
sortOrder = sortOrder,
309+
ids = ids,
310+
minCommunityRating = minCommunityRating,
311+
minCriticRating = minCriticRating,
312+
recursive = recursive,
313+
searchTerm = searchTerm,
314+
parentId = parentId,
315+
includeItemTypes = includeItemTypes,
316+
isFavorite = isFavorite,
317+
isPlayed = isPlayed,
318+
officialRatings = officialRatings,
319+
tags = tags,
320+
years = years,
321+
personIds = personIds,
322+
minOfficialRating = minOfficialRating,
323+
hasOfficialRating = hasOfficialRating,
324+
studioIds = studioIds,
325+
genreIds = genreIds,
326+
)
327+
}

‎app/src/main/java/com/github/damontecres/wholphin/data/model/JellyfinServer.kt‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import androidx.room.Relation
1313
import com.github.damontecres.wholphin.data.ZonedDateTimeSerializer
1414
import com.github.damontecres.wholphin.preferences.SubtitleModePreference
1515
import com.github.damontecres.wholphin.preferences.UserProfileSettings
16+
import com.github.damontecres.wholphin.services.HomePageSettingsSource
1617
import com.github.damontecres.wholphin.ui.isNotNullOrBlank
1718
import kotlinx.serialization.Serializable
1819
import kotlinx.serialization.UseSerializers
@@ -68,6 +69,7 @@ data class JellyfinUser(
6869
val lastUsed: ZonedDateTime? = null,
6970
val uiLanguage: String? = null,
7071
@Embedded val appPreferences: JellyfinUserPreferences = JellyfinUserPreferences(),
72+
@Embedded(prefix = "c_") val config: JellyfinUserConfig = JellyfinUserConfig(),
7173
) {
7274
val hasPin: Boolean get() = pin.isNotNullOrBlank()
7375

@@ -77,9 +79,17 @@ data class JellyfinUser(
7779
"JellyfinUser(rowId=$rowId, id=$id, name=$name, serverId=$serverId, lastUsed=$lastUsed, " +
7880
"accessToken?=${accessToken.isNotNullOrBlank()}, pin?=${pin.isNotNullOrBlank()}), " +
7981
"requireLogin=$requireLogin, lastUsed=$lastUsed, uiLanguage=$uiLanguage, " +
80-
"appPreferences=$appPreferences"
82+
"appPreferences=$appPreferences, config=$config"
83+
84+
fun updateConfig(copy: (JellyfinUserConfig) -> JellyfinUserConfig): JellyfinUser = this.copy(config = copy.invoke(this.config))
8185
}
8286

87+
@Serializable
88+
data class JellyfinUserConfig(
89+
@ColumnInfo(defaultValue = "UNSET")
90+
val homeSettingsSource: HomePageSettingsSource = HomePageSettingsSource.UNSET,
91+
)
92+
8393
/**
8494
* Represents the relationship between [JellyfinServer] and its [JellyfinUser]
8595
*/

0 commit comments

Comments
 (0)