@makefully/dutifully 1.10.1 → 1.11.0

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.
@@ -1,17 +1,17 @@
1
- const
2
- TextToSpeech = require('./TextToSpeech');
3
-
4
- module.exports = class ElevenLabs extends TextToSpeech {
5
- constructor (data) {
6
- const
7
- {id, elevenLabsApiKey} = data.contents;
8
-
9
- data.album = id;
10
- data.encodedBy = 'ElevenLabs';
11
- if (elevenLabsApiKey) {
12
- data.config.apiKey = elevenLabsApiKey;
13
- }
14
-
15
- super(data);
16
- }
1
+ const
2
+ TextToSpeech = require('./TextToSpeech');
3
+
4
+ module.exports = class ElevenLabs extends TextToSpeech {
5
+ constructor (data) {
6
+ const
7
+ {id, elevenLabsApiKey} = data.contents;
8
+
9
+ data.album = id;
10
+ data.encodedBy = 'ElevenLabs';
11
+ if (elevenLabsApiKey) {
12
+ data.config.apiKey = elevenLabsApiKey;
13
+ }
14
+
15
+ super(data);
16
+ }
17
17
  };
@@ -1,13 +1,13 @@
1
- const
2
- Cheer = require('./Cheer'),
3
- FFMPEG = class FFMPEG extends Cheer {
4
- beforeSend (archive) {
5
- const
6
- {src} = this.config;
7
-
8
- archive.directory(src, false);
9
- super.beforeSend(archive);
10
- }
11
- };
12
-
1
+ const
2
+ Cheer = require('./Cheer'),
3
+ FFMPEG = class FFMPEG extends Cheer {
4
+ beforeSend (archive) {
5
+ const
6
+ {src} = this.config;
7
+
8
+ archive.directory(src, false);
9
+ super.beforeSend(archive);
10
+ }
11
+ };
12
+
13
13
  module.exports = FFMPEG;
@@ -1,133 +1,133 @@
1
- const
2
- Cheer = require('./Cheer'),
3
- fs = require('fs').promises,
4
- getJSON = require('../helpers/getJSON'),
5
- id3 = require('node-id3').Promise,
6
- filter = (fileType, file) => (file.indexOf('.') !== 0) && (file.slice(-(fileType.length + 1)) === `.${fileType}`),
7
- combine = async (path, fileType) => {
8
- const
9
- files = (await fs.readdir(path)).filter(filter.bind(null, fileType)),
10
- list = [];
11
-
12
- for (let i = 0; i < files.length; i++) {
13
- const
14
- file = files[i];
15
-
16
- if (fileType === 'mp3') { // check id3 for lyrics presence.
17
- const
18
- {synchronisedLyrics} = await id3.read(`${path}${file}`);
19
-
20
- if (synchronisedLyrics) {
21
- const
22
- index = synchronisedLyrics.map(({shortText}) => shortText).indexOf('lipsync');
23
-
24
- if (index >= 0) {
25
- list.push(file.substring(0, file.length - fileType.length - 1));
26
- }
27
- }
28
- } else {
29
- list.push(file.substring(0, file.length - fileType.length - 1));
30
- }
31
- }
32
-
33
- return list;
34
- },
35
- sortKeys = (obj) => Object.keys(obj).sort().reduce((s, key) => {
36
- s[key] = obj[key];
37
- return s;
38
- }, {}),
39
- mapReduction = (map, list) => list.reduce((obj, file) => {
40
- const
41
- id = file.substring(0, file.length - 4);
42
-
43
- obj[id] = map[id];
44
- return obj;
45
- }, {}),
46
- LipSync = class LipSync extends Cheer {
47
- async prepare (data) {
48
- this.differenceOnly = false;
49
- this.updateList = null;
50
- await this.replaceConfigPathWithJSON('script', 'files');
51
- return super.prepare(data);
52
- }
53
-
54
- async checkDifference () {
55
- const
56
- {config} = this,
57
- {files = {}, options = {}, output, src} = config,
58
- {exportFormat = 'json', output: outputType = 'json'} = options,
59
- file = 'mouthCues.json',
60
- raw = outputType === 'json' && exportFormat !== 'mp3' ? await getJSON(`${output}${file}`) ?? {} : null,
61
- alreadyLipSynced = raw ? Object.keys(raw) : await combine(output, exportFormat),
62
- check = (id) => {
63
- const
64
- index = alreadyLipSynced.indexOf(id);
65
-
66
- if (index >= 0) {
67
- alreadyLipSynced.splice(index, 1);
68
- return true;
69
- } else {
70
- return false;
71
- }
72
- },
73
- mergeLipSync = async (newLipSync = false) => { // Must run _after_ all checks and will remove what's left.
74
- for (let i = 0; i < alreadyLipSynced.length; i++) {
75
- const
76
- key = alreadyLipSynced[i];
77
-
78
- if (raw) {
79
- delete raw[key];
80
- } else {
81
- await fs.rm(`${output}${key}.${exportFormat}`);
82
- }
83
- console.log(`Removed "${key}"`);
84
- }
85
- if (raw) {
86
- await fs.writeFile(`${output}${file}`, JSON.stringify(sortKeys({
87
- ...raw,
88
- ...newLipSync ? await getJSON(`${output}${file}`) ?? {} : {} // get new version.
89
- }), null, 4));
90
- }
91
-
92
- return alreadyLipSynced.length;
93
- },
94
- list = (await fs.readdir(src)).filter(filter.bind(null, 'mp3')).filter((file) => !check(file.substring(0, file.length - 4)));
95
-
96
- this.differenceOnly = true;
97
-
98
- if (list.length === 0) {
99
- // We'll still run the merge in case any have been removed.
100
- if (await mergeLipSync()) {
101
- throw Error('Old lip-sync removed, but no new ones required generation.');
102
- } else {
103
- throw Error('Lip-sync already up to date.');
104
- }
105
- }
106
- this.updateList = list;
107
- config.files = mapReduction(files, list);
108
- this.mergeLipSync = mergeLipSync;
109
- }
110
-
111
- beforeSend (archive) {
112
- const
113
- {src} = this.config;
114
-
115
- if (this.differenceOnly) {
116
- this.updateList.forEach((file) => archive.file(`${src}${file}`, {
117
- name: file
118
- }));
119
- } else {
120
- archive.directory(src, false);
121
- }
122
- super.beforeSend(archive);
123
- }
124
-
125
- afterExport (...args) {
126
- if (this.mergeLipSync) {
127
- this.mergeLipSync(true);
128
- }
129
- super.afterExport(...args)
130
- }
131
- };
132
-
1
+ const
2
+ Cheer = require('./Cheer'),
3
+ fs = require('fs').promises,
4
+ getJSON = require('../helpers/getJSON'),
5
+ id3 = require('node-id3').Promise,
6
+ filter = (fileType, file) => (file.indexOf('.') !== 0) && (file.slice(-(fileType.length + 1)) === `.${fileType}`),
7
+ combine = async (path, fileType) => {
8
+ const
9
+ files = (await fs.readdir(path)).filter(filter.bind(null, fileType)),
10
+ list = [];
11
+
12
+ for (let i = 0; i < files.length; i++) {
13
+ const
14
+ file = files[i];
15
+
16
+ if (fileType === 'mp3') { // check id3 for lyrics presence.
17
+ const
18
+ {synchronisedLyrics} = await id3.read(`${path}${file}`);
19
+
20
+ if (synchronisedLyrics) {
21
+ const
22
+ index = synchronisedLyrics.map(({shortText}) => shortText).indexOf('lipsync');
23
+
24
+ if (index >= 0) {
25
+ list.push(file.substring(0, file.length - fileType.length - 1));
26
+ }
27
+ }
28
+ } else {
29
+ list.push(file.substring(0, file.length - fileType.length - 1));
30
+ }
31
+ }
32
+
33
+ return list;
34
+ },
35
+ sortKeys = (obj) => Object.keys(obj).sort().reduce((s, key) => {
36
+ s[key] = obj[key];
37
+ return s;
38
+ }, {}),
39
+ mapReduction = (map, list) => list.reduce((obj, file) => {
40
+ const
41
+ id = file.substring(0, file.length - 4);
42
+
43
+ obj[id] = map[id];
44
+ return obj;
45
+ }, {}),
46
+ LipSync = class LipSync extends Cheer {
47
+ async prepare (data) {
48
+ this.differenceOnly = false;
49
+ this.updateList = null;
50
+ await this.replaceConfigPathWithJSON('script', 'files');
51
+ return super.prepare(data);
52
+ }
53
+
54
+ async checkDifference () {
55
+ const
56
+ {config} = this,
57
+ {files = {}, options = {}, output, src} = config,
58
+ {exportFormat = 'json', output: outputType = 'json'} = options,
59
+ file = 'mouthCues.json',
60
+ raw = outputType === 'json' && exportFormat !== 'mp3' ? await getJSON(`${output}${file}`) ?? {} : null,
61
+ alreadyLipSynced = raw ? Object.keys(raw) : await combine(output, exportFormat),
62
+ check = (id) => {
63
+ const
64
+ index = alreadyLipSynced.indexOf(id);
65
+
66
+ if (index >= 0) {
67
+ alreadyLipSynced.splice(index, 1);
68
+ return true;
69
+ } else {
70
+ return false;
71
+ }
72
+ },
73
+ mergeLipSync = async (newLipSync = false) => { // Must run _after_ all checks and will remove what's left.
74
+ for (let i = 0; i < alreadyLipSynced.length; i++) {
75
+ const
76
+ key = alreadyLipSynced[i];
77
+
78
+ if (raw) {
79
+ delete raw[key];
80
+ } else {
81
+ await fs.rm(`${output}${key}.${exportFormat}`);
82
+ }
83
+ console.log(`Removed "${key}"`);
84
+ }
85
+ if (raw) {
86
+ await fs.writeFile(`${output}${file}`, JSON.stringify(sortKeys({
87
+ ...raw,
88
+ ...newLipSync ? await getJSON(`${output}${file}`) ?? {} : {} // get new version.
89
+ }), null, 4));
90
+ }
91
+
92
+ return alreadyLipSynced.length;
93
+ },
94
+ list = (await fs.readdir(src)).filter(filter.bind(null, 'mp3')).filter((file) => !check(file.substring(0, file.length - 4)));
95
+
96
+ this.differenceOnly = true;
97
+
98
+ if (list.length === 0) {
99
+ // We'll still run the merge in case any have been removed.
100
+ if (await mergeLipSync()) {
101
+ throw Error('Old lip-sync removed, but no new ones required generation.');
102
+ } else {
103
+ throw Error('Lip-sync already up to date.');
104
+ }
105
+ }
106
+ this.updateList = list;
107
+ config.files = mapReduction(files, list);
108
+ this.mergeLipSync = mergeLipSync;
109
+ }
110
+
111
+ beforeSend (archive) {
112
+ const
113
+ {src} = this.config;
114
+
115
+ if (this.differenceOnly) {
116
+ this.updateList.forEach((file) => archive.file(`${src}${file}`, {
117
+ name: file
118
+ }));
119
+ } else {
120
+ archive.directory(src, false);
121
+ }
122
+ super.beforeSend(archive);
123
+ }
124
+
125
+ afterExport (...args) {
126
+ if (this.mergeLipSync) {
127
+ this.mergeLipSync(true);
128
+ }
129
+ super.afterExport(...args)
130
+ }
131
+ };
132
+
133
133
  module.exports = LipSync;
@@ -1,10 +1,10 @@
1
- const
2
- TextToSpeech = require('./TextToSpeech');
3
-
4
- module.exports = class Polly extends TextToSpeech {
5
- constructor (data) {
6
- data.album = data.contents.id;
7
- data.encodedBy = 'Amazon Polly';
8
- super(data);
9
- }
1
+ const
2
+ TextToSpeech = require('./TextToSpeech');
3
+
4
+ module.exports = class Polly extends TextToSpeech {
5
+ constructor (data) {
6
+ data.album = data.contents.id;
7
+ data.encodedBy = 'Amazon Polly';
8
+ super(data);
9
+ }
10
10
  };
@@ -1,13 +1,13 @@
1
- const
2
- Cheer = require('./Cheer'),
3
- Rasterize = class Rasterize extends Cheer {
4
- beforeSend (archive) {
5
- const
6
- {src} = this.config;
7
-
8
- archive.directory(src, false);
9
- super.beforeSend(archive);
10
- }
11
- };
12
-
1
+ const
2
+ Cheer = require('./Cheer'),
3
+ Rasterize = class Rasterize extends Cheer {
4
+ beforeSend (archive) {
5
+ const
6
+ {src} = this.config;
7
+
8
+ archive.directory(src, false);
9
+ super.beforeSend(archive);
10
+ }
11
+ };
12
+
13
13
  module.exports = Rasterize;