Styles and About Page Fixes
This commit is contained in:
@@ -1,25 +1,33 @@
|
||||
import ytpl from 'ytpl';
|
||||
import playdl, { 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=CIb9WIKhjKsRV3p3';
|
||||
const playlistUrl = 'https://music.youtube.com/playlist?list=PLHqPHHvmOjJ6JwiYc3Fg-O5JGbVppI1VR&si=pJnM95siw3kQRlnr';
|
||||
|
||||
const playlist = await ytpl(playlistUrl, { limit: Infinity });
|
||||
const playlist = await playdl.playlist_info(playlistUrl);
|
||||
|
||||
const songs = playlist.items.map((item, index) => {
|
||||
let songs = (await playlist.all_videos()).map((video: YouTubeVideo) => {
|
||||
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
|
||||
};
|
||||
});
|
||||
title: video.title,
|
||||
url: video.url,
|
||||
author: video.channel?.name,
|
||||
authorUrl: video.channel?.url,
|
||||
thumbnail: video.thumbnails[0].url,
|
||||
duration: video.durationRaw,
|
||||
}
|
||||
})
|
||||
|
||||
return {
|
||||
songs
|
||||
songs: shuffleArray(songs)
|
||||
};
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user