Added library mixin to YTMusic and Jellyfin
This commit is contained in:
@@ -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 })
|
||||
|
||||
13
src/routes/api/users/[userId]/library/albums/+server.ts
Normal file
13
src/routes/api/users/[userId]/library/albums/+server.ts
Normal 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 })
|
||||
}
|
||||
13
src/routes/api/users/[userId]/library/artists/+server.ts
Normal file
13
src/routes/api/users/[userId]/library/artists/+server.ts
Normal 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 })
|
||||
}
|
||||
13
src/routes/api/users/[userId]/library/playlists/+server.ts
Normal file
13
src/routes/api/users/[userId]/library/playlists/+server.ts
Normal 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 })
|
||||
}
|
||||
Reference in New Issue
Block a user