{"id":22532087,"url":"https://github.com/subframe7536/node-taglib-sharp-extend","last_synced_at":"2025-04-09T17:02:28.829Z","repository":{"id":226889974,"uuid":"769894129","full_name":"subframe7536/node-taglib-sharp-extend","owner":"subframe7536","description":"Read / Write music file metadata of various formats in Nodejs / Browser","archived":false,"fork":false,"pushed_at":"2025-02-05T02:13:05.000Z","size":13754,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-09T17:02:14.281Z","etag":null,"topics":["flac","m4a","metadata","mp3","taglib","wav"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/subframe7536.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-03-10T11:18:46.000Z","updated_at":"2025-02-05T02:13:08.000Z","dependencies_parsed_at":"2024-06-03T03:47:30.144Z","dependency_job_id":"deb4e7c4-a4e8-4c72-b795-ea86da63d86c","html_url":"https://github.com/subframe7536/node-taglib-sharp-extend","commit_stats":null,"previous_names":["subframe7536/node-taglib-sharp-extend"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/subframe7536%2Fnode-taglib-sharp-extend","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/subframe7536%2Fnode-taglib-sharp-extend/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/subframe7536%2Fnode-taglib-sharp-extend/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/subframe7536%2Fnode-taglib-sharp-extend/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/subframe7536","download_url":"https://codeload.github.com/subframe7536/node-taglib-sharp-extend/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248074966,"owners_count":21043490,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["flac","m4a","metadata","mp3","taglib","wav"],"created_at":"2024-12-07T08:10:15.170Z","updated_at":"2025-04-09T17:02:28.823Z","avatar_url":"https://github.com/subframe7536.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# node-taglib-sharp-extend\n\nPatch [node-taglib-sharp](https://github.com/benrr101/node-taglib-sharp) with:\n\n- Some utils with corrected types, narrow exports\n- Read / Write support for file in buffer, detach `createFromPath` in `File`\n- Fresh dependencies and reduce `Node` dependencies\n- Provide `Vite` plugin for webapp\n\nBackup your file!\n\nKnown issue:\n- ~~`m4a` maybe corrupt after writing, see [original issue](https://github.com/benrr101/node-taglib-sharp/issues/103#issuecomment-1987243846)~~ Seems be solved, see [original PR](https://github.com/benrr101/node-taglib-sharp/pull/108)\n\n## Install\n\n```shell\nnpm install node-taglib-sharp-extend\n```\n```shell\nyarn add node-taglib-sharp-extend\n```\n```shell\npnpm add node-taglib-sharp-extend\n```\n\n## Usage\n\n```ts\nimport { createFileFromBuffer, createFileFromPath } from 'node-taglib-sharp-extend'\n\nconst localFile = await createFileFromPath('./samples/test.mp3')\nconst file = await createFileFromBuffer('test.mp3', buffer)\n```\n\n### Utils\n\n```ts\nimport {\n  flushFile,\n  getBufferFromFile,\n  getFileFromBuffer,\n  getPictureBase64,\n  getPictureURL,\n  parseMetadata,\n  updatePicture,\n  updateTag\n} from 'node-taglib-sharp-extend'\n\nlet file = getFileFromBuffer('test.mp3', buffer)\n\nconst { tag, property, pictures, quality, unwritableReason } = parseMetadata(\n  file,\n  arr =\u003e arr.flatMap(a =\u003e a.split('; ')).join('')\n)\n\nupdateTag(file, 'title', 'test')\nupdatePicture(file, buffer)\n\n// if `File` is created from buffer and corrupt after flushing, throw `CorruptError`\nfile = flushFile(file)\nconsole.log('file size:', getBufferFromFile(file).length)\n\n// browser only\nconst [url, clean] = getPictureURL(pictures[0])\nconsole.log(url)\nclean()\n\nconst base64 = await getPictureBase64(pictures[0])\n```\n\n#### Types\n\n```ts\nexport type IAudioTag\u003cT extends string | string[] = string[]\u003e = Partial\u003c{\n  title: string\n  artists: T\n  album: string\n  track: number\n  trackTotal: number\n  disk: number\n  diskTotal: number\n  year: number\n  genres: T\n  albumArtists: T\n  composers: T\n  comment: string\n  lyrics: string\n}\u003e\n\nexport type IAudioProperty = {\n  bitRate: number\n  bitsPerSample: number\n  sampleRate: number\n  duration: number\n  channels: number\n  codecs: ICodec[]\n}\n\nexport type AudioQualityType = 'HQ' | 'Hi-Res' | 'SQ'\n\nexport type Metadata\u003cT extends string | string[] = string[]\u003e = {\n  tag: IAudioTag\u003cT\u003e\n  property: IAudioProperty\n  quality: AudioQualityType\n  pictures?: IParsedPicture[]\n}\n```\n\nmore utils are documented by JSDoc\n\n### Run in browser\n\nif you want to run it in webapp, you need to do some polyfills for node modules\n\ntotal size: ~250KB (minified + gzip)\n\n#### Polyfills\n\nthere is a built-in vite plugin for polyfill, and please ensure that [`vite-plugin-node-polyfills`](https://github.com/davidmyersdev/vite-plugin-node-polyfills) is installed\n\nwhen dev,\ndefault includes: `['buffer', 'string_decoder', 'stream', 'crypto', 'fs', 'util']`\n\nwhen build,\ndefault includes: `['buffer', 'string_decoder']`,\nother modules are manually transformed by the plugin\n\nvite config:\n```ts\nimport { polyfillTaglib } from 'node-taglib-sharp-extend/vite'\nimport { defineConfig } from 'vite'\n\nexport default defineConfig({\n  plugins: [\n    polyfillTaglib(/* options */),\n  ],\n})\n```\n\n#### Manual Chunks\n\nBuilt-in `manualChunks` config, split into 2 vendors: `iconv` and `taglib`\n\n```ts\nimport { taglibManualChunksConfig } from 'node-taglib-sharp-extend/vite'\nimport { defineConfig } from 'vite'\n\nexport default defineConfig({\n  build: {\n    rollupOptions: {\n      output: {\n        manualChunks: taglibManualChunksConfig\n      }\n    }\n  }\n})\n```\n\n#### Web Worker support check\n\nMatroska / WebM use `node:crypto.randomFillSync()` to generate random array, it is polyfilled to `crypto.getRandomValues`.\n\nyou can use built-in function to check if support in Web Worker:\n\n```ts\nimport { checkWebWorkerSupport } from 'node-taglib-sharp-extend'\n\n// you can run in main thread or worker thread\nif (await checkWebWorkerSupport()) {\n  // ...\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsubframe7536%2Fnode-taglib-sharp-extend","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsubframe7536%2Fnode-taglib-sharp-extend","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsubframe7536%2Fnode-taglib-sharp-extend/lists"}