Desktop app: shell and library screens

This commit is contained in:
2026-10-26 23:46:29 +03:00
parent 69048452b8
commit 01c1b304ef
46 changed files with 4700 additions and 5 deletions

View File

@@ -1,8 +1,23 @@
package ru.stenfredd.sleepyowl.core.jellyfin
import org.jellyfin.sdk.JellyfinOptions
import org.jellyfin.sdk.model.DeviceInfo
import java.io.File
import java.util.UUID
class DesktopJellyfinPlatform : JellyfinPlatform {
// /etc/hostname rather than InetAddress: that one may wait for DNS.
override val deviceName = "SleepyOwl · " + (runCatching { File("/etc/hostname").readText().trim() }.getOrNull()?.ifEmpty { null } ?: "Linux")
override val deviceName = "SleepyOwl · " + (readLine("/etc/hostname") ?: "Linux")
/**
* The SDK's default device: on Android it comes from the system, on the desktop it has to be given — server
* discovery and probing (`ServerLogin.find`) create their API clients with it. Signed-in clients use the
* account's saved device id instead. The id is this machine's (`/etc/machine-id`), hashed.
*/
override fun configure(options: JellyfinOptions.Builder) {
val machine = readLine("/etc/machine-id") ?: deviceName
options.deviceInfo = DeviceInfo(id = UUID.nameUUIDFromBytes(machine.toByteArray()).toString(), name = deviceName)
}
private fun readLine(path: String) = runCatching { File(path).readText().trim() }.getOrNull()?.ifEmpty { null }
}