HLSDownloader. Downloader

Main donwloader class of HLSDownloader Package

Constructor

new Downloader(downloderOptions)

Parameters:
NameTypeDescription
downloderOptionsobject

Options to build downloader

Properties
NameTypeAttributesDefaultDescription
playlistURLstring

Playlist URL to download

concurrencynumber<optional>
1

concurrency limit to download playlist chunk

destinationobject<optional>
''

Absolute path to download

onDataobject | function<optional>
null

onData hook

onErrorobject | function<optional>
null

onError hook

overwriteboolean<optional>
false

Overwrite files toggler

optionsobject<optional>
{}

Options to override from Ky

Author
  • Nur Rony<pro.nmrony@gmail.com>
Throws:
  • TypeError

  • ProtocolNotSupported

Members

concurrency :number

Concurrency limit to download items

Type:
  • number
Default Value
  • 1

defaultKyOptions :object

Default Ky options values set by HLSDownloader

Type:
  • object
Default Value
  • {
      retry: { limit: 0 }
    }
    

destination :string

Absolute path to download the TS files with corresponding playlist file

Type:
  • string
Default Value
  • ''

errors :Array.<{url: string, name: string, message: string}>

items that are not downloaded successfully

Type:
  • Array.<{url: string, name: string, message: string}>

items :Array.<string>

items that are downloaded successfully

Type:
  • Array.<string>

kyOptions :object

Extra options to pass into Ky

Type:
  • object
Default Value
  • {}

onData :function|null

Function to track downloaded data

Type:
  • function | null
Default Value
  • null

onError :function|null

Function to track error

Type:
  • function | null
Default Value
  • null

overwrite :boolean

concurrency controller

Type:
  • boolean
Default Value
  • false

playlistURL :string

Playlist URL to download

Type:
  • string
Default Value
  • ''

pool :object

concurrency controller

Type:
  • object
Default Value
  • 1

unSupportedOptions :Array.<string>

Type:
  • Array.<string>
Default Value
  • [
     'uri',
     'url',
     'json',
     'form',
     'body',
     'method',
     'setHost',
     'isStream',
     'parseJson',
     'prefixUrl',
     'cookieJar',
     'playlistURL',
     'concurrency',
     'allowGetBody',
     'stringifyJson',
     'methodRewriting'
    ]
    

Methods

(async) createDirectory(url) → {Promise.<string>}

create directory to download

Parameters:
NameTypeDescription
urlstring

url to construct the path from

Returns:

destination path

Type: 
Promise.<string>

(async) downloadItem(item) → {Promise.<any>}

Download each iteam

Parameters:
NameTypeDescription
itemstring

item to download

Returns:
Type: 
Promise.<any>

(async) downloadItems() → {Promise.<any>}

Download playlist and items

Returns:
Type: 
Promise.<any>

(async) fetchItems() → {Promise.<any>}

Fetch playlist items

Returns:
Type: 
Promise.<any>

(async) fetchPlaylist() → {Promise.<{url, body}>}

fetch playlist content

Returns:
Type: 
Promise.<{url, body}>

formatPlaylistContent(playlistContentResults) → {Array.<{url: string, body: string}>}

filter playlist contents

Parameters:
NameTypeDescription
playlistContentResultsArray.<object>

list of fetched playlist content

Returns:

list of object containing url and its content

Type: 
Array.<{url: string, body: string}>

mergeOptions(options) → {object}

merge options

Parameters:
NameTypeDescription
optionsobject
Returns:
Type: 
object

parsePlaylist(playlistContent)

Parse playlist content and index the TS chunk to download.

Parameters:
NameTypeDescription
playlistContentstring
Returns:

string[] Array of url

(async) processPlaylistItems() → {Promise.<any>}

Process playlist items

Returns:
Type: 
Promise.<any>

(async) shouldOverwrite(url) → {Promise.<boolean>}

Checks for overwrite flag

Parameters:
NameTypeDescription
urlstring

url to build path from

Returns:
Type: 
Promise.<boolean>