andrade-soulseek-downloader
Version:
Simple, safe Soulseek download library with built-in rate limiting to prevent bans
96 lines • 2.37 kB
TypeScript
import { EventEmitter } from 'events';
export interface ServerAddress {
host: string;
port: number;
}
export interface Credentials {
user: string;
pass: string;
incomingPort?: number;
}
export interface ConnectOptions extends Credentials {
host?: string;
port?: number;
timeout?: number;
sharedFolders?: string[];
}
export interface PeerInfo {
user: string;
host?: string;
port?: number;
token?: string;
type?: string;
}
export interface SearchQuery {
req: string;
timeout?: number;
}
export interface SearchResult {
user: string;
file: string;
size: number;
slots: boolean;
bitrate?: number;
speed?: number;
queue?: number;
}
export interface FileInfo {
user: string;
file: string;
size?: number;
}
export interface DownloadOptions {
file: FileInfo;
path?: string;
}
export interface SharedFile {
key?: string;
value?: {
file: string;
size: number;
};
file?: string;
size?: number;
}
export interface PeerSearchMatch {
[user: string]: {
[ticket: string]: SharedFile[];
};
}
export interface SearchCallback {
cb: (res: SearchResult) => void;
query: string;
}
export interface DownloadToken {
user: string;
file: string;
size?: number;
}
export interface DownloadCallback {
cb: ((err: Error | null, data?: Buffer) => void) | null;
path?: string;
stream?: NodeJS.ReadableStream;
}
export interface Stack {
login?: (err: Error | null) => void;
search: {
[token: string]: SearchCallback;
};
download: {
[key: string]: DownloadCallback;
};
downloadTokens: {
[token: string]: DownloadToken;
};
peerSearchMatches: PeerSearchMatch;
currentLogin?: string;
}
export interface SlskClientInterface extends EventEmitter {
init(cb: (err?: Error) => void): void;
login(credentials: Credentials, cb: (err?: Error) => void): void;
search(obj: SearchQuery, cb: (err: Error | null, results: SearchResult[]) => void): void;
download(obj: DownloadOptions, cb: (err: Error | null, data?: Buffer) => void, stream?: NodeJS.ReadableStream): EventEmitter;
downloadStream(obj: DownloadOptions, cb: (err: Error | null, stream?: NodeJS.ReadableStream) => void): void;
destroy(): void;
}
//# sourceMappingURL=types.d.ts.map