ncm-decrypt
v0.0.4
Published
A simple ESM-only Node.js library for decrypting `.ncm` music files.
Readme
ncm-decrypt
A simple ESM-only Node.js library for decrypting .ncm music files.
Note: This library is ESM-only and can only be used in Node.js environments. It is not compatible with browsers or CommonJS.
Features
- Decrypts
.ncmformat used by NetEase Cloud Music - Extracts metadata such as title, artist, album, and cover art
- Supports multiple output types: Buffer, Blob, Data URL, etc.
Installation
npm install ncm-decryptUsage
import fs from "node:fs/promises"
import { decrypt } from "ncm-decrypt"
const buffer = await fs.readFile("./song.ncm")
const result = await decrypt(buffer, "song.ncm")
console.log(result)API
decrypt(buffer: Buffer | ArrayBuffer, filename: string): Promise<DecryptResult>
Decrypts a .ncm file and returns a DecryptResult object.
Parameters
buffer: The file contents as aBufferorArrayBufferfilename: The original file name (used to infer file extension if needed)
Returns
A Promise that resolves to a DecryptResult object.
DecryptResult Interface
export interface DecryptResult {
title: string
album?: string
artist?: string
mime: string
ext: string
file: string
blob: Blob | ArrayBuffer
picture?: string
message?: string
rawExt?: string
rawFilename?: string
buffer?: ArrayBuffer
src?: string
}Example Output
{
"title": "Sample Song",
"artist": "Sample Artist",
"album": "Sample Album",
"mime": "audio/mpeg",
"ext": "mp3",
"file": "Sample Song.mp3",
"blob": {},
"picture": "data:image/jpeg;base64,...",
"message": "Successfully decrypted",
"buffer": {},
"src": "data:audio/mpeg;base64,..."
}License
MIT
