networkwm-js 0.1.1 → 0.1.2-alpha.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.
- package/dist/database-abstraction.d.ts +1 -1
- package/dist/database-abstraction.d.ts.map +1 -1
- package/dist/database-abstraction.js +16 -6
- package/dist/id3.d.ts +10 -2
- package/dist/id3.d.ts.map +1 -1
- package/dist/id3.js +27 -3
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/mp3.d.ts +3 -1
- package/dist/mp3.d.ts.map +1 -1
- package/dist/mp3.js +25 -2
- package/package.json +3 -3
- package/dist/test.d.ts +0 -2
- package/dist/test.d.ts.map +0 -1
- package/dist/test.js +0 -70
|
@@ -18,7 +18,7 @@ export declare class DatabaseAbstraction {
|
|
|
18
18
|
private lastTotalDuration;
|
|
19
19
|
private allTracks;
|
|
20
20
|
private deletedTracks;
|
|
21
|
-
|
|
21
|
+
mp3DeviceKey?: number;
|
|
22
22
|
database: DatabaseManager;
|
|
23
23
|
private constructor();
|
|
24
24
|
static create(filesystem: HiMDFilesystem, deviceInfo: DeviceDefinition): Promise<DatabaseAbstraction>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"database-abstraction.d.ts","sourceRoot":"","sources":["../src/database-abstraction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACnE,OAAO,EAAE,eAAe,EAAc,oBAAoB,EAAE,aAAa,EAAY,MAAM,aAAa,CAAC;AAGzG,OAAO,EAAsB,eAAe,EAAE,MAAM,cAAc,CAAC;AAGnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE7C,OAAO,EAAE,WAAW,EAAyB,MAAM,UAAU,CAAC;AAK9D,oBAAY,eAAe,GAAG,aAAa,GAAG;IAC1C,eAAe,EAAE,UAAU,CAAC;IAC5B,SAAS,EAAE,UAAU,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;IAEpB,SAAS,EAAE,aAAa,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,qBAAa,mBAAmB;IAOR,OAAO,CAAC,UAAU;IAAyB,UAAU,EAAE,gBAAgB;IAN3F,OAAO,CAAC,wBAAwB,CAAC,CAAyB;IAC1D,OAAO,CAAC,iBAAiB,CAAa;IACtC,OAAO,CAAC,SAAS,CAAyB;IAC1C,OAAO,CAAC,aAAa,CAAgB;
|
|
1
|
+
{"version":3,"file":"database-abstraction.d.ts","sourceRoot":"","sources":["../src/database-abstraction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACnE,OAAO,EAAE,eAAe,EAAc,oBAAoB,EAAE,aAAa,EAAY,MAAM,aAAa,CAAC;AAGzG,OAAO,EAAsB,eAAe,EAAE,MAAM,cAAc,CAAC;AAGnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE7C,OAAO,EAAE,WAAW,EAAyB,MAAM,UAAU,CAAC;AAK9D,oBAAY,eAAe,GAAG,aAAa,GAAG;IAC1C,eAAe,EAAE,UAAU,CAAC;IAC5B,SAAS,EAAE,UAAU,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;IAEpB,SAAS,EAAE,aAAa,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,qBAAa,mBAAmB;IAOR,OAAO,CAAC,UAAU;IAAyB,UAAU,EAAE,gBAAgB;IAN3F,OAAO,CAAC,wBAAwB,CAAC,CAAyB;IAC1D,OAAO,CAAC,iBAAiB,CAAa;IACtC,OAAO,CAAC,SAAS,CAAyB;IAC1C,OAAO,CAAC,aAAa,CAAgB;IAC9B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,eAAe,CAAC;IACjC,OAAO;WAIa,MAAM,CAAC,UAAU,EAAE,cAAc,EAAE,UAAU,EAAE,gBAAgB;IA+BnF,OAAO,CAAC,OAAO;IAkCR,WAAW,CAAC,SAAS,EAAE,aAAa,EAAE,SAAS,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM;IAyB5F,OAAO,CAAC,mBAAmB;YAWb,gBAAgB;IAsBxB,cAAc,CAChB,SAAS,EAAE,oBAAoB,EAC/B,OAAO,EAAE,UAAU,EACnB,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI;IAe9C,WAAW,CACb,SAAS,EAAE,oBAAoB,EAC/B,KAAK,EAAE,SAAS,EAChB,OAAO,EAAE,UAAU,EACnB,OAAO,CAAC,EAAE,eAAe,EACzB,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI;IAmB9C,YAAY;IAMZ,WAAW,CAAC,WAAW,EAAE,MAAM;IAcrC,mBAAmB;IA6EnB,0BAA0B,IAAK;QAC3B,0BAA0B,EAAE,CAAC,CAAC;QAC9B,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE;YACN,0BAA0B,EAAE,CAAC,CAAC;YAC9B,IAAI,EAAE,MAAM,CAAC;YACb,QAAQ,EAAE,eAAe,EAAE,CAAA;SAC9B,EAAE,CAAA;KACN,EAAE;IAIG,QAAQ;IA6BR,WAAW,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa;CAoBjE"}
|
|
@@ -282,15 +282,25 @@ class DatabaseAbstraction {
|
|
|
282
282
|
this._create();
|
|
283
283
|
}
|
|
284
284
|
async renameTrack(systemIndex, metadata) {
|
|
285
|
-
this.allTracks[systemIndex - 1].album = metadata.album;
|
|
286
|
-
this.allTracks[systemIndex - 1].artist = metadata.artist;
|
|
287
|
-
this.allTracks[systemIndex - 1].title = metadata.title;
|
|
288
|
-
this.allTracks[systemIndex - 1].trackNumber = metadata.trackNumber;
|
|
289
|
-
// TODO: Is this necessary??
|
|
290
285
|
// Update the metadata within the OMA file
|
|
291
286
|
const handle = await this.database.filesystem.open((0, helpers_1.resolvePathFromGlobalIndex)(systemIndex), 'rw');
|
|
292
287
|
if (handle) {
|
|
293
|
-
|
|
288
|
+
try {
|
|
289
|
+
if (this.allTracks[systemIndex - 1].codecName === "MP3") {
|
|
290
|
+
await (0, mp3_1.updateMP3Metadata)(handle, metadata);
|
|
291
|
+
}
|
|
292
|
+
else {
|
|
293
|
+
await (0, tagged_oma_1.updateMetadata)(handle, metadata);
|
|
294
|
+
}
|
|
295
|
+
// Only do this if we managed to update the track metadata in the underlying file:
|
|
296
|
+
this.allTracks[systemIndex - 1].album = metadata.album;
|
|
297
|
+
this.allTracks[systemIndex - 1].artist = metadata.artist;
|
|
298
|
+
this.allTracks[systemIndex - 1].title = metadata.title;
|
|
299
|
+
this.allTracks[systemIndex - 1].trackNumber = metadata.trackNumber;
|
|
300
|
+
}
|
|
301
|
+
finally {
|
|
302
|
+
await handle.close();
|
|
303
|
+
}
|
|
294
304
|
}
|
|
295
305
|
}
|
|
296
306
|
}
|
package/dist/id3.d.ts
CHANGED
|
@@ -13,8 +13,16 @@ export interface ID3Tags {
|
|
|
13
13
|
flags: number;
|
|
14
14
|
}
|
|
15
15
|
export declare function readSynchsafeInt32(data: DataView, offset: number): [number, number];
|
|
16
|
-
export declare function
|
|
17
|
-
|
|
16
|
+
export declare function readInitialID3Header(buffer: Uint8Array): {
|
|
17
|
+
major: number;
|
|
18
|
+
minor: number;
|
|
19
|
+
flags: number;
|
|
20
|
+
size: number;
|
|
21
|
+
};
|
|
22
|
+
export declare function parse(buffer: Uint8Array): ID3Tags & {
|
|
23
|
+
size: number;
|
|
24
|
+
};
|
|
25
|
+
export declare function serialize(tags: ID3Tags, constSize?: number): Uint8Array;
|
|
18
26
|
export declare function encodeUTF16BEStringEA3(source: string, includeType?: boolean): Uint8Array;
|
|
19
27
|
export declare function encodeSonyWeirdString(type: string, data: string): Uint8Array;
|
|
20
28
|
export declare function createCommonID3Tags(titleInfo: InboundTrackMetadata): {
|
package/dist/id3.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"id3.d.ts","sourceRoot":"","sources":["../src/id3.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAiB,MAAM,aAAa,CAAC;AAGlE,MAAM,WAAW,MAAM;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,UAAU,CAAC;CACxB;AAED,MAAM,WAAW,OAAO;IACpB,OAAO,EAAE;QACL,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,CAAC;KACjB,CAAC;IACF,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAYnF;AAKD,wBAAgB,KAAK,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,
|
|
1
|
+
{"version":3,"file":"id3.d.ts","sourceRoot":"","sources":["../src/id3.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAiB,MAAM,aAAa,CAAC;AAGlE,MAAM,WAAW,MAAM;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,UAAU,CAAC;CACxB;AAED,MAAM,WAAW,OAAO;IACpB,OAAO,EAAE;QACL,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,CAAC;KACjB,CAAC;IACF,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAYnF;AAKD,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,UAAU,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAiBtH;AAED,wBAAgB,KAAK,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAgDpE;AAWD,wBAAgB,SAAS,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,UAAU,CA8CvE;AAED,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,UAAO,cAgCxE;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,cAM/D;AAED,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,oBAAoB;;;;IAYlE"}
|
package/dist/id3.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createCommonID3Tags = exports.encodeSonyWeirdString = exports.encodeUTF16BEStringEA3 = exports.serialize = exports.parse = exports.readSynchsafeInt32 = void 0;
|
|
3
|
+
exports.createCommonID3Tags = exports.encodeSonyWeirdString = exports.encodeUTF16BEStringEA3 = exports.serialize = exports.parse = exports.readInitialID3Header = exports.readSynchsafeInt32 = void 0;
|
|
4
4
|
const bytemanip_1 = require("./bytemanip");
|
|
5
5
|
const utils_1 = require("./utils");
|
|
6
6
|
function readSynchsafeInt32(data, offset) {
|
|
@@ -20,6 +20,23 @@ exports.readSynchsafeInt32 = readSynchsafeInt32;
|
|
|
20
20
|
;
|
|
21
21
|
const textDecoder = new TextDecoder();
|
|
22
22
|
const textEncoder = new TextEncoder();
|
|
23
|
+
function readInitialID3Header(buffer) {
|
|
24
|
+
const data = new DataView(buffer.buffer);
|
|
25
|
+
let offset = 0;
|
|
26
|
+
// Read header
|
|
27
|
+
let bytes;
|
|
28
|
+
[bytes, offset] = (0, bytemanip_1.readBytes)(data, offset, 3);
|
|
29
|
+
if (String.fromCharCode(...bytes) !== 'ea3') {
|
|
30
|
+
throw new Error("Not an ID3v2 tag");
|
|
31
|
+
}
|
|
32
|
+
let major, minor, flags, size;
|
|
33
|
+
[major, offset] = (0, bytemanip_1.readUint8)(data, offset);
|
|
34
|
+
[minor, offset] = (0, bytemanip_1.readUint8)(data, offset);
|
|
35
|
+
[flags, offset] = (0, bytemanip_1.readUint8)(data, offset);
|
|
36
|
+
[size, offset] = readSynchsafeInt32(data, offset);
|
|
37
|
+
return { major, minor, size, flags };
|
|
38
|
+
}
|
|
39
|
+
exports.readInitialID3Header = readInitialID3Header;
|
|
23
40
|
function parse(buffer) {
|
|
24
41
|
const data = new DataView(buffer.buffer);
|
|
25
42
|
let offset = 0;
|
|
@@ -36,7 +53,7 @@ function parse(buffer) {
|
|
|
36
53
|
[size, offset] = readSynchsafeInt32(data, offset);
|
|
37
54
|
const tags = [];
|
|
38
55
|
// Parse frames
|
|
39
|
-
while (
|
|
56
|
+
while (offset < size) {
|
|
40
57
|
let frameId, frameSize, frameFlags, frameContents;
|
|
41
58
|
[frameId, offset] = (0, bytemanip_1.readBytes)(data, offset, 4);
|
|
42
59
|
[frameSize, offset] = (0, bytemanip_1.readUint32)(data, offset);
|
|
@@ -59,6 +76,7 @@ function parse(buffer) {
|
|
|
59
76
|
},
|
|
60
77
|
tags,
|
|
61
78
|
flags,
|
|
79
|
+
size,
|
|
62
80
|
};
|
|
63
81
|
}
|
|
64
82
|
exports.parse = parse;
|
|
@@ -72,7 +90,7 @@ function writeSynchsafeInt32(value) {
|
|
|
72
90
|
return array;
|
|
73
91
|
}
|
|
74
92
|
;
|
|
75
|
-
function serialize(tags) {
|
|
93
|
+
function serialize(tags, constSize) {
|
|
76
94
|
const header = new Uint8Array(10);
|
|
77
95
|
header.set(textEncoder.encode('ea3'));
|
|
78
96
|
header.set((0, bytemanip_1.writeUint8)(tags.version.major), 3);
|
|
@@ -91,6 +109,12 @@ function serialize(tags) {
|
|
|
91
109
|
frames.push(frame);
|
|
92
110
|
size += frame.length;
|
|
93
111
|
}
|
|
112
|
+
if (constSize !== undefined) {
|
|
113
|
+
if (size > constSize) {
|
|
114
|
+
throw new Error("Too much data to encode!");
|
|
115
|
+
}
|
|
116
|
+
size = constSize;
|
|
117
|
+
}
|
|
94
118
|
if ((size + 10) % 16 !== 0) {
|
|
95
119
|
const diff = 16 - ((size + 10) % 16);
|
|
96
120
|
size += diff;
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,wBAAwB,CAAC;AACvC,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,wBAAwB,CAAC;AACvC,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -23,6 +23,7 @@ __exportStar(require("./database-abstraction"), exports);
|
|
|
23
23
|
__exportStar(require("./sort"), exports);
|
|
24
24
|
__exportStar(require("./tagged-oma"), exports);
|
|
25
25
|
__exportStar(require("./devices"), exports);
|
|
26
|
+
__exportStar(require("./derive-mp3-key"), exports);
|
|
26
27
|
var encryption_1 = require("./encryption");
|
|
27
28
|
Object.defineProperty(exports, "importKeys", { enumerable: true, get: function () { return encryption_1.importKeys; } });
|
|
28
29
|
Object.defineProperty(exports, "initCrypto", { enumerable: true, get: function () { return encryption_1.initCrypto; } });
|
package/dist/mp3.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { NWCodecInfo } from './codecs';
|
|
2
|
-
import { InboundTrackMetadata } from './databases';
|
|
2
|
+
import { InboundTrackMetadata, TrackMetadata } from './databases';
|
|
3
|
+
import { HiMDFile } from 'himd-js';
|
|
3
4
|
export declare function generateMP3CodecField(mp3Data: Uint8Array): {
|
|
4
5
|
codec: NWCodecInfo;
|
|
5
6
|
duration: number;
|
|
6
7
|
frames: number;
|
|
7
8
|
};
|
|
8
9
|
export declare function createMP3OMAFile(index: number, metadata: InboundTrackMetadata, rawFile: Uint8Array, deviceKey: number, codec: NWCodecInfo): Uint8Array;
|
|
10
|
+
export declare function updateMP3Metadata(file: HiMDFile, titleInfo: TrackMetadata): Promise<void>;
|
|
9
11
|
//# sourceMappingURL=mp3.d.ts.map
|
package/dist/mp3.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mp3.d.ts","sourceRoot":"","sources":["../src/mp3.ts"],"names":[],"mappings":"AAEA,OAAO,EAA4B,WAAW,EAAE,MAAM,UAAU,CAAC;AACjE,OAAO,EAAE,oBAAoB,
|
|
1
|
+
{"version":3,"file":"mp3.d.ts","sourceRoot":"","sources":["../src/mp3.ts"],"names":[],"mappings":"AAEA,OAAO,EAA4B,WAAW,EAAE,MAAM,UAAU,CAAC;AACjE,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAGlE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAiBnC,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,UAAU,GAAG;IAAE,KAAK,EAAE,WAAW,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAsFnH;AAID,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,oBAAoB,EAAE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,GAAG,UAAU,CAqCtJ;AAED,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,aAAa,iBAmB/E"}
|
package/dist/mp3.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createMP3OMAFile = exports.generateMP3CodecField = void 0;
|
|
3
|
+
exports.updateMP3Metadata = exports.createMP3OMAFile = exports.generateMP3CodecField = void 0;
|
|
4
4
|
const mp3_parser_1 = require("mp3-parser");
|
|
5
5
|
const bytemanip_1 = require("./bytemanip");
|
|
6
6
|
const codecs_1 = require("./codecs");
|
|
@@ -99,6 +99,7 @@ function generateMP3CodecField(mp3Data) {
|
|
|
99
99
|
};
|
|
100
100
|
}
|
|
101
101
|
exports.generateMP3CodecField = generateMP3CodecField;
|
|
102
|
+
const METADATA_BLOCK_SIZE = 0x1000;
|
|
102
103
|
function createMP3OMAFile(index, metadata, rawFile, deviceKey, codec) {
|
|
103
104
|
// Strip all ID3 tags from the source MP3 file
|
|
104
105
|
let cursor = 0;
|
|
@@ -111,6 +112,7 @@ function createMP3OMAFile(index, metadata, rawFile, deviceKey, codec) {
|
|
|
111
112
|
}
|
|
112
113
|
// Cursor points to the start of the first MP3 frame in this file.
|
|
113
114
|
// Create the new and compliant ID3 tag set from metadata
|
|
115
|
+
// Reserve METADATA_BLOCK_SIZE bytes for metadata edits down the line
|
|
114
116
|
const rootID3 = (0, id3_1.serialize)({
|
|
115
117
|
version: { major: 3, minor: 0 },
|
|
116
118
|
flags: 0,
|
|
@@ -120,7 +122,7 @@ function createMP3OMAFile(index, metadata, rawFile, deviceKey, codec) {
|
|
|
120
122
|
{ id: 'TXXX', flags: 0, contents: (0, id3_1.encodeSonyWeirdString)("OMG_FCRCA1", " ") },
|
|
121
123
|
{ id: 'TXXX', flags: 0, contents: (0, id3_1.encodeSonyWeirdString)("OMG_TRLDA", "1982/01/01 00:00:00") },
|
|
122
124
|
],
|
|
123
|
-
});
|
|
125
|
+
}, METADATA_BLOCK_SIZE);
|
|
124
126
|
const formatHeader = (0, codecs_1.createEA3Header)(codec, 0xFFFE, 2);
|
|
125
127
|
const finalFileBuffer = new Uint8Array(rootID3.length + formatHeader.length + rawFile.length - cursor);
|
|
126
128
|
finalFileBuffer.set(rootID3, 0);
|
|
@@ -135,3 +137,24 @@ function createMP3OMAFile(index, metadata, rawFile, deviceKey, codec) {
|
|
|
135
137
|
return finalFileBuffer;
|
|
136
138
|
}
|
|
137
139
|
exports.createMP3OMAFile = createMP3OMAFile;
|
|
140
|
+
async function updateMP3Metadata(file, titleInfo) {
|
|
141
|
+
// Check if this is a valid file.
|
|
142
|
+
await file.seek(0);
|
|
143
|
+
const initialBuffer = await file.read(10);
|
|
144
|
+
const { size: ea3Size } = (0, id3_1.readInitialID3Header)(initialBuffer);
|
|
145
|
+
// The new buffer has to fit within the space reserved by the old one.
|
|
146
|
+
// We cannot shift the audio data around.
|
|
147
|
+
const newEA3 = (0, id3_1.serialize)({
|
|
148
|
+
version: { major: 3, minor: 0 },
|
|
149
|
+
flags: 0,
|
|
150
|
+
tags: [
|
|
151
|
+
...(0, id3_1.createCommonID3Tags)(titleInfo),
|
|
152
|
+
{ id: 'TXXX', flags: 0, contents: (0, id3_1.encodeSonyWeirdString)("OMG_FPRCA1", " ") },
|
|
153
|
+
{ id: 'TXXX', flags: 0, contents: (0, id3_1.encodeSonyWeirdString)("OMG_FCRCA1", " ") },
|
|
154
|
+
{ id: 'TXXX', flags: 0, contents: (0, id3_1.encodeSonyWeirdString)("OMG_TRLDA", "1982/01/01 00:00:00") },
|
|
155
|
+
],
|
|
156
|
+
}, ea3Size);
|
|
157
|
+
await file.seek(0);
|
|
158
|
+
await file.write(newEA3);
|
|
159
|
+
}
|
|
160
|
+
exports.updateMP3Metadata = updateMP3Metadata;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "networkwm-js",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2-alpha.0",
|
|
4
4
|
"description": "A library which lets you manage tracks and metadata on Sony Network Walkmen.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -37,11 +37,11 @@
|
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@originjs/crypto-js-wasm": "github:asivery/crypto-js-wasm",
|
|
39
39
|
"async-mutex": "^0.4.0",
|
|
40
|
-
"himd-js": "^0.2.
|
|
40
|
+
"himd-js": "^0.2.1",
|
|
41
41
|
"mp3-parser": "^0.3.0",
|
|
42
42
|
"node-id3": "^0.2.5",
|
|
43
43
|
"node-mass-storage": "^0.2.2",
|
|
44
|
-
"nufatfs": "^0.1.
|
|
44
|
+
"nufatfs": "^0.1.9",
|
|
45
45
|
"usb": "^2.4.1"
|
|
46
46
|
}
|
|
47
47
|
}
|
package/dist/test.d.ts
DELETED
package/dist/test.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"test.d.ts","sourceRoot":"","sources":["../src/test.ts"],"names":[],"mappings":""}
|
package/dist/test.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const codecs_1 = require("./codecs");
|
|
4
|
-
// (async () => {
|
|
5
|
-
// const data = new Uint8Array(fs.readFileSync("/ram/10000001.OMA"));
|
|
6
|
-
// const id3 = parse(data);
|
|
7
|
-
// console.log(id3);
|
|
8
|
-
// for(let tag of id3.tags) {
|
|
9
|
-
// fs.writeFileSync(`/ram/tag-${tag.id}`, tag.contents);
|
|
10
|
-
// }
|
|
11
|
-
// })();
|
|
12
|
-
// import { } from 'himd-js';
|
|
13
|
-
// import { createEA3Header } from './utils';
|
|
14
|
-
// (async () => {
|
|
15
|
-
// const header = createEA3Header({ })
|
|
16
|
-
// })
|
|
17
|
-
// const data = new Uint8Array(fs.readFileSync("/ram/10000007.OMA"));
|
|
18
|
-
// let trackKey;
|
|
19
|
-
// console.log(trackKey = deriveMP3TrackKey(data, console.log));
|
|
20
|
-
// console.log(deriveDeviceKey(trackKey, 0x07));
|
|
21
|
-
(async () => {
|
|
22
|
-
// const device = await openNewDeviceNode();
|
|
23
|
-
// initCrypto();
|
|
24
|
-
// importKeys(new Uint8Array(nfs.readFileSync("EKBROOTS.DES")));
|
|
25
|
-
// if(!device) {
|
|
26
|
-
// console.log("No device");
|
|
27
|
-
// return;
|
|
28
|
-
// }
|
|
29
|
-
// console.log(`Connected to ${device.definition.name}`);
|
|
30
|
-
// const fs = await createNWJSFS(device);
|
|
31
|
-
// const database = await DatabaseAbstraction.create(fs, device.definition);
|
|
32
|
-
// const session = new UMSCNWJSSession(fs.driver, fs);
|
|
33
|
-
// await session.performAuthorization();
|
|
34
|
-
// const trackNames = (JSON.parse(nfs.readFileSync("/mnt/NAS/Code/ALT_SS_STAGE/Putting the 9 hour mix on the MD/titlesv2/tracknames.json").toString()) as [string, string][]).map(e => e[1]);
|
|
35
|
-
// const BASE_LOC = "/mnt/NAS/Code/ALT_SS_STAGE/Putting the 9 hour mix on the MD/tracks/";
|
|
36
|
-
// for(let i = 1; i<180; i++){
|
|
37
|
-
// let file = `${BASE_LOC}/${i + 1}.wav`;
|
|
38
|
-
// const contents = new Uint8Array(nfs.readFileSync(file)).subarray(76);
|
|
39
|
-
// await uploadTrack(database, session, {
|
|
40
|
-
// album: "The Ultimate S3RL Tribute Mix 2023",
|
|
41
|
-
// artist: "S3RL",
|
|
42
|
-
// genre: "Happy Hardcore",
|
|
43
|
-
// title: trackNames[i],
|
|
44
|
-
// trackDuration: -1,
|
|
45
|
-
// trackNumber: -1,
|
|
46
|
-
// }, generateCodecInfo("AT3", HiMDKBPSToFrameSize.atrac3[66]), contents, console.log);
|
|
47
|
-
// console.log(`Finished uploading ${i + 1} / 180`);
|
|
48
|
-
// }
|
|
49
|
-
// await session.finalizeSession();
|
|
50
|
-
// await database.flushUpdates();
|
|
51
|
-
// await fs.fatfs!.flushMetadataChanges();
|
|
52
|
-
// console.log(await fs.list("/OMGAUDIO"));
|
|
53
|
-
// const session = new UMSCNWJSSession(fs.driver, fs);
|
|
54
|
-
// await session.performAuthorization();
|
|
55
|
-
// await database.uploadTrack({
|
|
56
|
-
// album: 'Singles',
|
|
57
|
-
// artist: 'cy4ne',
|
|
58
|
-
// genre: 'Scenecore',
|
|
59
|
-
// title: 'solace',
|
|
60
|
-
// trackNumber: -1,
|
|
61
|
-
// }, generateCodecInfo('A3+', HiMDKBPSToFrameSize.atrac3plus[256]), new Uint8Array(nfs.readFileSync("/ram/solace.raw.at3p")), session);
|
|
62
|
-
// await session.finalizeSession();
|
|
63
|
-
// await database.flushUpdates();
|
|
64
|
-
// await fs.fatfs!.flushMetadataChanges();
|
|
65
|
-
const nwCodec = {
|
|
66
|
-
codecId: codecs_1.NWCodec.MP3,
|
|
67
|
-
codecInfo: new Uint8Array([0x80, 0xdd, 0x10]),
|
|
68
|
-
};
|
|
69
|
-
console.log((0, codecs_1.getKBPS)(nwCodec));
|
|
70
|
-
})().then(() => process.exit(0));
|