Skip to content

🎵 Lightweight TypeScript library to encode/decode Lavalink track metadata — fast, fully typed, and easy to use with CommonJS & ESM support

License

Notifications You must be signed in to change notification settings

CycloneAddons/lavalink-track-codec

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

npm version
License: MIT
TypeScript


Overview

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.


Features

  • âš¡ 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

Installation

npm install lavalink-track-codec
# or
yarn add lavalink-track-codec

Usage

import { 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);

API

encodeTrack(track: Track): string

Encodes a Track object into a string representation.

decodeTrack(encoded: string): Track

Decodes an encoded track string back into a Track object.


Track Type Definition

type Track = {
  title: string;
  author: string;
  length: number;
  identifier: string;
  isStream: boolean;
  uri: string;
  artworkUrl: string | null;
  isrc: string | null;
  sourceName: string;
  position: number;
};

Development

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 test

Contributions and issues are welcome!

About

🎵 Lightweight TypeScript library to encode/decode Lavalink track metadata — fast, fully typed, and easy to use with CommonJS & ESM support

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published