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

    Class DownloadInfo

    One download variant of a track (codec + bitrate), plus the means to resolve a short-lived direct file URL.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    bitrateInKbps?: number

    Bitrate in kbit/s.

    client?: Client

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

    codec?: string

    Audio codec, for example mp3 or aac.

    direct?: boolean

    Whether the link is already direct.

    directLink?: string

    Cached resolved direct link, populated by DownloadInfo.getDirectLink.

    downloadInfoUrl?: string

    URL of the XML document describing how to build the direct link.

    gain?: boolean

    Whether gain is applied.

    preview?: boolean

    Whether this is a preview rather than the full track.

    Methods

    • Deserialize a list of DownloadInfo, optionally resolving direct links.

      Parameters

      • raw: JSONValue | undefined

        Raw JSON array from the API.

      • Optionalclient: Client

        The owning client.

      • getDirectLinks: boolean = false

        When true, resolve every direct link eagerly.

      Returns Promise<DownloadInfo[]>

      The list of download variants.

    • Download the track straight to a file on disk.

      Parameters

      • filename: string

        Destination path, including extension.

      Returns Promise<void>

      On any transport or API error.

    • Download the track and return it as bytes.

      Returns Promise<Uint8Array<ArrayBufferLike>>

      The audio file contents.

      On any transport or API error.

    • Resolve the short-lived direct download URL from the info XML.

      The resolved URL is valid for roughly one minute; requesting it later yields an HTTP 410. The result is cached in DownloadInfo.directLink.

      Returns Promise<string>

      The direct download URL.

      On any transport or API error.

    • 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.