Error Fixes
This commit is contained in:
parent
ad1ad2b918
commit
b969de06e2
4
package-lock.json
generated
4
package-lock.json
generated
@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "play-dl",
|
||||
"version": "0.1.7",
|
||||
"version": "0.2.1",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "play-dl",
|
||||
"version": "0.1.7",
|
||||
"version": "0.2.1",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"got": "^11.8.2"
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "play-dl",
|
||||
"version": "0.1.7",
|
||||
"version": "0.2.1",
|
||||
"description": "YouTube, SoundCloud, Spotify downloader",
|
||||
"main": "dist/index.js",
|
||||
"typings": "dist/index.d.ts",
|
||||
|
||||
@ -4,11 +4,10 @@ import { Video } from '../classes/Video'
|
||||
import { PlayList } from '../classes/Playlist'
|
||||
|
||||
const DEFAULT_API_KEY = "AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8";
|
||||
const youtube_url = /https:\/\/www.youtube.com\//g
|
||||
const video_pattern = /^((?:https?:)?\/\/)?((?:www|m)\.)?((?:youtube\.com|youtu.be))(\/(?:[\w\-]+\?v=|embed\/|v\/)?)([\w\-]+)(\S+)?$/;
|
||||
const video_pattern = /^((?:https?:)?\/\/)?:(?:(?:www|m)\.)?((?:youtube\.com|youtu.be))(\/(?:[\w\-]+\?v=|embed\/|v\/)?)([\w\-]+)(\S+)?$/;
|
||||
|
||||
export async function video_basic_info(url : string){
|
||||
if(!url.match(youtube_url) || !url.match(video_pattern)) throw new Error('This is not a YouTube URL')
|
||||
if(!url.match(video_pattern)) throw new Error('This is not a YouTube URL')
|
||||
let video_id = url.split('watch?v=')[1].split('&')[0]
|
||||
let new_url = 'https://www.youtube.com/watch?v=' + video_id
|
||||
let body = await url_get(new_url)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user