mirror of
https://github.com/YuzuZensai/play-dl-test.git
synced 2026-01-30 20:24:25 +00:00
Validate URL + All Errors Fixed
This commit is contained in:
@@ -6,6 +6,11 @@ import { PlayList } from '../classes/Playlist'
|
||||
const DEFAULT_API_KEY = "AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8";
|
||||
const video_pattern = /^((?:https?:)?\/\/)?(?:(?:www|m)\.)?((?:youtube\.com|youtu.be))(\/(?:[\w\-]+\?v=|embed\/|v\/)?)([\w\-]+)(\S+)?$/;
|
||||
|
||||
export function validate(url : string): boolean{
|
||||
if(!url.match(video_pattern)) return false
|
||||
else return true
|
||||
}
|
||||
|
||||
export async function video_basic_info(url : string){
|
||||
if(!url.match(video_pattern)) throw new Error('This is not a YouTube URL')
|
||||
let video_id : string;
|
||||
|
||||
Reference in New Issue
Block a user