[scraper] use html escape lib

This commit is contained in:
TheBeastLT
2020-03-23 16:09:28 +01:00
parent cd9530bfa7
commit fd3fd9c2fe
3 changed files with 8 additions and 5 deletions

5
package-lock.json generated
View File

@@ -807,6 +807,11 @@
"resolved": "https://registry.npmjs.org/hat/-/hat-0.0.3.tgz",
"integrity": "sha1-uwFKnmSzeIrtgAWRdBPU/z1QLYo="
},
"he": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz",
"integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw=="
},
"htmlparser2": {
"version": "3.10.1",
"resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-3.10.1.tgz",

View File

@@ -19,6 +19,7 @@
"cheerio": "^0.22.0",
"dotenv": "^8.2.0",
"express": "^4.16.4",
"he": "^1.2.0",
"jaro-winkler": "^0.2.8",
"line-by-line": "^0.1.6",
"magnet-uri": "^5.1.7",

View File

@@ -1,6 +1,7 @@
const needle = require('needle');
const nameToImdb = require('name-to-imdb');
const bing = require('nodejs-bing');
const he = require('he');
const { cacheWrapImdbId, cacheWrapKitsuId, cacheWrapMetadata } = require('./cache');
const { Type } = require('./types');
@@ -86,11 +87,7 @@ function escapeTitle(title) {
}
function escapeHTML(title) {
return title
.replace(/'|'/g, '\'')
.replace(/&|&/g, '&')
.replace(/!/g, '!')
.replace(/%/g, '%');
return he.decode(title);
}
async function getImdbId(info, type) {