-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
129 lines (112 loc) · 3.23 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
import { Readable } from "stream";
type StreamOptions = {
highWaterMark: number;
format: number;
download: boolean;
};
type SearchOptions = {
limit: number;
type: 'tracks' | 'albums' | 'playlists';
};
interface StreamEvents {
ready: [];
error: [Error];
}
interface SoundCloudTrack{
uploaded: Date;
description?: string;
duration: number;
genre: string;
id: number;
title: string;
likes: number;
url: string;
streams: number;
author: {
name: string;
image: string;
url: string;
followers: number;
};
formats: [];
partial: false;
thumbnail: string;
type: 'track';
clientId: string;
}
interface SoundCloudBaseTrack{
id: string;
partial: true;
type: 'track';
clientId: string;
}
interface SoundCloudPlaylist{
created: Date;
description?: string;
duration: number;
genre: string;
id: number;
title: string;
likes: number;
author: {
name: string;
image: string;
url: string;
followers: number;
}
songs: [SoundCloudTrack | SoundCloudBaseTrack];
thumbnail: string;
type: 'playlist';
clientId: string;
}
interface SoundCloudStream{
stream: Readable;
url: string;
retryCount: number;
ready: boolean;
info: SoundCloudTrack;
options: {
format?: number;
download?: boolean;
highWaterMark?: number;
};
mimeType: string;
format: {};
downloaded_time: number;
time: [number];
sub_urls: [string];
on<T extends keyof StreamEvents>(eventName: T, listener: (...args: StreamEvents[T]) => void);
once<T extends keyof StreamEvents>(eventName: T, listener: (...args: StreamEvents[T]) => void);
emit<T extends keyof StreamEvents>(eventName: T, listener: (...args: StreamEvents[T]) => void);
}
/**
* Receives information about a playlist or a track on SoundCloud
* @param url The url of the SoundCloud playlist or track
*/
export function getInfo(url: string) : Promise<SoundCloudTrack | SoundCloudPlaylist>;
/**
* Creates a readable stream for a SoundCloud track
* @param info The url of the SoundCloud track or an instance of the SoundCloudTrack class of the track you would like to create a readable stream for
* @param options Additional options for the stream function
*/
export function stream(info: string | SoundCloudTrack, options: StreamOptions) : Promise<SoundCloudStream>;
/**
* Searches for a track, playlist or album on SoundCloud
* @param query The query you would like to use for the search
* @param options Additional options to specify your search
*/
export function search(query: string, options: SearchOptions) : Promise<[SoundCloudTrack | SoundCloudPlaylist]>;
/**
* Updates the client id used to get the information from SoundCloud
*/
export function getClientId() : Promise<string>;
/**
* Fetches a track by only using the track id
* @param trackId The track id of the song you would like to fetch
*/
export function fetchTrack(trackId: string | number) : Promise<SoundCloudTrack>;
/**
* Checks whether a url is a valid SoundCloud url or not
* @param url The SoundCloud url you would like to validate
*/
export function validateSoundCloudURL(url: string) : boolean;