import playdl, { type YouTubeVideo } from 'play-dl';

function shuffleArray(array: any[]) {
    for (let i = array.length - 1; i > 0; i--) {
        const j = Math.floor(Math.random() * (i + 1));
        [array[i], array[j]] = [array[j], array[i]];
    }
    return array;
}

/** @type {import('./$types').PageServerLoad} */
export async function load({ params }) {

    // const playlistUrl = 'https://music.youtube.com/playlist?list=PLHqPHHvmOjJ6JwiYc3Fg-O5JGbVppI1VR&si=evK225CpqXKeSq2Q';

    // const playlist = await playdl.playlist_info(playlistUrl);

    // let songs = (await playlist.all_videos()).map((video: YouTubeVideo) => {
    //     return {
    //         title: video.title,
    //         url: video.url,
    //         author: video.channel?.name,
    //         authorUrl: video.channel?.url,
    //         thumbnail: video.thumbnails[0].url,
    //         duration: video.durationRaw,
    //     }
    // })

    return {
        songs: []
    };

}