All Projects → jellyfin → jellyfin-sdk-kotlin

jellyfin / jellyfin-sdk-kotlin

Licence: LGPL-3.0 license
Kotlin SDK for Jellyfin, supporting Android and JVM Targets

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to jellyfin-sdk-kotlin

Lastik
Kotlin Multiplatform + Jetpack Compose pet project, based on www.last.fm/api (in development)
Stars: ✭ 37 (-13.95%)
Mutual labels:  jvm, ktor
SevenFacette
7Facette is an open-source multiplatform test automation library supporting JVM and JS.
Stars: ✭ 28 (-34.88%)
Mutual labels:  jvm
jvm-dump-proxy
A proxy DLL for Windows to dump JVM classes at JNI level
Stars: ✭ 53 (+23.26%)
Mutual labels:  jvm
ToDometer Multiplatform
WIP Kotlin Multiplatform project: A meter to-do list built with Android Jetpack, Compose UI Multiplatform, Wear Compose, SQLDelight, Koin Multiplatform, SwiftUI, Ktor Server / Client, Exposed...
Stars: ✭ 145 (+237.21%)
Mutual labels:  ktor
turtle
Run shell commands from a Kotlin script or application with ease
Stars: ✭ 128 (+197.67%)
Mutual labels:  jvm
rxjava2-http
Transmit RxJava2 Flowable over http with non-blocking backpressure
Stars: ✭ 19 (-55.81%)
Mutual labels:  jvm
firecracker
Stop half-done API specifications! Cherrybomb is a CLI tool that helps you avoid undefined user behaviour by validating your API specifications.
Stars: ✭ 438 (+918.6%)
Mutual labels:  openapi3
arquillian-graphene
Robust Functional Tests leveraging WebDriver with flavour of neat AJAX-ready API
Stars: ✭ 91 (+111.63%)
Mutual labels:  jvm
JVMByPython
《自己动手写Java虚拟机》JVM的python实现
Stars: ✭ 110 (+155.81%)
Mutual labels:  jvm
kdl4j
KDL Parser for the JVM
Stars: ✭ 16 (-62.79%)
Mutual labels:  jvm
local-data-api
Data API for local, you can write unittest for AWS Aurora Serverless's Data API
Stars: ✭ 99 (+130.23%)
Mutual labels:  ktor
gctoolkit
Tool for parsing GC logs
Stars: ✭ 1,127 (+2520.93%)
Mutual labels:  jvm
KaiZen-OpenApi-Parser
High-performance Parser, Validator, and Java Object Model for OpenAPI 3.x
Stars: ✭ 119 (+176.74%)
Mutual labels:  openapi3
2p-kt
A Kotlin Multi-Platform ecosystem for symbolic AI
Stars: ✭ 52 (+20.93%)
Mutual labels:  jvm
multi-projects-architecture-with-Ktor
A Ktor real world example built on multi-projects architecture
Stars: ✭ 29 (-32.56%)
Mutual labels:  ktor
kotlin-simple-architecture
Kotlin Simple Architecture
Stars: ✭ 35 (-18.6%)
Mutual labels:  ktor
play-scala-streaming-example
Example Play application showing Comet and Server Sent Events in Scala
Stars: ✭ 42 (-2.33%)
Mutual labels:  jvm
review-notes
团队分享学习、复盘笔记资料共享。Java、Scala、Flink...
Stars: ✭ 27 (-37.21%)
Mutual labels:  jvm
docker-amtd
AMTD is a Radarr companion script to automatically download movie trailers and extras for use in other video applications (plex/kodi/jellyfin/emby)
Stars: ✭ 78 (+81.4%)
Mutual labels:  jellyfin
linux.gpio.clj
Use the standard Linux GPIO API from Clojure JVM
Stars: ✭ 24 (-44.19%)
Mutual labels:  jvm

Jellyfin Kotlin SDK

Part of the Jellyfin Project


Logo Banner

LGPL 3.0 license Current Release Maven Central Release
Donate Chat on Matrix Join our Subreddit Release RSS Feed Master Commits RSS Feed


The Jellyfin Kotlin SDK is a library implementing the Jellyfin API to easily access servers. It is currently available for the JVM and Android 4.4 and up. Java 8 or higher is required. Android versions below Android 8 should use library desugaring.

Setup

Releases are published to mavenCentral(). Make sure to use the correct library depending on your platform.

Latest version on Maven Central

Gradle with Kotlin DSL

implementation("org.jellyfin.sdk:jellyfin-core:$sdkVersion")
Gradle with Groovy
implementation "org.jellyfin.sdk:jellyfin-core:$sdkVersion"
Maven
<dependency>
    <groupId>org.jellyfin.sdk</groupId>
    <artifactId>jellyfin-core</artifactId>
    <version>$sdkVersion</version>
</dependency>
Using SNAPSHOT versions

When working on new features in your application you might need a build of the SDK targeting the next server version. For this use case we publish two SNAPSHOT releases: master-SNAPSHOT and openapi-unstable-SNAPSHOT. To use the snapshot versions, add the snapshot repository to your build script: https://s01.oss.sonatype.org/content/repositories/snapshots/

An example using Gradle with Kotlin DSL that only allows the master-SNAPSHOT version:

repositories {
    maven("https://s01.oss.sonatype.org/content/repositories/snapshots/") {
        content {
            // Only allow SDK snapshots
            includeVersionByRegex("org\\.jellyfin\\.sdk", ".*", "master-SNAPSHOT")
        }
    }
}

Usage

Creating a Jellyfin instance

Most functionality of the SDK requires an instance of the Jellyfin class. This class holds the configuration required to make API calls and platform specific options. The Jellyfin class can be instantiated using a custom Kotlin DSL:

val jellyfin = createJellyfin {
    clientInfo = ClientInfo(name = "My awesome client!", version = "1.33.7",)

    // Uncomment when using android:
    // context = /* Android Context */
}

Make sure to supply the client information if you want to make API calls. The context is required for Android applications.

Creating an API instance

API calls require an API instance. This can be done with the createApi function. It requires a server address. The client and device information are set automatically but can be changed. All properties can be changed later in the API instance.

val api = jellyfin.createApi(
    baseUrl = "https://demo.jellyfin.org/stable/",
    // Optional options:
    // accessToken = "access token or api key"
    // clientInfo = ClientInfo(), // defaults to parent info
    // deviceInfo = DeviceInfo(), // defaults to parent info
    // httpClientOptions = HttpClientOptions() // allows setting additional options
)

Authenticating a user

All API operations are grouped. To make use of an operation you need to first get the group from your ApiClient instance. All groups are defined as extension functions, and you can alternatively construct the API instances manually.

val userApi = api.userApi

try {
    val authenticationResult by userApi.authenticateUserByName(
        username = "demo", 
        password = "",
    )
    
    // Use access token in api instance
    api.accessToken = authenticationResult.accessToken
    
    // Print session information
    println(authenticationResult.sessionInfo)
} catch(err: ApiClientException) {
    // Catch exceptions
    println("Something went wrong! ${err.message}")
}

WebSockets

Jellyfin uses WebSockets to communicate events like library changes and activities. This API can be used with the SocketApi. Documentation is available in the docs folder.

val instance = api.ws()

instance.addGlobalListener { message ->
	println(message)
}

Server discovery

The server discovery feature can be used to find servers on the local network, normalize inputted server addresses and to determine the best server to use from a list of addresses.

// Discover servers on the local network
jellyfin.discovery.discoverLocalServers().collect {
    println("Server ${it.name} was found at address ${it.address}")
}

// Get all candidates for a given input
val candidates = jellyfin.discovery.getAddressCandidates("demo.jellyfin.org/stable")

// Get a flow of potential servers to connect to
val recommended = jellyfin.discovery.getRecommendedServers(candidates, RecommendedServerInfoScore.GOOD)

More examples

We provide a few small projects in the samples folder. The samples are used for testing new features and can be used as a basis for your own application.

Projects using the SDK

Official Jellyfin clients

Third party clients

  • Findroid provides a native user interface to browse and play movies and series.

Want to add your project? We'd love to know about it, open an issue or create pull request!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].