HLS Downloaderv0.0.0-semantic-release

default

Source: HttpClient.ts:52

A resilient HTTP Client specifically designed for HLS streaming workloads. Features include:

  • Native fetch implementation (Node 20+)
  • Exponential backoff retry strategy for transient 5xx/429 errors
  • Corporate Proxy support via ProxyAgent
  • Domain-based Proxy bypass (NO_PROXY)
  • Automatic AbortController management for request timeouts

Example

CODE
const client = new HttpClient({
timeout: 5000,
retry: { limit: 3, delay: 1000 },
proxy: 'http://proxy.corp.com:8080',
noProxy: 'localhost,127.0.0.1,.internal.com',
headers: { 'x-custom-header': 'my-custom-header' }
});

Constructors

new default(customOptions: HttpClientOptions): default

Parameters

Returns

default


Methods

fetchText(url: string): Promise<string>

Fetches a playlist and validates its HLS structure.

Parameters

  • url (string) — {string} - The M3U8 playlist URL

Returns

  • Promise<string> — The raw string content of the playlist

Throws

  • If the response body is not a valid HLS manifest

getStream( url: string, ): Promise<ReadableStream<Uint8Array<ArrayBufferLike>>>

Fetches a resource (usually a .ts segment) as a stream.

Parameters

  • url (string) — {string} - The segment URL

Returns

  • Promise<ReadableStream<Uint8Array<ArrayBufferLike>>> — A readable stream of the resource

Throws

  • If the response body is empty

setPrimaryOrigin(url: string): void

Sets the primary origin based on the initial playlist URL.

Parameters

  • url (string) — {string} url to set primary origin from

Returns

  • void