Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-id3

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-id3 - npm Package Compare versions

Comparing version 0.2.1 to 0.2.2

14

CHANGELOG.md
# Changelog
## [0.2.2] - 2020-01-01
### Fixed
- Bug in iTunes where artwork doesn't show up when description is empty
- Creating tags with undefined, terminated UTF-16 value now passes FF FE 00 00 instead of 00 00
- Add raw to TypeScript definition
- Add removeTags async to TypeScript definition
### Added
- Added options to update
## [0.2.1] - 2020-10-30

@@ -190,3 +201,4 @@

[unreleased]: https://github.com/Zazama/node-id3/compare/0.2.1...HEAD
[unreleased]: https://github.com/Zazama/node-id3/compare/0.2.2...HEAD
[0.2.2]: https://github.com/Zazama/node-id3/compare/0.2.1...0.2.2
[0.2.1]: https://github.com/Zazama/node-id3/compare/0.2.0...0.2.1

@@ -193,0 +205,0 @@ [0.2.0]: https://github.com/Zazama/node-id3/compare/0.1.21...0.2.0

11

index.d.ts

@@ -337,3 +337,4 @@ declare module "node-id3" {

url: string
}>
}>,
raw?: Tags
}

@@ -350,6 +351,10 @@ export function write(tags: Tags, filebuffer: Buffer): Buffer

export function read(filebuffer: string | Buffer, options: Object, fn: (err: NodeJS.ErrnoException | null, tags: Tags | null) => void): void
export function update(tags: Tags, filebuffer: Buffer): Buffer
export function update(tags: Tags, filepath: string): true | Error
export function update(tags: Tags, filebuffer: Buffer, options?: Object): Buffer
export function update(tags: Tags, filepath: string, options?: Object): true | Error
export function update(tags: Tags, filepath: string, fn: (err: NodeJS.ErrnoException | Error | null) => void): void
export function update(tags: Tags, filepath: string, options: Object, fn: (err: NodeJS.ErrnoException | Error | null) => void): void
export function update(tags: Tags, filebuffer: Buffer, fn: (err: NodeJS.ErrnoException | null, buffer?: Buffer) => void): void
export function update(tags: Tags, filebuffer: Buffer, options: Object, fn: (err: NodeJS.ErrnoException | null, buffer?: Buffer) => void): void
export function removeTags(filepath: string): true | Error
export function removeTags(filepath: string, fn: (err: NodeJS.ErrnoException | Error | null) => void): void
export const Promise: {

@@ -356,0 +361,0 @@ write(tags: Tags, filebuffer: Buffer) : Promise<Buffer>,

@@ -188,6 +188,12 @@ const fs = require('fs')

* @param filebuffer - Can contain a filepath string or buffer
* @param options - (optional) Object containing options
* @param fn - (optional) Function for async version
* @returns {boolean|Buffer|Error}
*/
module.exports.update = function(tags, filebuffer, fn) {
module.exports.update = function(tags, filebuffer, options, fn) {
if(!options || typeof options === 'function') {
fn = fn || options
options = {}
}
const rawTags = Object.keys(tags).reduce((acc, val) => {

@@ -232,6 +238,6 @@ if(ID3Definitions.FRAME_IDENTIFIERS.v3[val] !== undefined) {

if(!fn || typeof fn !== 'function') {
return this.write(updateFn(this.read(filebuffer)), filebuffer)
return this.write(updateFn(this.read(filebuffer, options)), filebuffer)
} else {
this.read(filebuffer, (err, currentTags) => {
this.write(updateFn(this.read(filebuffer)), filebuffer, fn)
this.write(updateFn(this.read(filebuffer, options)), filebuffer, fn)
})

@@ -238,0 +244,0 @@ }

{
"name": "node-id3",
"version": "0.2.1",
"version": "0.2.2",
"description": "Pure JavaScript ID3v2 Tag writer and reader",

@@ -5,0 +5,0 @@ "author": "Jan Metzger <jan.metzger@gmx.net>",

@@ -17,3 +17,3 @@ # node-id3

const filebuffer = new Buffer("Some Buffer of a (mp3) file")
const filebuffer = Buffer.from("Some Buffer of a (mp3) file")
const filepath = './path/to/(mp3)file'

@@ -51,2 +51,13 @@

NodeID3.update(tags, filebuffer, function(err, buffer) { })
// Possible options
const options = {
include: ['TALB', 'TIT2'], // only read the specified tags (default: all)
exclude: ['APIC'] // don't read the specified tags (default: [])
}
NodeID3.update(tags, filepath, options)
const success = NodeID3.update(tags, filebuffer, options)
NodeID3.update(tags, filepath, options, function(err, buffer) { })
NodeID3.update(tags, filebuffer, options, function(err, buffer) { })
```

@@ -53,0 +64,0 @@

@@ -28,2 +28,3 @@ module.exports = ID3FrameBuilder

ID3FrameBuilder.prototype.appendNullTerminatedValue = function(value, encoding = 0x00) {
if(!value) value = ''
const convertedValue = convertValue(value, encoding)

@@ -30,0 +31,0 @@ this._buffer = Buffer.concat([this._buffer, nullTerminatedValueToBuffer(convertedValue, encoding)])

@@ -66,9 +66,15 @@ const fs = require('fs')

/*
* Fix a bug in iTunes where the artwork is not recognized when the description is empty using UTF-16.
* Instead, if the description is empty, use encoding 0x00 (ISO-8859-1).
*/
const { description = '' } = data;
const encoding = description ? 0x01 : 0x00
return new ID3FrameBuilder("APIC")
.appendStaticNumber(0x01, 1)
.appendNullTerminatedValue(mime_type)
.appendStaticNumber(0x03, 1)
.appendNullTerminatedValue(data.description, 0x01)
.appendStaticValue(data.imageBuffer)
.getBuffer()
.appendStaticNumber(encoding, 1)
.appendNullTerminatedValue(mime_type)
.appendStaticNumber(0x03, 1)
.appendNullTerminatedValue(description, encoding)
.appendStaticValue(data.imageBuffer)
.getBuffer()
} catch(e) {

@@ -75,0 +81,0 @@ return e

@@ -164,2 +164,7 @@ const NodeID3 = require('../index.js')

), 0)
// iTunes fix if description is empty
assert.strictEqual(NodeID3.create({
image: fs.readFileSync(__dirname + '/smallimg')
})[20], 0x00)
})

@@ -676,2 +681,3 @@

language: 'e33',
shortText: 'asd物f',
text: 'asd物f asd物f asd物f'

@@ -775,3 +781,3 @@ },

assert.deepStrictEqual({ language: tags.COMM.data.language, shortText: tags.COMM.data.short_description, text: parseInt(tags.COMM.data.text) }, nodeTagsFull.comment)
assert.deepStrictEqual({ language: tags.USLT.data.language, text: tags.USLT.data.lyrics }, nodeTagsFull.unsynchronisedLyrics)
assert.deepStrictEqual({ language: tags.USLT.data.language, shortText: tags.USLT.data.descriptor, text: tags.USLT.data.lyrics }, nodeTagsFull.unsynchronisedLyrics)
expect(tags.TXXX.map((t) => {

@@ -873,3 +879,3 @@ return {

read.private[0].data = read.private[0].data.toString()
if(read.unsynchronisedLyrics.shortText === undefined) delete read.unsynchronisedLyrics.shortText
if(!read.unsynchronisedLyrics.shortText) delete read.unsynchronisedLyrics.shortText
assert.deepStrictEqual(nodeTagsFull, read)

@@ -886,4 +892,4 @@ })

read.comment.text = parseInt(read.comment.text)
if(read.comment.shortText === undefined) delete read.comment.shortText
if(read.image.description === undefined) delete read.image.description
if(!read.comment.shortText) delete read.comment.shortText
if(!read.image.description) delete read.image.description
delete read.image.type

@@ -899,4 +905,4 @@ assert.strictEqual(read.popularimeter.rating, 0)

delete read.tableOfContents[0].isOrdered
if(read.userDefinedText[0].description === undefined) delete read.userDefinedText[0].description
if(read.userDefinedText[1].description === undefined) delete read.userDefinedText[1].description
if(!read.userDefinedText[0].description) delete read.userDefinedText[0].description
if(!read.userDefinedText[1].description) delete read.userDefinedText[1].description
assert.deepStrictEqual(nodeTagsMissingValues, read)

@@ -903,0 +909,0 @@ })

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc