-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
36 lines (26 loc) · 965 Bytes
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { readdir } from "node:fs/promises";
import { join } from "node:path";
import { downloadCoverArt } from "./downloadFile.ts";
import { checkTrackInfo } from "./checkTrackInfo.ts";
import { updateTrackInfo } from "./updateTrackInfo.ts";
const ONLY_ONE = false;
const MUSIC_FOLDER = "/<folder>";
const listFiles = async (): Promise<string[]> => {
const files = await readdir(MUSIC_FOLDER);
return files
.filter((fileName) => fileName !== ".DS_Store")
.map((fileName) => join(MUSIC_FOLDER, fileName));
};
(async () => {
const filePaths = await listFiles();
for (const filePath of filePaths) {
console.log("Processing: ", filePath);
const newTrackInfo = await checkTrackInfo(filePath);
console.log(newTrackInfo);
const coverArtPath = await downloadCoverArt(newTrackInfo);
newTrackInfo.coverArtPath = coverArtPath;
await updateTrackInfo(newTrackInfo);
if (ONLY_ONE) break;
}
console.log("finished");
})();