Added library mixin to YTMusic and Jellyfin

This commit is contained in:
Eclypsed
2024-06-04 22:37:19 -04:00
parent 292dc1425e
commit cb4cc1d949
24 changed files with 1017 additions and 1109 deletions

View File

@@ -16,7 +16,7 @@ export const GET: RequestHandler = async ({ params, url }) => {
const limit = Number.isInteger(numberLimit) && numberLimit > 0 ? numberLimit : undefined
const response = await connection
.getPlaylistItems(playlistId!, startIndex, limit)
.getPlaylistItems(playlistId!, { startIndex, limit })
.then((items) => Response.json({ items }))
.catch((error: TypeError | Error) => {
if (error instanceof TypeError) return new Response('Bad Request', { status: 400 })

View File

@@ -0,0 +1,13 @@
import type { RequestHandler } from '@sveltejs/kit'
import { Connections } from '$lib/server/connections'
export const GET: RequestHandler = async ({ params }) => {
const userId = params.userId!
const userConnections = Connections.getUserConnections(userId)
if (!userConnections) return new Response('Invalid user id', { status: 400 })
const items = (await Promise.all(userConnections.map((connection) => connection.library.albums()))).flat()
return Response.json({ items })
}

View File

@@ -0,0 +1,13 @@
import type { RequestHandler } from '@sveltejs/kit'
import { Connections } from '$lib/server/connections'
export const GET: RequestHandler = async ({ params }) => {
const userId = params.userId!
const userConnections = Connections.getUserConnections(userId)
if (!userConnections) return new Response('Invalid user id', { status: 400 })
const items = (await Promise.all(userConnections.map((connection) => connection.library.artists()))).flat()
return Response.json({ items })
}

View File

@@ -0,0 +1,13 @@
import type { RequestHandler } from '@sveltejs/kit'
import { Connections } from '$lib/server/connections'
export const GET: RequestHandler = async ({ params }) => {
const userId = params.userId!
const userConnections = Connections.getUserConnections(userId)
if (!userConnections) return new Response('Invalid user id', { status: 400 })
const items = (await Promise.all(userConnections.map((connection) => connection.library.playlists()))).flat()
return Response.json({ items })
}