feat(web-player): page the album results and save YouTube albums
The albums section keeps a Ver más button while YouTube Music has another page, fed by a new /api/youtube/albums route that forwards the continuation token. The YouTube album page gains a save button that drops the whole album, tracks included, into your library and takes you to it.
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import type { RequestHandler } from './$types';
|
||||
import { json, error } from '@sveltejs/kit';
|
||||
import { createApiClient, requireAccessToken, unwrapOrError } from '$lib/server/api';
|
||||
|
||||
export const GET: RequestHandler = async ({ url, locals, fetch }) => {
|
||||
const accessToken = requireAccessToken(locals, 'Inicia sesión para buscar.');
|
||||
|
||||
const query = url.searchParams.get('query')?.trim() ?? '';
|
||||
if (!query) {
|
||||
error(400, 'Falta el término de búsqueda.');
|
||||
}
|
||||
|
||||
const continuation = url.searchParams.get('continuation') ?? undefined;
|
||||
|
||||
const api = createApiClient({ fetch, accessToken });
|
||||
const result = await api.GET('/youtube/albums', {
|
||||
params: { query: { query, continuation } }
|
||||
});
|
||||
|
||||
return json(unwrapOrError(result, 'No se pudieron buscar álbumes en YouTube Music.'));
|
||||
};
|
||||
Reference in New Issue
Block a user