-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
29 lines (27 loc) · 905 Bytes
/
index.js
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
import searchForSong from './searchForSong.js';
import addSong from './addSong.js';
import songNamesFromFile from './song-names.json';
(async ()=>{
const failed = [];
try{
let songNames = songNamesFromFile.map(s => s.replace('\n', ' '));
let index = songNames.length - 1;
while(index >= 0){
try{
const searchResult = await searchForSong(songNames[index]);
console.log(`[${songNames.length - index}/${songNames.length}] ${searchResult.name}`);
const added = await addSong(searchResult.id);
if(!added){
failed.push(songNames[index]);
}
}catch (e) {
failed.push(songNames[index]);
}finally {
index--;
}
}
}catch (e) {
console.log(e);
console.log(failed);
}
})();