@eidoriantan/seratolibraryparser
Version:
Helps parsing serato DJ libraries for node.js based applications.
80 lines (79 loc) • 2.51 kB
TypeScript
declare type ChunkDataType = string | Chunk[] | number | Date;
/**
* Datastructure for saving Dom Objects
*/
declare class Chunk {
data?: ChunkDataType;
length: number;
tag: string;
constructor(length: number, tag: string, data?: ChunkDataType);
}
/**
* Interface for song data in sessions
*/
export interface Song {
title: string;
artist: string;
filePath: string;
bpm?: number;
}
/**
* Interface for song data in sessions
*/
export interface HistorySong extends Song {
timePlayed: Date;
}
/**
* Interface for session data
*/
export interface Session {
date: string;
songs: HistorySong[];
}
/**
* Converts a 4 byte string into a integer
* @param {string} s 4 byte string to be converted
*/
export declare function getUInt32FromString(s: string): number;
/**
* Converts a 4 byte integer into a string
* @param {number} n 4 byte integer
*/
export declare function getStringFromUInt32(n: number): string;
/**
* Returns the raw domtree of a serato file
* @param {string} path The path to the file that shoud be parsed
* @returns {Promise<Chunk[]>} Nested object dom
*/
export declare function getDomTree(path: string): Promise<Chunk[]>;
/**
* Reads in a history.databases file
* @param {string} path Path to the history.database file
* @returns {Promise<{ [Key: string]: number }>} A dictonary with the number of the session file for every date
*/
export declare function getSessions(path: string): Promise<{
[Key: string]: number;
}>;
/**
* Reads in a serato session file.
* @param {string} path Path to *.session file
* @returns {Promise<SessionSong[]>} An array containing title and artist for every song played
*/
export declare function getSessionSongs(path: string): Promise<HistorySong[]>;
/**
* Gets all songs of the database v2 serato file
* @param {string} path path to database v2 serato file
*/
export declare function getSeratoSongs(path: string): Promise<Song[]>;
/**
* Reads all sessions and played songs from the _Serato_ folder
* @param {string} seratoPath path to _Serato_ folder (including _Serato_)
* @returns {Promise<Session[]>} list of sessions including songs
*/
export declare function getSeratoHistory(seratoPath: string): Promise<Session[]>;
/**
* Returns the default path to the _serato_ folder of the user
* @returns {string} path to _serato_ folder
*/
export declare function getDefaultSeratoPath(): string;
export {};