25 lines
664 B
TypeScript
25 lines
664 B
TypeScript
import ytpl from 'ytpl';
|
|
|
|
/** @type {import('./$types').PageServerLoad} */
|
|
export async function load({ params }) {
|
|
|
|
const playlistUrl = 'https://music.youtube.com/playlist?list=PLHqPHHvmOjJ6JwiYc3Fg-O5JGbVppI1VR&si=CIb9WIKhjKsRV3p3';
|
|
|
|
const playlist = await ytpl(playlistUrl, { limit: Infinity });
|
|
|
|
const songs = playlist.items.map((item, index) => {
|
|
return {
|
|
index: index + 1,
|
|
title: item.title,
|
|
duration: item.duration, // format is usually mm:ss
|
|
author: item.author.name,
|
|
isLive: item.isLive,
|
|
url: item.shortUrl
|
|
};
|
|
});
|
|
|
|
return {
|
|
songs
|
|
};
|
|
|
|
} |