From 7b94b962efcc1e07371fa9f6a826f2416ebe72e3 Mon Sep 17 00:00:00 2001 From: Azalea <22280294+hykilpikonna@users.noreply.github.com> Date: Fri, 21 Nov 2025 13:31:13 +0800 Subject: [PATCH] [O] Only init when not already exist --- src/lib/server/songs.ts | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/lib/server/songs.ts b/src/lib/server/songs.ts index bd624df..f6c1a98 100644 --- a/src/lib/server/songs.ts +++ b/src/lib/server/songs.ts @@ -217,10 +217,16 @@ export const getPlaylist = async (playlistId: number | string) => { return plData.data } -await startImport("13555799996") -await startImport("https://music.163.com/playlist?id=14348145982") -await startImport("https://music.163.com/playlist?id=14392963638") -await startImport("https://music.163.com/playlist?id=580208139") -await startImport("https://music.163.com/playlist?id=17404030548") - -// TODO: Filter out non-Japanese songs +// Check if there are any playlists, if not, import default ones +(async () => { + const count = await db.collection('playlists').countDocuments() + if (count === 0) { + console.log("No playlists found. Importing default playlists...") + await startImport("13555799996") + await startImport("17463338036") + await startImport("14348145982") + await startImport("14392963638") + await startImport("580208139") + await startImport("17404030548") + } +})()