Stream and Validate fixes

This commit is contained in:
killer069
2021-10-05 18:47:09 +05:30
parent f30c4f458b
commit 79419d2205
5 changed files with 137 additions and 59 deletions

View File

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