summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar piotrruss <mail@pruss.it> 2021-06-05 10:02:32 +0200
committerGravatar piotrruss <mail@pruss.it> 2021-06-05 10:02:32 +0200
commit5014b7e55f6c19d227b0669e7591a60124e722c9 (patch)
tree09ad2e5ca8783c874e2f764f05bba37c2a1b9a38
parentffee711b6633bebdc7299624e1b4f49d34779f4c (diff)
downloadyt_audio_player_api-main.tar.gz
yt_audio_player_api-main.tar.bz2
yt_audio_player_api-main.zip
unescape html charactersmain
-rw-r--r--htmlChars22
-rwxr-xr-xyta9
2 files changed, 28 insertions, 3 deletions
diff --git a/htmlChars b/htmlChars
new file mode 100644
index 0000000..3114945
--- /dev/null
+++ b/htmlChars
@@ -0,0 +1,22 @@
+module.exports = {
+ '&quot;': '\"',
+ '&#34;': '\"',
+ '&apos;': '\\',
+ '&#39;': '\\',
+ '&amp;': '&',
+ '&#38;': '&',
+ '&gt;': '>',
+ '&#62;': '>',
+ '&lt;': '<',
+ '&#60;': '<',
+ '&cent;': '¢',
+ '&#162;': '¢',
+ '&copy;': '©',
+ '&#169;': '©',
+ '&euro;': '€',
+ '&#8364;': '€',
+ '&pound;': '£',
+ '&#163;': '£',
+ '&reg;': '®',
+ '&#174;': '®'
+};
diff --git a/yta b/yta
index bdee11e..c572662 100755
--- a/yta
+++ b/yta
@@ -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);