Utils#

Reader#

class harmonize.utils.DataReader(base64_str: str)[source]#

A utility class for reading binary data from a base 64 track. Original

property remaining: int#

The amount of bytes left to be read.

read_byte() bytes[source]#

Reads a single byte from the stream.

Return type:

bytes

read_boolean() bool[source]#

Reads a bool from the stream.

Return type:

bool

read_unsigned_short() int[source]#

Reads an unsigned short from the stream.

Return type:

int

read_int() int[source]#

Reads an int from the stream.

Return type:

int

read_long() int[source]#

Reads a long from the stream.

Return type:

int

read_nullable_utf(utfm: bool = False) str | None[source]#

Reads an optional UTF string from the stream.

Internally, this just reads a bool and then a string if the bool is True.

Parameters:

utfm (bool) – Whether to read the string as modified UTF.

Return type:

Optional[str]

read_utf() bytes[source]#

Reads a UTF string from the stream.

Return type:

bytes

read_utfm() str[source]#

Reads a UTF string from the stream.

This method is different to read_utf() as it accounts for different encoding methods utilised by Java’s streams, which uses modified UTF for character encoding.

Return type:

str

Fields decoding functions#

harmonize.utils.decode_probe_info(reader: DataReader) dict[str, any][source]#

Decodes the probe information from the provided DataReader.

Parameters:

reader (harmonize.utils.DataReader) – The DataReader object containing the probe information.

Return type:

dict[str, any]

Note

The dictionary contains the following key and its corresponding value:

  • ‘probe_info’: The probe information as a string.

harmonize.utils.decode_lavasrc_fields(reader: DataReader) dict[str, any][source]#

Decodes the Lava Source fields from the provided DataReader.

Parameters:

reader (harmonize.utils.DataReader) – The DataReader object containing the source data.

Return type:

dict[str, any]

Note

The dictionary contains the following keys and their corresponding values:

  • ‘albumName’: The name of the album.

  • ‘albumUrl’: The URL of the album.

  • ‘artistUrl’: The URL of the artist.

  • ‘artistArtworkUrl’: The URL of the artist’s artwork.

  • ‘previewUrl’: The URL of the preview.

  • ‘isPreview’: A boolean indicating whether the source is a preview.