Skip to content

Commit

Permalink
Update common.js
Browse files Browse the repository at this point in the history
  • Loading branch information
EdenwareApps committed Jul 14, 2023
1 parent e063912 commit 28a2d5e
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions www/nodejs-project/modules/lists/common.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

const Events = require('events'), fs = require('fs'), ParentalControl = require('./parental-control')
const Parser = require('./parser'), M3UTools = require('./tools'), MediaURLInfo = require('../streamer/utils/media-url-info')
const { regexes, sanitizeName } = require('./parser'), M3UTools = require('./tools'), MediaURLInfo = require('../streamer/utils/media-url-info')
const List = require('./list'), UpdateListIndex = require('./update-list-index')

global.LIST_DATA_KEY_MASK = 'list-data-1-{0}'
Expand Down Expand Up @@ -90,6 +90,8 @@ class Fetcher extends Events {
class Common extends Events {
constructor(opts){
super()
this.regexes = regexes
this.sanitizeName = sanitizeName
this.Fetcher = Fetcher
this.searchRedirects = []
this.stopWords = ['sd', 'hd', 'h264', 'h.264', 'fhd'] // common words to ignore on searching
Expand All @@ -104,7 +106,6 @@ class Common extends Events {
this[k] = opts[k]
})
}
this.parser = new Parser()
this.tools = new M3UTools(opts)
this.mi = new MediaURLInfo()
this.parentalControl = new ParentalControl()
Expand Down Expand Up @@ -160,22 +161,22 @@ class Common extends Events {
}
})
txt = txt.toLowerCase()
let tms = this.applySearchRedirects(txt.replace(this.parser.regexes['plus-signal'], 'plus').
replace(this.parser.regexes['between-brackets'], '').
normalize('NFD').toLowerCase().replace(this.parser.regexes['accents'], ''). // replace/normalize accents
let tms = this.applySearchRedirects(txt.replace(this.regexes['plus-signal'], 'plus').
replace(this.regexes['between-brackets'], '').
normalize('NFD').toLowerCase().replace(this.regexes['accents'], ''). // replace/normalize accents
split(' ').
map(s => {
if(s.charAt(0) == '-'){
if(allowModifier){
s = s.replace(this.parser.regexes['hyphen-not-modifier'], '$1')
s = s.replace(this.regexes['hyphen-not-modifier'], '$1')
return s.length > 1 ? s : ''
} else {
return ''
}
} else if(s == '|' && !allowModifier){
return ''
}
return s.replace(this.parser.regexes['hyphen-not-modifier'], '$1')
return s.replace(this.regexes['hyphen-not-modifier'], '$1')
}))
tms = tms.filter(s => s)
if(!keepStopWords){
Expand Down

0 comments on commit 28a2d5e

Please sign in to comment.