Skip to content
This repository was archived by the owner on Mar 20, 2023. It is now read-only.

Commit 5d5e6d6

Browse files
committed
feat: script to cherry pick items out of metadata.json
1 parent 4deb794 commit 5d5e6d6

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
node_modules/
33
data/
44
music/
5+
scripts/metadata.json
56

67
.env
78

scripts/metadata_match_delete.js

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
const fs = require('fs');
2+
const path = require('path');
3+
4+
const metadata = require('./metadata.json');
5+
const newMetadata = [];
6+
7+
//
8+
// Match track and delete from metadata
9+
//
10+
console.log(`Match track and delete from metadata
11+
`);
12+
13+
// Options
14+
const DRY_RUN = false;
15+
const MATCH_PATTERN = /(\[1958\] The Lady In Red)/i;
16+
17+
for (const key in metadata) {
18+
const track = metadata[key];
19+
const { path: trackPath, metadata: meta } = track;
20+
const { title, artist } = meta;
21+
22+
// If path matches, skip
23+
if (trackPath.match(MATCH_PATTERN)) {
24+
console.log(`Matched: ${artist} - ${title}`);
25+
continue;
26+
}
27+
28+
newMetadata.push(track);
29+
}
30+
31+
console.log('');
32+
console.log('Tracks before:', metadata.length);
33+
console.log('Tracks after: ', newMetadata.length);
34+
if (DRY_RUN) console.log('DRY RUN: No changes made');
35+
36+
37+
// Overwrite metadata
38+
if (!DRY_RUN) fs.writeFileSync(path.resolve(__dirname, 'metadata.json'), JSON.stringify(newMetadata));

0 commit comments

Comments
 (0)