@dvxch/yandex-music
    Preparing search index...

    Class LosslessDownloadInfo

    Lossless (and other modern) download info from /get-file-info.

    With transport: 'encraw' the URLs serve an AES-CTR-encrypted stream and LosslessDownloadInfo.key holds the hex decryption key; LosslessDownloadInfo.downloadBytes fetches and decrypts it for you. The endpoint falls back to a lossy codec when a track has no lossless source, so check LosslessDownloadInfo.codec / LosslessDownloadInfo.isLossless.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    bitrate?: number

    Bitrate in kbit/s.

    client?: Client

    The client that created this model, used by convenience methods.

    codec?: string

    Actual codec served (flac, flac-mp4, aac, mp3, …).

    gain?: boolean

    Whether loudness-normalization gain data is available.

    key?: string

    Hex AES-CTR key used to decrypt an encraw stream, when encrypted.

    quality?: string

    Requested/granted quality (for example lossless).

    realId?: string

    Canonical track id when the requested id is an alias.

    size?: number

    File size in bytes, when known.

    trackId?: string

    Track id this info belongs to.

    transport?: string

    Transport, typically encraw (AES-CTR-encrypted raw stream).

    url?: string

    Single stream URL (older response shape).

    urls?: string[]

    Candidate stream URLs (any one works).

    Accessors

    Methods

    • Download the audio straight to a file on disk, streaming it and transparently AES-CTR-decrypting an encraw stream on the fly when key is present.

      Streaming keeps memory O(chunk) rather than buffering the whole (large, for lossless) file. Mirror URLs are tried in order, so a flaky host falls back to the next.

      Parameters

      • filename: string

        Destination path, including extension.

      • options: { race?: boolean } = {}

        Set race: true to race all mirror URLs and commit to the fastest responder (cuts tail latency when a host is slow; falls back to sequential on failure). Defaults to sequential mirror failover.

      Returns Promise<void>

      On any transport or API error (the last one, after every candidate URL fails).

    • Download the audio as bytes, transparently AES-CTR-decrypting an encraw stream when key is present.

      /get-file-info returns several mirror URLs on different CDN hosts; this tries each in order so a single flaky host doesn't fail the download.

      Returns Promise<Uint8Array<ArrayBufferLike>>

      The decoded audio file contents.

      On any transport or API error (the last one, after every candidate URL fails).

    • Pick a stream URL.

      Returns string

      The first candidate stream URL (the bytes may be encrypted — see key).

      When no URL is present.

    • Assert that this model carries a client, returning it narrowed to non-null.

      Convenience methods that need to call the API use this to fail fast with a clear message instead of a generic "cannot read property of undefined".

      Returns Client

      The owning Client.

      When the model was created without a client.