Skip to content

Instantly share code, notes, and snippets.

@aadishv
Created December 7, 2025 09:03
Show Gist options
  • Select an option

  • Save aadishv/a53c864877aa619b02d0c32790922b33 to your computer and use it in GitHub Desktop.

Select an option

Save aadishv/a53c864877aa619b02d0c32790922b33 to your computer and use it in GitHub Desktop.
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