mirror of
https://github.com/YuzuZensai/play-dl-test.git
synced 2026-01-06 04:32:40 +00:00
More Validation methods added
This commit is contained in:
@@ -5,12 +5,22 @@ 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+)?$/;
|
||||
const playlist_pattern = /^((?:https?:)?\/\/)?(?:(?:www|m)\.)?(youtube\.com)\/(?:(playlist|watch))(.*)?((\?|\&)list=)/
|
||||
|
||||
export function validate(url : string): boolean{
|
||||
if(!url.match(video_pattern)) return false
|
||||
else return true
|
||||
}
|
||||
|
||||
export function validate_playlist(url : string): boolean{
|
||||
if(!url.match(playlist_pattern)) return false
|
||||
let Playlist_id = url.split('list=')[1].split('&')[0]
|
||||
if(Playlist_id.length !== 34 || !Playlist_id.startsWith('PL')){
|
||||
return false
|
||||
}
|
||||
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;
|
||||
|
||||
@@ -1 +1 @@
|
||||
export { video_basic_info, video_info, playlist_info, validate } from './extractor'
|
||||
export { video_basic_info, video_info, playlist_info, validate, validate_playlist } from './extractor'
|
||||
@@ -1 +1 @@
|
||||
export { playlist_info, video_basic_info, video_info, search, stream, stream_from_info, validate } from "./YouTube";
|
||||
export { playlist_info, video_basic_info, video_info, search, stream, stream_from_info, validate, validate_playlist } from "./YouTube";
|
||||
Reference in New Issue
Block a user