From e1d6e35c72a09165b8c1a34f738108644339f8e0 Mon Sep 17 00:00:00 2001 From: Kylart Date: Sat, 17 Jun 2017 18:30:34 +0200 Subject: [PATCH] Fixed bug where files with VOSTFR could not be read --- assets/api/local.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/assets/api/local.js b/assets/api/local.js index 960d454..bb2ac00 100644 --- a/assets/api/local.js +++ b/assets/api/local.js @@ -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