updates horriblesubs scraper to split multiple season entries

This commit is contained in:
TheBeastLT
2020-03-05 14:57:57 +01:00
parent cbfcea65f8
commit 51eb21f112
6 changed files with 47 additions and 14 deletions

View File

@@ -67,18 +67,18 @@ function _requestMetadata(url) {
});
}
function escapeTitle(title, hyphenEscape = true) {
function escapeTitle(title) {
return title.toLowerCase()
.normalize('NFKD') // normalize non-ASCII characters
.replace(/[\u0300-\u036F]/g, '')
.replace(/&/g, 'and')
.replace(hyphenEscape ? /[.,_+ -]+/g : /[.,_+ ]+/g, ' ') // replace dots, commas or underscores with spaces
.replace(/[^\w- ()]/gi, '') // remove all non-alphanumeric chars
.replace(/[;, ~\-]+/g, ' ') // replace dots, commas or underscores with spaces
.replace(/[^\w ()+#@!']+/g, '') // remove all non-alphanumeric chars
.trim();
}
async function getImdbId(info, type) {
const name = escapeTitle(info.title).toLowerCase();
const name = escapeTitle(info.title);
const year = info.year || info.date && info.date.slice(0, 4);
const key = `${name}_${year}_${type}`;
@@ -100,7 +100,7 @@ async function getImdbId(info, type) {
}
async function getKitsuId(info) {
const title = escapeTitle(info.title).toLowerCase().replace(/[;]+/g, ' ').replace(/[,%']+/g, '');
const title = escapeTitle(info.title);
const season = info.season > 1 ? ` S${info.season}` : '';
const query = `${title}${season}`;