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

@@ -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
);