lavalink-track-codec is a lightweight TypeScript library to encode and decode Lavalink-compatible audio track metadata efficiently. Designed for music bots and streaming applications, it supports both CommonJS and ES Modules with fully typed interfaces for seamless TypeScript integration.
- âš¡ Fast encoding and decoding of track metadata
- 🎵 Supports all essential track info: title, author, length, identifier, stream flags, URIs, and more
- 🔄 Compatible with CommonJS and ES Module ecosystems
- ✅ Written in TypeScript with full type definitions
- 🔧 Simple and minimal API for easy integration
npm install lavalink-track-codec
# or
yarn add lavalink-track-codecimport { encodeTrack, decodeTrack } from 'lavalink-track-codec';
import type { Track } from 'lavalink-track-codec';
const track: Track = {
title: 'Shayad - CYCLONE ADDDD',
author: 'Sony Music India',
length: 190000,
identifier: 'MJyKN-8UncM',
isStream: false,
uri: 'https://www.youtube.com/watch?v=MJyKN-8UncM',
artworkUrl: 'https://i.ytimg.com/vi/MJyKN-8UncM/mqdefault.jpg',
isrc: null,
sourceName: 'youtube',
position: 0,
};
const encoded = encodeTrack(track);
const decoded = decodeTrack(encoded);
console.log('Encoded Track:', encoded);
console.log('Decoded Track:', decoded);Encodes a Track object into a string representation.
Decodes an encoded track string back into a Track object.
type Track = {
title: string;
author: string;
length: number;
identifier: string;
isStream: boolean;
uri: string;
artworkUrl: string | null;
isrc: string | null;
sourceName: string;
position: number;
};Clone the repo, install dependencies, build, and run tests:
git clone https://github.com/CycloneAddons/lavalink-track-codec
cd lavalink-track-codec
npm install
npm run build
npm run testContributions and issues are welcome!