Swift SDK Jellyfin

用于与 Jellyfin 服务器交互的 Swift SDK。

使用 CreateAPI 生成

文档

文档可在 Swift Package Index 上找到。

用法

JellyfinClient 使用底层的 Get APIClient 来提供与 Jellyfin 服务器交互的基本功能

// Create client instance
let jellyfinClient = JellyfinClient(configuration: configuration)

// Sign in user with credentials
let response = jellyfinClient.signIn(username: "jelly", password: "fin")

或者,您可以使用您自己的网络堆栈与生成的 EntitiesPaths

快速连接

已提供 QuickConnect 对象来执行快速连接授权流程。

/// Create a QuickConnect object with a JellyfinClient
let quickConnect = QuickConnect(client: client)

let quickConnectState = Task {
	/// Listen to QuickConnect states with async/await or Combine
	for await state in quickConnect.$state.values {
		switch state {
		/// Other cases ommitted
		case let .polling(code: code):
			print(code)
		case let .authenticated(secret: secret):
			/// Sign in with the Quick Connect secret
			client.signIn(quickConnectSecret: secret)
		}
	}
}

/// Start the Quick Connect authorization flow
quickConnect.start()

生成

# Download latest spec and run CreateAPI
$ make update

或者,您可以使用 CreateAPI 或任何其他 OpenAPI 生成器来生成您自己的 Swift Jellyfin SDK。