diff options
author | 2021-06-05 10:02:32 +0200 | |
---|---|---|
committer | 2021-06-05 10:02:32 +0200 | |
commit | 5014b7e55f6c19d227b0669e7591a60124e722c9 (patch) | |
tree | 09ad2e5ca8783c874e2f764f05bba37c2a1b9a38 /yta | |
parent | ffee711b6633bebdc7299624e1b4f49d34779f4c (diff) | |
download | yt_audio_player_api-5014b7e55f6c19d227b0669e7591a60124e722c9.tar.gz yt_audio_player_api-5014b7e55f6c19d227b0669e7591a60124e722c9.tar.bz2 yt_audio_player_api-5014b7e55f6c19d227b0669e7591a60124e722c9.zip |
unescape html charactersmain
Diffstat (limited to 'yta')
-rwxr-xr-x | yta | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -3,6 +3,7 @@ const spawn = require('child_process').spawn; const colors = require('colors'); const prompt = require('prompt'); const fetch = require('node-fetch'); +const htmlChars = require('./htmlChars'); const { YTKEY } = require('./config'); let data = {ids: [], titles: [], descriptions: [], channels: [], durations: []}; @@ -131,9 +132,9 @@ const getDurations = (ids) => getJson(detailsUrl(ids)).then(json => json.items.m const presentResults = (results) => { const items = results.items.filter(i => i.snippet); - data.titles = items.map(i => i.snippet.title); - data.descriptions = items.map(i => i.snippet.description); - data.channels = items.map(i => i.snippet.channelTitle); + data.titles = items.map(i => decode(i.snippet.title)); + data.descriptions = items.map(i => decode(i.snippet.description)); + data.channels = items.map(i => decode(i.snippet.channelTitle)); data.ids = items.map(i => i.id.videoId); getDurations(data.ids).then(durations => { data.durations = durations; @@ -143,6 +144,8 @@ const presentResults = (results) => { }); }; +const decode = t => t.replace(new RegExp(`/${Object.keys(htmlChars).join('|')}/gi`), (m) => htmlChars[m]); + const handlePrompt = (err, { query }) => { if (err) { console.log(err); |