update dependencies, add songs to youtube playlist
This commit is contained in:
24
src/routes/ytauth/+page.server.ts
Normal file
24
src/routes/ytauth/+page.server.ts
Normal file
@ -0,0 +1,24 @@
|
||||
import { log } from '$lib/log';
|
||||
import { YoutubePlaylistAdder } from '$lib/server/ytPlaylistAdder';
|
||||
import { redirect } from '@sveltejs/kit';
|
||||
import type { PageServerLoad } from './$types';
|
||||
|
||||
export const load: PageServerLoad = async ({ url }) => {
|
||||
const adder = new YoutubePlaylistAdder();
|
||||
if (url.searchParams.has('code')) {
|
||||
log.debug(url.searchParams);
|
||||
await adder.receivedAuthCode(url.searchParams.get('code') || '', url);
|
||||
redirect(307, '/');
|
||||
} else if (url.searchParams.has('error')) {
|
||||
log.error('received error', url.searchParams.get('error'));
|
||||
return;
|
||||
}
|
||||
|
||||
if (await adder.authCodeExists()) {
|
||||
redirect(307, '/');
|
||||
}
|
||||
|
||||
const authUrl = adder.constructAuthUrl(url);
|
||||
log.debug('+page.server.ts', authUrl.toString());
|
||||
redirect(307, authUrl);
|
||||
};
|
2
src/routes/ytauth/+page.svelte
Normal file
2
src/routes/ytauth/+page.svelte
Normal file
@ -0,0 +1,2 @@
|
||||
<h1>Hello and welcome to my site!</h1>
|
||||
<a href="/about">About my site</a>
|
Reference in New Issue
Block a user