NZB File
A library to download files from NZB files using multiple connections. Supports streaming.
Files follow the W3C spec for File objects.
Installation
npm install nzb-file
Usage
const { files, pool } = await fromNZB(
await readFile('file.nzb', { encoding: 'utf-8' }),
'example.domain.news.com',
119,
'login',
'password',
'alt.binaries.things',
20
)
const biggest = files.reduce((a, b) => (a.size > b.size ? a : b))
const sub = biggest.slice(0, 50 * 1024 * 1024)
const data = await sub.arrayBuffer()
const stream = file.stream()
const slices = [
biggest.slice(0, 10 * 1024 * 1024),
biggest.slice(10 * 1024 * 1024, 20 * 1024 * 1024),
biggest.slice(20 * 1024 * 1024)
]
const allData = slices.map(s => s.arrayBuffer())
await Promise.all(allData)
import { Readable } from 'node:stream'
import { createWriteStream } from 'node:fs'
const readable = Readable.from(biggest)
readable.pipe(createWriteStream('output.file'))
pool.destroy()