UNPKG

andrade-soulseek-downloader

Version:

Simple, safe Soulseek download library with built-in rate limiting to prevent bans

85 lines 3.01 kB
import { Bitrate } from '../value-objects/bitrate'; import { TrackId } from '../value-objects/track-id'; /** * Domain entity representing a music track available on Soulseek. * Encapsulates track metadata and quality scoring business logic. */ export declare class Track { private readonly id; private readonly artist; private readonly title; private readonly bitrate; private readonly fileSize; private readonly filePath; private readonly user; private readonly slots; private readonly speed; private readonly matchScore; /** * Creates a new Track entity. * @param id - Unique identifier for the track * @param artist - Artist name * @param title - Track title * @param bitrate - Audio bitrate value object * @param fileSize - File size in bytes * @param filePath - Path to file on remote user's system * @param user - Soulseek username of the file owner * @param slots - Whether user has available download slots * @param speed - User's upload speed in bytes/second * @param matchScore - Search relevance score (0-1) * @throws {Error} If validation fails */ constructor(id: TrackId, artist: string, title: string, bitrate: Bitrate, fileSize: number, filePath: string, user: string, slots: boolean, speed: number, matchScore: number); /** Validates track invariants */ private validateTrack; /** @returns Track unique identifier */ getId(): TrackId; /** @returns Artist name */ getArtist(): string; /** @returns Track title */ getTitle(): string; /** @returns Bitrate value object */ getBitrate(): Bitrate; /** @returns File size in bytes */ getFileSize(): number; /** @returns Remote file path */ getFilePath(): string; /** @returns Soulseek username */ getUser(): string; /** @returns Whether user has download slots available */ hasAvailableSlots(): boolean; /** @returns Upload speed in bytes/second */ getSpeed(): number; /** @returns Search relevance score (0-1) */ getMatchScore(): number; /** * Calculates quality score based on bitrate, availability, speed, and match. * Core business logic for track prioritization. * @returns Quality score from 0-100 (higher is better) */ calculateQualityScore(): number; /** * Compares quality against another track. * @param other - Track to compare against * @returns True if this track has higher quality score */ isBetterThan(other: Track): boolean; /** * Serializes track to JSON representation. * @returns Plain object with all track properties */ toJSON(): { id: string; artist: string; title: string; bitrate: number; fileSize: number; filePath: string; user: string; slots: boolean; speed: number; matchScore: number; qualityScore: number; }; } //# sourceMappingURL=track.d.ts.map