diff --git a/play-dl/Deezer/index.ts b/play-dl/Deezer/index.ts index fee02e7..745d5eb 100644 --- a/play-dl/Deezer/index.ts +++ b/play-dl/Deezer/index.ts @@ -92,7 +92,7 @@ async function internalValidate(url: string): Promise { return { type: false }; } - if ((path[1] === 'track' || path[1] === 'album' || path[1] === 'playlist') && path[2].match(/^[0-9]+$/)) { + if ((path[1] === 'track' || path[1] === 'album' || path[1] === 'playlist') && path[2].match(/^\d+$/)) { return { type: path[1], id: path[2] @@ -105,7 +105,7 @@ async function internalValidate(url: string): Promise { if ( path.length === 3 && (path[1] === 'track' || path[1] === 'album' || path[1] === 'playlist') && - path[2].match(/^[0-9]+$/) + path[2].match(/^\d+$/) ) { return { type: path[1], diff --git a/play-dl/YouTube/utils/cipher.ts b/play-dl/YouTube/utils/cipher.ts index 62d1c99..84adb4c 100644 --- a/play-dl/YouTube/utils/cipher.ts +++ b/play-dl/YouTube/utils/cipher.ts @@ -9,7 +9,7 @@ interface formatOptions { s?: string; } // RegExp for various js functions -const var_js = '[a-zA-Z_\\$][a-zA-Z_0-9]*'; +const var_js = '[a-zA-Z_\\$]\\w*'; const singlequote_js = `'[^'\\\\]*(:?\\\\[\\s\\S][^'\\\\]*)*'`; const duoblequote_js = `"[^"\\\\]*(:?\\\\[\\s\\S][^"\\\\]*)*"`; const quote_js = `(?:${singlequote_js}|${duoblequote_js})`; diff --git a/play-dl/YouTube/utils/extractor.ts b/play-dl/YouTube/utils/extractor.ts index e1ed5ed..24a5ca1 100644 --- a/play-dl/YouTube/utils/extractor.ts +++ b/play-dl/YouTube/utils/extractor.ts @@ -468,12 +468,12 @@ function getNormalPlaylist(response: any, body: any): YouTubePlayList { if (!data.title.runs || !data.title.runs.length) throw new Error('Failed to Parse Playlist info.'); const author = playlist_details[1]?.playlistSidebarSecondaryInfoRenderer.videoOwner; - const views = data.stats.length === 3 ? data.stats[1].simpleText.replace(/[^0-9]/g, '') : 0; + const views = data.stats.length === 3 ? data.stats[1].simpleText.replace(/\D/g, '') : 0; const lastUpdate = data.stats .find((x: any) => 'runs' in x && x['runs'].find((y: any) => y.text.toLowerCase().includes('last update'))) ?.runs.pop()?.text ?? null; - const videosCount = data.stats[0].runs[0].text.replace(/[^0-9]/g, '') || 0; + const videosCount = data.stats[0].runs[0].text.replace(/\D/g, '') || 0; const res = new YouTubePlayList({ continuation: { diff --git a/play-dl/YouTube/utils/parser.ts b/play-dl/YouTube/utils/parser.ts index 1042d88..647a52e 100644 --- a/play-dl/YouTube/utils/parser.ts +++ b/play-dl/YouTube/utils/parser.ts @@ -146,7 +146,7 @@ export function parseVideo(data?: any): YouTubeVideo { artist: Boolean(badge?.includes('artist')) }, uploadedAt: data.videoRenderer.publishedTimeText?.simpleText ?? null, - views: data.videoRenderer.viewCountText?.simpleText?.replace(/[^0-9]/g, '') ?? 0, + views: data.videoRenderer.viewCountText?.simpleText?.replace(/\D/g, '') ?? 0, live: durationText ? false : true }); @@ -179,7 +179,7 @@ export function parsePlaylist(data?: any): YouTubePlayList { name: channel?.text, url: `https://www.youtube.com${channel?.navigationEndpoint.commandMetadata.webCommandMetadata.url}` }, - videos: parseInt(data.playlistRenderer.videoCount.replace(/[^0-9]/g, '')) + videos: parseInt(data.playlistRenderer.videoCount.replace(/\D/g, '')) }, true );