-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconvert.js
More file actions
26 lines (21 loc) · 896 Bytes
/
Copy pathconvert.js
File metadata and controls
26 lines (21 loc) · 896 Bytes
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
import { mkdirSync, writeFileSync } from 'node:fs';
import { dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';
import { ReadOnlyDatabase } from './converter/source_reader.js';
import { convertWithDb } from './converter/convert_core.js';
const __dirname = dirname(fileURLToPath(import.meta.url));
const DATABASE = 'databases/m.db';
const OUTPUT = join(__dirname, 'output', 'rekordbox.xml');
export function doConvert(playlistNames, outputPath = OUTPUT, goldenRef = {}, dbPath = DATABASE) {
mkdirSync(dirname(outputPath), { recursive: true });
const db = new ReadOnlyDatabase(dbPath);
db.openSync();
try {
const { xml, trackCount, playlistCount } = convertWithDb(db, playlistNames, goldenRef);
writeFileSync(outputPath, xml, 'utf-8');
return { outputPath, trackCount, playlistCount };
} finally {
db.close();
}
}
export { convertWithDb };