metadata-connect 1.1.2 → 1.1.3
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/extract.d.ts +10 -1
- package/dist/extract.d.ts.map +1 -1
- package/dist/extract.js +16 -4
- package/dist/extract.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/types/logger.d.ts +13 -0
- package/dist/types/logger.d.ts.map +1 -0
- package/dist/types/logger.js +12 -0
- package/dist/types/logger.js.map +1 -0
- package/package.json +1 -1
package/dist/extract.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ExtractedMetadata, FileReader, MetadataParser } from './types.js';
|
|
2
|
+
import type { Logger } from './types/logger.js';
|
|
2
3
|
/**
|
|
3
4
|
* Get the appropriate parser for a file extension
|
|
4
5
|
*/
|
|
@@ -11,10 +12,18 @@ export declare function getSupportedExtensions(): string[];
|
|
|
11
12
|
* Check if a file extension is supported
|
|
12
13
|
*/
|
|
13
14
|
export declare function isExtensionSupported(extension: string): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Options for extractMetadata
|
|
17
|
+
*/
|
|
18
|
+
export interface ExtractMetadataOptions {
|
|
19
|
+
/** Optional logger instance. If omitted, logging is silently disabled. */
|
|
20
|
+
logger?: Logger;
|
|
21
|
+
}
|
|
14
22
|
/**
|
|
15
23
|
* Extract metadata from an audio file using the appropriate parser
|
|
16
24
|
*
|
|
17
25
|
* @param reader - FileReader interface for reading file data
|
|
26
|
+
* @param options - Optional configuration including logger
|
|
18
27
|
* @returns Extracted metadata, or null if extraction fails or format is unsupported
|
|
19
28
|
*
|
|
20
29
|
* @example
|
|
@@ -32,5 +41,5 @@ export declare function isExtensionSupported(extension: string): boolean;
|
|
|
32
41
|
* }
|
|
33
42
|
* ```
|
|
34
43
|
*/
|
|
35
|
-
export declare function extractMetadata(reader: FileReader): Promise<ExtractedMetadata | null>;
|
|
44
|
+
export declare function extractMetadata(reader: FileReader, options?: ExtractMetadataOptions): Promise<ExtractedMetadata | null>;
|
|
36
45
|
//# sourceMappingURL=extract.d.ts.map
|
package/dist/extract.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extract.d.ts","sourceRoot":"","sources":["../src/extract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"extract.d.ts","sourceRoot":"","sources":["../src/extract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAChF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AA8BhD;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI,CAG9E;AAED;;GAEG;AACH,wBAAgB,sBAAsB,IAAI,MAAM,EAAE,CAEjD;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAE/D;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,0EAA0E;IAC1E,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,UAAU,EAClB,OAAO,CAAC,EAAE,sBAAsB,GAC/B,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAsBnC"}
|
package/dist/extract.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { noopLogger } from './types/logger.js';
|
|
1
2
|
import { extractFromMp3 } from './parsers/id3.js';
|
|
2
3
|
import { extractFromMp4 } from './parsers/mp4.js';
|
|
3
4
|
import { extractFromFlac } from './parsers/flac.js';
|
|
@@ -44,6 +45,7 @@ export function isExtensionSupported(extension) {
|
|
|
44
45
|
* Extract metadata from an audio file using the appropriate parser
|
|
45
46
|
*
|
|
46
47
|
* @param reader - FileReader interface for reading file data
|
|
48
|
+
* @param options - Optional configuration including logger
|
|
47
49
|
* @returns Extracted metadata, or null if extraction fails or format is unsupported
|
|
48
50
|
*
|
|
49
51
|
* @example
|
|
@@ -61,16 +63,26 @@ export function isExtensionSupported(extension) {
|
|
|
61
63
|
* }
|
|
62
64
|
* ```
|
|
63
65
|
*/
|
|
64
|
-
export async function extractMetadata(reader) {
|
|
66
|
+
export async function extractMetadata(reader, options) {
|
|
67
|
+
const logger = options?.logger ?? noopLogger;
|
|
65
68
|
const parser = getParserForExtension(reader.extension);
|
|
66
69
|
if (!parser) {
|
|
70
|
+
logger.debug('No parser found for extension: %s', reader.extension);
|
|
67
71
|
return null;
|
|
68
72
|
}
|
|
69
73
|
try {
|
|
70
|
-
|
|
74
|
+
logger.debug('Extracting metadata from %s file (%d bytes)', reader.extension, reader.size);
|
|
75
|
+
const result = await parser(reader);
|
|
76
|
+
if (result) {
|
|
77
|
+
logger.debug('Extracted metadata: title=%s, artist=%s', result.title ?? '(none)', result.artist ?? '(none)');
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
logger.debug('Parser returned null for %s file', reader.extension);
|
|
81
|
+
}
|
|
82
|
+
return result;
|
|
71
83
|
}
|
|
72
|
-
catch {
|
|
73
|
-
|
|
84
|
+
catch (err) {
|
|
85
|
+
logger.warn('Failed to extract metadata from %s file: %s', reader.extension, err);
|
|
74
86
|
return null;
|
|
75
87
|
}
|
|
76
88
|
}
|
package/dist/extract.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extract.js","sourceRoot":"","sources":["../src/extract.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"extract.js","sourceRoot":"","sources":["../src/extract.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,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C,CAAC;IAEvD,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,CAAC,KAAK,CAAC,mCAAmC,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC;QACpE,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,CAAC;QACH,MAAM,CAAC,KAAK,CAAC,6CAA6C,EAAE,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;QAC3F,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,CAAC;QACpC,IAAI,MAAM,EAAE,CAAC;YACX,MAAM,CAAC,KAAK,CAAC,yCAAyC,EAAE,MAAM,CAAC,KAAK,IAAI,QAAQ,EAAE,MAAM,CAAC,MAAM,IAAI,QAAQ,CAAC,CAAC;QAC/G,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,KAAK,CAAC,kCAAkC,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC;QACrE,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,CAAC,IAAI,CAAC,6CAA6C,EAAE,MAAM,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;QAClF,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
export { extractMetadata, getParserForExtension, getSupportedExtensions, isExtensionSupported, } from './extract.js';
|
|
2
|
+
export type { ExtractMetadataOptions } from './extract.js';
|
|
2
3
|
export type { FileReader, ExtractedMetadata, ArtworkMimeType, MetadataParser, } from './types.js';
|
|
3
4
|
export { PictureType } from './types.js';
|
|
5
|
+
export type { Logger } from './types/logger.js';
|
|
6
|
+
export { noopLogger } from './types/logger.js';
|
|
4
7
|
export { createBufferReader } from './reader.js';
|
|
5
8
|
export { extractFromMp3, extractFromMp4, extractFromFlac, extractFromAiff, detectImageType, normalizeMimeType, } from './parsers/index.js';
|
|
6
9
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,sBAAsB,EACtB,oBAAoB,GACrB,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,sBAAsB,EACtB,oBAAoB,GACrB,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAG3D,YAAY,EACV,UAAU,EACV,iBAAiB,EACjB,eAAe,EACf,cAAc,GACf,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAGzC,YAAY,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAG/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAGjD,OAAO,EACL,cAAc,EACd,cAAc,EACd,eAAe,EACf,eAAe,EACf,eAAe,EACf,iBAAiB,GAClB,MAAM,oBAAoB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Main extraction function
|
|
2
2
|
export { extractMetadata, getParserForExtension, getSupportedExtensions, isExtensionSupported, } from './extract.js';
|
|
3
3
|
export { PictureType } from './types.js';
|
|
4
|
+
export { noopLogger } from './types/logger.js';
|
|
4
5
|
// Reader utilities
|
|
5
6
|
export { createBufferReader } from './reader.js';
|
|
6
7
|
// Individual parsers (for advanced use cases)
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,2BAA2B;AAC3B,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,sBAAsB,EACtB,oBAAoB,GACrB,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,2BAA2B;AAC3B,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,sBAAsB,EACtB,oBAAoB,GACrB,MAAM,cAAc,CAAC;AAUtB,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAIzC,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,mBAAmB;AACnB,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjD,8CAA8C;AAC9C,OAAO,EACL,cAAc,EACd,cAAc,EACd,eAAe,EACf,eAAe,EACf,eAAe,EACf,iBAAiB,GAClB,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Logger interface for metadata-connect.
|
|
3
|
+
* Allows consumers to inject their own logger implementation.
|
|
4
|
+
*/
|
|
5
|
+
export interface Logger {
|
|
6
|
+
trace(msg: string, ...args: unknown[]): void;
|
|
7
|
+
debug(msg: string, ...args: unknown[]): void;
|
|
8
|
+
info(msg: string, ...args: unknown[]): void;
|
|
9
|
+
warn(msg: string, ...args: unknown[]): void;
|
|
10
|
+
error(msg: string, ...args: unknown[]): void;
|
|
11
|
+
}
|
|
12
|
+
export declare const noopLogger: Logger;
|
|
13
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/types/logger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,MAAM;IACrB,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAC7C,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAC7C,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAC5C,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAC5C,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;CAC9C;AAED,eAAO,MAAM,UAAU,EAAE,MAMxB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Logger interface for metadata-connect.
|
|
3
|
+
* Allows consumers to inject their own logger implementation.
|
|
4
|
+
*/
|
|
5
|
+
export const noopLogger = {
|
|
6
|
+
trace() { },
|
|
7
|
+
debug() { },
|
|
8
|
+
info() { },
|
|
9
|
+
warn() { },
|
|
10
|
+
error() { },
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/types/logger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAUH,MAAM,CAAC,MAAM,UAAU,GAAW;IAChC,KAAK,KAAI,CAAC;IACV,KAAK,KAAI,CAAC;IACV,IAAI,KAAI,CAAC;IACT,IAAI,KAAI,CAAC;IACT,KAAK,KAAI,CAAC;CACX,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "metadata-connect",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"description": "Extract audio metadata (title, artist, album, BPM, key, artwork) from MP3, M4A, FLAC, and AIFF files with minimal network transfer using partial file reads",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|