Fixed bug where files with VOSTFR could not be read

This commit is contained in:
Kylart 2017-06-17 18:30:34 +02:00
parent 20b72f9700
commit e1d6e35c72
1 changed files with 8 additions and 5 deletions

View File

@ -10,12 +10,17 @@ const qs = require('querystring')
const extensions = ['.mkv', '.mp4']
const removeUnwanted = (rawName) => {
return rawName
.replace(' VOSTFR', '')
}
const getName = (rawName) => {
return rawName.split(' ').slice(1, -3).join(' ')
return removeUnwanted(rawName).split(' ').slice(1, -3).join(' ')
}
const getEp = (rawName) => {
return parseInt(rawName.split(' ').splice(-2)[0])
return parseInt(removeUnwanted(rawName).split(' ').splice(-2)[0])
}
const minifyName = (name) => {
@ -62,9 +67,7 @@ const searchLocalFiles = (url, res) => {
const query = qs.parse(url.query.replace('?', ''))
const dir = query.dir
const files = fs.readdirSync(dir).filter((file) => { return extensions.includes(extname(file)) }).map((file) => {
return file.replace(' VOSTFR', '')
})
const files = fs.readdirSync(dir).filter((file) => { return extensions.includes(extname(file)) })
const uniqueNames = getUniques(files)
let counter = 0