0.0.16 • Published 5 years ago

hlx-file-writer v0.0.16

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

Build Status Coverage Status Dependency Status Development Dependency Status Known Vulnerabilities XO code style

hlx-file-writer

A writable stream to save HLS playlists/segments as local files

Features

  • Being used with other hlx objects, it provides a functionality to write every HLS related data (playlist and segments) to your local filesystem.
  • It determines the local path for each files based on the uri described in the HLS playlist.
  • The hostname contained in the uri will be ignored (e.g. "https://foo.bar/abc/def.m3u8" is translated into "{outputDir}/abc/def.m3u8")
  • If the uri is a file url, users can specify a root directory (inputDir) from which the file should be read (e.g. "file://path/to/abc/def.m3u8", inputDir="/path/to", is translated into "{outputDir}/abc/def.m3u8")

Install

NPM

Usage

const {createReadStream} = require('hlx-file-reader');
const {createUrlRewriter} = require('hlx-url-rewriter');
const {createWriteStream} = require('hlx-file-writer'); // file-writer
const {createTerminator} = require('hlx-terminator')

const src = createReadStream('https://foo.bar/sample.m3u8');
const rewrite = createUrlRewriter();
const save = createWriteStream({
  outputDir: '/var/www/media/',
  storePlaylist: true
});
const dest = createTerminator();

// Write all playlists/segments to your local filesystem
src.pipe(rewrite).pipe(save).pipe(dest)
.on('error', err => {
  console.log(err.stack);
});

API

The features are built on top of the Node's transform streams.

createWriteStream([options])

Creates a new TransformStream object.

params

NameTypeRequiredDefaultDescription
optionsobjectNo{}See below

options

NameTypeDefaultDescription
inputDirstring/The root directory from which all the files are read (This option is only used in case of file urls)
outputDirstringprocess.CWD()The root directory to which all the files are written
storePlaylistbooleanfalseIf true, the playlist files are also stored as local files

return value

An instance of TransformStream.

0.0.16

5 years ago

0.0.15

5 years ago

0.0.14

5 years ago

0.0.13

5 years ago

0.0.12

5 years ago

0.0.11

5 years ago

0.0.10

5 years ago

0.0.9

5 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago