Simplify regular expressions

This commit is contained in:
absidue
2021-12-26 16:55:10 +01:00
parent 6c607f062f
commit 770e896cc0
4 changed files with 7 additions and 7 deletions

View File

@@ -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: {