Created
December 7, 2025 09:03
-
-
Save aadishv/a53c864877aa619b02d0c32790922b33 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { globSync } from "fs"; | |
| import NodeID3 from "node-id3"; | |
| export function getSongs() { | |
| let songs = []; | |
| for (const file of globSync("../Media.localized/Music/**/*.mp3")) { | |
| const data = NodeID3.read(file); | |
| if (data.album && data.artist) { | |
| let title = file.split("/").pop(); | |
| if (title?.startsWith("0") || title?.startsWith("1")) { | |
| title = title.slice(3); | |
| } | |
| title = title ? title.slice(0, title.length - 4) : "N/A" | |
| songs.push({ | |
| album: data.album, | |
| artist: data.artist, | |
| title, | |
| lyrics: data.unsynchronisedLyrics?.text | |
| }); | |
| } else continue; | |
| } | |
| return songs | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment