search validation added

This commit is contained in:
killer069
2021-10-09 16:18:05 +05:30
parent 1ba762d10c
commit 6698a87983
11 changed files with 199 additions and 187 deletions

View File

@@ -260,7 +260,7 @@ export class Stream {
}
private async loop() {
if (this.stream.destroyed ||this.time.length === 0 || this.segment_urls.length === 0) {
if (this.stream.destroyed || this.time.length === 0 || this.segment_urls.length === 0) {
this.cleanup();
return;
}
@@ -273,7 +273,7 @@ export class Stream {
return;
}
this.request = stream
this.request = stream;
stream.pipe(this.stream, { end: false });
stream.on('end', () => {
if (this.downloaded_time >= 300) return;

View File

@@ -126,8 +126,8 @@ export async function check_id(id: string): Promise<boolean> {
* @param url soundcloud url
* @returns "false" | 'track' | 'playlist'
*/
export async function so_validate(url: string): Promise<false | 'track' | 'playlist'> {
if (!url.match(pattern)) return false;
export async function so_validate(url: string): Promise<false | 'track' | 'playlist' | 'search'> {
if (!url.match(pattern)) return 'search';
const data = await request(
`https://api-v2.soundcloud.com/resolve?url=${url}&client_id=${soundData.client_id}`
).catch((err: Error) => err);