From 0ecc1367d2b6e15048eec4a9d6d95c3e7cf0125f Mon Sep 17 00:00:00 2001 From: buvta <12312540+buvta@users.noreply.github.com> Date: Mon, 25 Jan 2021 17:15:04 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=90=9C=E7=B4=A2=EF=BC=8C?= =?UTF-8?q?=E8=BF=87=E6=BB=A4=E6=8E=89=E5=BC=82=E5=B8=B8=E7=BB=93=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lib/site/tools.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/lib/site/tools.js b/src/lib/site/tools.js index ad993e2..416a7a7 100644 --- a/src/lib/site/tools.js +++ b/src/lib/site/tools.js @@ -212,15 +212,20 @@ const zy = { return new Promise((resolve, reject) => { this.getSite(key).then(res => { const site = res - wd = encodeURI(wd) - const url = `${site.api}?wd=${wd}` + const url = `${site.api}?wd=${encodeURI(wd)}` axios.post(url, { timeout: 3000 }).then(res => { const data = res.data const json = parser.parse(data, this.xmlConfig) const jsondata = json.rss === undefined ? json : json.rss if (json && jsondata && jsondata.list) { - const videoList = jsondata.list.video - resolve(videoList) + let videoList = jsondata.list.video + if (Object.prototype.toString.call(videoList) === '[object Object]') videoList = [].concat(videoList) + videoList = videoList.filter(e => e.name.toLowerCase().includes(wd.toLowerCase())) + if (videoList.length) { + resolve(videoList) + } else { + resolve() + } } }).catch(err => { reject(err)