@sequencemedia/music-library 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/app.mjs CHANGED
@@ -1,133 +1,133 @@
1
- #!/usr/bin/env node
2
-
3
- import 'dotenv/config'
4
-
5
- import debug from 'debug'
6
-
7
- import {
8
- readFile
9
- } from 'fs/promises'
10
-
11
- import psList from 'ps-list'
12
-
13
- import commander from 'commander'
14
-
15
- import * as watch from '#music-library/watch'
16
-
17
- const {
18
- library,
19
- library: {
20
- tracks,
21
- playlists
22
- }
23
- } = watch
24
-
25
- const NAME = 'ml.App'
26
- process.title = NAME
27
-
28
- async function app () {
29
- const PACKAGE = JSON.parse(await readFile('./package.json'))
30
-
31
- const {
32
- name
33
- } = PACKAGE
34
-
35
- /**
36
- * Permit only one instance of the application
37
- */
38
- try {
39
- const a = (await psList())
40
- .filter(({ name }) => name === NAME)
41
-
42
- if (a.length > 1) {
43
- const {
44
- pid: PID
45
- } = process
46
-
47
- const {
48
- pid
49
- } = a.find(({ pid }) => pid !== PID)
50
-
51
- const log = debug('music-library:process:log')
52
-
53
- log(`Killing application "${name}" in process ${pid}.`)
54
-
55
- process.kill(pid)
56
- }
57
- } catch ({ message }) {
58
- const error = debug('music-library:process:error')
59
-
60
- error(message)
61
- return
62
- }
63
-
64
- const log = debug('@sequencemedia/music-library')
65
-
66
- const {
67
- pid,
68
- argv,
69
- env: {
70
- JAR,
71
- XML,
72
- DESTINATION
73
- }
74
- } = process
75
-
76
- log(`Starting application "${name}" in process ${pid}.`)
77
-
78
- const {
79
- version
80
- } = PACKAGE
81
-
82
- commander
83
- .version(version)
84
- .option('-j, --jar [jar]', 'Path to Saxon PE/EE JAR')
85
- .option('-x, --xml [xml]', 'Path to iTunes Library XML')
86
- .option('-d, --destination [destination]', 'Destination path for M3Us')
87
- .option('-t, --tracks', 'Parse all tracks')
88
- .option('-p, --playlists', 'Parse all playlists')
89
- .parse(argv)
90
-
91
- const {
92
- jar = JAR,
93
- xml = XML,
94
- destination = DESTINATION,
95
- tracks: t = false,
96
- playlists: p = false
97
- } = commander.opts()
98
-
99
- const l = (
100
- (t && p) || (!t && !p)
101
- )
102
-
103
- if (l) {
104
- log(`Application "${name}" in process ${pid} watching Library.`)
105
-
106
- log({ jar, xml, destination })
107
-
108
- return (
109
- library
110
- .toM3U(jar, xml, destination)
111
- )
112
- } else {
113
- if (t) {
114
- log(`Application "${name}" in process ${pid} watching Tracks.`)
115
-
116
- return (
117
- tracks
118
- .toM3U(jar, xml, destination)
119
- )
120
- }
121
-
122
- if (p) {
123
- log(`Application "${name}" in process ${pid} watching Playlists.`)
124
-
125
- return (
126
- playlists
127
- .toM3U(jar, xml, destination)
128
- )
129
- }
130
- }
131
- }
132
-
133
- export default app()
1
+ #!/usr/bin/env node
2
+
3
+ import 'dotenv/config'
4
+
5
+ import debug from 'debug'
6
+
7
+ import {
8
+ readFile
9
+ } from 'fs/promises'
10
+
11
+ import psList from 'ps-list'
12
+
13
+ import commander from 'commander'
14
+
15
+ import * as watch from '#music-library/watch'
16
+
17
+ const {
18
+ library,
19
+ library: {
20
+ tracks,
21
+ playlists
22
+ }
23
+ } = watch
24
+
25
+ const NAME = 'ml.App'
26
+ process.title = NAME
27
+
28
+ async function app () {
29
+ const PACKAGE = JSON.parse(await readFile('./package.json'))
30
+
31
+ const {
32
+ name
33
+ } = PACKAGE
34
+
35
+ /**
36
+ * Permit only one instance of the application
37
+ */
38
+ try {
39
+ const a = (await psList())
40
+ .filter(({ name }) => name === NAME)
41
+
42
+ if (a.length > 1) {
43
+ const {
44
+ pid: PID
45
+ } = process
46
+
47
+ const {
48
+ pid
49
+ } = a.find(({ pid }) => pid !== PID)
50
+
51
+ const log = debug('music-library:process:log')
52
+
53
+ log(`Killing application "${name}" in process ${pid}.`)
54
+
55
+ process.kill(pid)
56
+ }
57
+ } catch ({ message }) {
58
+ const error = debug('music-library:process:error')
59
+
60
+ error(message)
61
+ return
62
+ }
63
+
64
+ const log = debug('@sequencemedia/music-library')
65
+
66
+ const {
67
+ pid,
68
+ argv,
69
+ env: {
70
+ JAR,
71
+ XML,
72
+ DESTINATION
73
+ }
74
+ } = process
75
+
76
+ log(`Starting application "${name}" in process ${pid}.`)
77
+
78
+ const {
79
+ version
80
+ } = PACKAGE
81
+
82
+ commander
83
+ .version(version)
84
+ .option('-j, --jar [jar]', 'Path to Saxon PE/EE JAR')
85
+ .option('-x, --xml [xml]', 'Path to iTunes Library XML')
86
+ .option('-d, --destination [destination]', 'Destination path for M3Us')
87
+ .option('-t, --tracks', 'Parse all tracks')
88
+ .option('-p, --playlists', 'Parse all playlists')
89
+ .parse(argv)
90
+
91
+ const {
92
+ jar = JAR,
93
+ xml = XML,
94
+ destination = DESTINATION,
95
+ tracks: t = false,
96
+ playlists: p = false
97
+ } = commander.opts()
98
+
99
+ const l = (
100
+ (t && p) || (!t && !p)
101
+ )
102
+
103
+ if (l) {
104
+ log(`Application "${name}" in process ${pid} watching Library.`)
105
+
106
+ log({ jar, xml, destination })
107
+
108
+ return (
109
+ library
110
+ .toM3U(jar, xml, destination)
111
+ )
112
+ } else {
113
+ if (t) {
114
+ log(`Application "${name}" in process ${pid} watching Tracks.`)
115
+
116
+ return (
117
+ tracks
118
+ .toM3U(jar, xml, destination)
119
+ )
120
+ }
121
+
122
+ if (p) {
123
+ log(`Application "${name}" in process ${pid} watching Playlists.`)
124
+
125
+ return (
126
+ playlists
127
+ .toM3U(jar, xml, destination)
128
+ )
129
+ }
130
+ }
131
+ }
132
+
133
+ export default app()
package/babel.config.cjs CHANGED
@@ -1,24 +1,24 @@
1
- const presets = [
2
- [
3
- '@babel/env',
4
- {
5
- targets: {
6
- node: 'current'
7
- },
8
- useBuiltIns: 'usage',
9
- corejs: 3
10
- }
11
- ]
12
- ]
13
-
14
- const plugins = [
15
- '@babel/proposal-export-default-from',
16
- '@babel/proposal-export-namespace-from'
17
- ]
18
-
19
- module.exports = {
20
- compact: true,
21
- comments: false,
22
- presets,
23
- plugins
24
- }
1
+ const presets = [
2
+ [
3
+ '@babel/env',
4
+ {
5
+ targets: {
6
+ node: 'current'
7
+ },
8
+ useBuiltIns: 'usage',
9
+ corejs: 3
10
+ }
11
+ ]
12
+ ]
13
+
14
+ const plugins = [
15
+ '@babel/proposal-export-default-from',
16
+ '@babel/proposal-export-namespace-from'
17
+ ]
18
+
19
+ module.exports = {
20
+ compact: true,
21
+ comments: false,
22
+ presets,
23
+ plugins
24
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sequencemedia/music-library",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Watch Apple Music Library XML and parse to JSON, JS, ES, or M3U",
5
5
  "keywords": [
6
6
  "music",
@@ -34,17 +34,17 @@
34
34
  "scripts": {
35
35
  "lint": "eslint . --ext .mjs --ext .cjs",
36
36
  "lint:fix": "npm run lint -- --fix",
37
- "start": "cross-env DEBUG=@sequencemedia/music-library* NODE_ENV=production node .",
38
- "start:dev": "cross-env DEBUG=@sequencemedia/music-library* NODE_ENV=development node ."
37
+ "start": "cross-env DEBUG=@sequencemedia/music-library,@sequencemedia/music-library:*,@sequencemedia/music-library-parser,@sequencemedia/music-library-parser:* NODE_ENV=production node .",
38
+ "start:dev": "cross-env DEBUG=@sequencemedia/music-library,@sequencemedia/music-library:*,@sequencemedia/music-library-parser,@sequencemedia/music-library-parser:* NODE_ENV=development node ."
39
39
  },
40
40
  "dependencies": {
41
- "@sequencemedia/music-library-parser": "1.0.0",
41
+ "@sequencemedia/music-library-parser": "1.0.2",
42
42
  "chokidar": "^3.5.2",
43
43
  "commander": "^8.3.0",
44
44
  "cross-env": "^7.0.3",
45
45
  "debug": "^4.3.3",
46
46
  "dotenv": "^10.0.0",
47
- "ps-list": "7.2.0",
47
+ "ps-list": "^8.0.0",
48
48
  "supports-color": "^9.2.1"
49
49
  },
50
50
  "devDependencies": {
package/src/index.mjs CHANGED
@@ -1 +1 @@
1
- export * as library from '#music-library/library'
1
+ export * as library from '#music-library/library'
@@ -1,37 +1,37 @@
1
- import debug from 'debug'
2
-
3
- import * as musicLibraryParser from '@sequencemedia/music-library-parser'
4
-
5
- import normalise from '#music-library/common/normalise'
6
-
7
- const {
8
- library: {
9
- toM3U: parseToM3U
10
- }
11
- } = musicLibraryParser
12
-
13
- const error = debug('@sequencemedia/music-library:error')
14
-
15
- export async function toM3U (jar, xml, destination) {
16
- try {
17
- const j = jar
18
- ? normalise(jar)
19
- : jar
20
-
21
- const x = xml
22
- ? normalise(xml)
23
- : xml
24
-
25
- const d = destination
26
- ? normalise(destination)
27
- : destination
28
-
29
- return await parseToM3U(j, x, d)
30
- } catch ({ message }) {
31
- error(message)
32
- }
33
- }
34
-
35
- export * as tracks from './tracks'
36
- export * as playlists from './playlists'
37
- export * as transform from './transform'
1
+ import debug from 'debug'
2
+
3
+ import * as musicLibraryParser from '@sequencemedia/music-library-parser'
4
+
5
+ import normalise from '#music-library/common/normalise'
6
+
7
+ const {
8
+ library: {
9
+ toM3U: parseToM3U
10
+ }
11
+ } = musicLibraryParser
12
+
13
+ const error = debug('@sequencemedia/music-library:error')
14
+
15
+ export async function toM3U (jar, xml, destination) {
16
+ try {
17
+ const j = jar
18
+ ? normalise(jar)
19
+ : jar
20
+
21
+ const x = xml
22
+ ? normalise(xml)
23
+ : xml
24
+
25
+ const d = destination
26
+ ? normalise(destination)
27
+ : destination
28
+
29
+ return await parseToM3U(j, x, d)
30
+ } catch ({ message }) {
31
+ error(message)
32
+ }
33
+ }
34
+
35
+ export * as tracks from '#music-library/library/tracks'
36
+ export * as playlists from '#music-library/library/playlists'
37
+ export * as transform from '#music-library/library/transform'
@@ -1,37 +1,37 @@
1
- import debug from 'debug'
2
-
3
- import * as musicLibraryParser from '@sequencemedia/music-library-parser'
4
-
5
- import normalise from '#music-library/common/normalise'
6
-
7
- const {
8
- library: {
9
- playlists: {
10
- toM3U: parseToM3U
11
- }
12
- }
13
- } = musicLibraryParser
14
-
15
- const error = debug('@sequencemedia/music-library:error')
16
-
17
- export async function toM3U (jar, xml, destination) {
18
- try {
19
- const j = jar
20
- ? normalise(jar)
21
- : jar
22
-
23
- const x = xml
24
- ? normalise(xml)
25
- : xml
26
-
27
- const d = destination
28
- ? normalise(destination)
29
- : destination
30
-
31
- return await parseToM3U(j, x, d)
32
- } catch ({ message }) {
33
- error(message)
34
- }
35
- }
36
-
37
- export * as transform from './transform'
1
+ import debug from 'debug'
2
+
3
+ import * as musicLibraryParser from '@sequencemedia/music-library-parser'
4
+
5
+ import normalise from '#music-library/common/normalise'
6
+
7
+ const {
8
+ library: {
9
+ playlists: {
10
+ toM3U: parseToM3U
11
+ }
12
+ }
13
+ } = musicLibraryParser
14
+
15
+ const error = debug('@sequencemedia/music-library:error')
16
+
17
+ export async function toM3U (jar, xml, destination) {
18
+ try {
19
+ const j = jar
20
+ ? normalise(jar)
21
+ : jar
22
+
23
+ const x = xml
24
+ ? normalise(xml)
25
+ : xml
26
+
27
+ const d = destination
28
+ ? normalise(destination)
29
+ : destination
30
+
31
+ return await parseToM3U(j, x, d)
32
+ } catch ({ message }) {
33
+ error(message)
34
+ }
35
+ }
36
+
37
+ export * as transform from './transform'
@@ -1,67 +1,67 @@
1
- import debug from 'debug'
2
-
3
- import * as musicLibraryParser from '@sequencemedia/music-library-parser'
4
-
5
- import normalise from '#music-library/common/normalise'
6
-
7
- const {
8
- library: {
9
- playlists: {
10
- transform: {
11
- toJSON: transformToJSON,
12
- toJS: transformToJS,
13
- toES: transformToES
14
- }
15
- }
16
- }
17
- } = musicLibraryParser
18
-
19
- const error = debug('@sequencemedia/music-library:transform:error')
20
-
21
- export async function toJSON (jar, xml) {
22
- try {
23
- const j = jar
24
- ? normalise(jar)
25
- : jar
26
-
27
- const x = xml
28
- ? normalise(xml)
29
- : xml
30
-
31
- return await transformToJSON(j, x)
32
- } catch ({ message }) {
33
- error(message)
34
- }
35
- }
36
-
37
- export async function toJS (jar, xml) {
38
- try {
39
- const j = jar
40
- ? normalise(jar)
41
- : jar
42
-
43
- const x = xml
44
- ? normalise(xml)
45
- : xml
46
-
47
- return await transformToJS(j, x)
48
- } catch ({ message }) {
49
- error(message)
50
- }
51
- }
52
-
53
- export async function toES (jar, xml) {
54
- try {
55
- const j = jar
56
- ? normalise(jar)
57
- : jar
58
-
59
- const x = xml
60
- ? normalise(xml)
61
- : xml
62
-
63
- return await transformToES(j, x)
64
- } catch ({ message }) {
65
- error(message)
66
- }
67
- }
1
+ import debug from 'debug'
2
+
3
+ import * as musicLibraryParser from '@sequencemedia/music-library-parser'
4
+
5
+ import normalise from '#music-library/common/normalise'
6
+
7
+ const {
8
+ library: {
9
+ playlists: {
10
+ transform: {
11
+ toJSON: transformToJSON,
12
+ toJS: transformToJS,
13
+ toES: transformToES
14
+ }
15
+ }
16
+ }
17
+ } = musicLibraryParser
18
+
19
+ const error = debug('@sequencemedia/music-library:transform:error')
20
+
21
+ export async function toJSON (jar, xml) {
22
+ try {
23
+ const j = jar
24
+ ? normalise(jar)
25
+ : jar
26
+
27
+ const x = xml
28
+ ? normalise(xml)
29
+ : xml
30
+
31
+ return await transformToJSON(j, x)
32
+ } catch ({ message }) {
33
+ error(message)
34
+ }
35
+ }
36
+
37
+ export async function toJS (jar, xml) {
38
+ try {
39
+ const j = jar
40
+ ? normalise(jar)
41
+ : jar
42
+
43
+ const x = xml
44
+ ? normalise(xml)
45
+ : xml
46
+
47
+ return await transformToJS(j, x)
48
+ } catch ({ message }) {
49
+ error(message)
50
+ }
51
+ }
52
+
53
+ export async function toES (jar, xml) {
54
+ try {
55
+ const j = jar
56
+ ? normalise(jar)
57
+ : jar
58
+
59
+ const x = xml
60
+ ? normalise(xml)
61
+ : xml
62
+
63
+ return await transformToES(j, x)
64
+ } catch ({ message }) {
65
+ error(message)
66
+ }
67
+ }