Docs + search validate updated

This commit is contained in:
killer069
2021-10-09 18:59:16 +05:30
parent 6698a87983
commit f6a91254aa
6 changed files with 37 additions and 38 deletions

View File

@@ -28,11 +28,10 @@ export function yt_validate(url: string): 'playlist' | 'video' | 'search' | fals
if (url.indexOf('list=') === -1) {
if (url.startsWith('https')) {
if (url.match(video_pattern)) {
const id = url.split('v=')[1].split('&')[0]
if(id.match(video_id_pattern)) return "video"
else return false
}
else return false;
const id = url.split('v=')[1].split('&')[0];
if (id.match(video_id_pattern)) return 'video';
else return false;
} else return false;
} else {
if (url.match(video_id_pattern)) return 'video';
else if (url.match(playlist_id_pattern)) return 'playlist';

View File

@@ -91,28 +91,19 @@ export async function stream_from_info(
export async function validate(
url: string
): Promise<
| 'so_playlist'
| 'so_track'
| 'so_search'
| 'sp_track'
| 'sp_album'
| 'sp_playlist'
| 'sp_search'
| 'yt_video'
| 'yt_playlist'
| 'yt_search'
| false
'so_playlist' | 'so_track' | 'sp_track' | 'sp_album' | 'sp_playlist' | 'yt_video' | 'yt_playlist' | 'search' | false
> {
let check;
if (!url.startsWith('https')) return 'search';
if (url.indexOf('spotify') !== -1) {
check = sp_validate(url);
return check !== false ? (('sp_' + check) as 'sp_track' | 'sp_album' | 'sp_playlist' | 'sp_search') : false;
return check !== false ? (('sp_' + check) as 'sp_track' | 'sp_album' | 'sp_playlist') : false;
} else if (url.indexOf('soundcloud') !== -1) {
check = await so_validate(url);
return check !== false ? (('so_' + check) as 'so_playlist' | 'so_track' | 'so_search') : false;
return check !== false ? (('so_' + check) as 'so_playlist' | 'so_track') : false;
} else {
check = yt_validate(url);
return check !== false ? (('yt_' + check) as 'yt_video' | 'yt_playlist' | 'yt_search') : false;
return check !== false ? (('yt_' + check) as 'yt_video' | 'yt_playlist') : false;
}
}
/**