-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
74 lines (67 loc) · 3.04 KB
/
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
const { program } = require('commander');
const { MBNDSynchronizer } = require('./lib/handlers/MBNDSynchronizer.js');
const packageJson = require('./package.json');
const runAction = async (options, command) => {
const synchronizer = new MBNDSynchronizer(options);
await synchronizer.run(command._name);
};
const commandLinesOptions = {
csv: {
flags: '--csv <path>',
description: 'MusicBee CSV source file path. Default: MusicBee_Export.csv, in the same folder as MBNDS',
defaultValue: 'MusicBee_Export.csv'
},
db: {
flags: '--db <path>',
description: 'Navidrome SQLITE .db source file path. Default: navidrome.db, in the same folder as MBNDS',
defaultValue: 'navidrome.db'
},
user: {
flags: '-u, --user <user_name>',
description: 'choose Navidrome username (by default if not used, the first user will be used)'
},
datetimeFormat: {
flags: '--datetime-format <format>',
description: 'MusicBee CSV datetime format. Default: "DD/MM/YYYY HH:mm"',
defaultValue: 'DD/MM/YYYY HH:mm'
},
verbose: {
flags: '--verbose',
description: 'verbose debugging'
}
};
program
.command('fullSync')
.description('sync playcounts, track ratings, loved tracks and last played from MusicBee DB to Navidrome DB')
.option(commandLinesOptions.user.flags, commandLinesOptions.user.description)
.option('-f, --first', 'run sync for the first time: add MB playcount to ND playcount')
.option(commandLinesOptions.verbose.flags, commandLinesOptions.verbose.description)
.option(commandLinesOptions.csv.flags, commandLinesOptions.description, commandLinesOptions.defaultValue)
.option(commandLinesOptions.db.flags, commandLinesOptions.db.description, commandLinesOptions.db.defaultValue)
.option(
commandLinesOptions.datetimeFormat.flags,
commandLinesOptions.datetimeFormat.description,
commandLinesOptions.datetimeFormat.defaultValue
)
.action(runAction);
program
.name('musicbee-navidrome-sync')
.description(
`MusicBee to Navidrome Sync (MBNDS) : Tools to sync MusicBee DB to Navidrome DB (v${packageJson.version})\nhttps://github.com/rombat/musicbee-navidrome-sync`
)
.version(packageJson.version, '-v, --version', 'output the current version');
program
.command('albumsSync')
.description('update all albums playcounts and ratings based on existing Navidrome DB')
.option(commandLinesOptions.user.flags, commandLinesOptions.user.description)
.option(commandLinesOptions.verbose.flags, commandLinesOptions.verbose.description)
.option(commandLinesOptions.db.flags, commandLinesOptions.db.description, commandLinesOptions.db.defaultValue)
.action(runAction);
program
.command('artistsSync')
.description('update all artists playcounts and ratings based on existing Navidrome DB')
.option(commandLinesOptions.user.flags, commandLinesOptions.user.description)
.option(commandLinesOptions.verbose.flags, commandLinesOptions.verbose.description)
.option(commandLinesOptions.db.flags, commandLinesOptions.db.description, commandLinesOptions.db.defaultValue)
.action(runAction);
program.parse();