From b00b69a582fde28c8dc37575f2f3c17baef79e57 Mon Sep 17 00:00:00 2001 From: haiyangcui Date: Tue, 6 Apr 2021 16:49:00 +0200 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E8=B0=83=E7=94=A8API?= =?UTF-8?q?=E7=9A=84=E9=80=BB=E8=BE=91,=E5=A6=82=E6=9E=9C=E6=9F=90?= =?UTF-8?q?=E4=BA=9B=E9=87=8D=E8=A6=81=E6=95=B0=E6=8D=AE=E6=B2=A1=E6=9C=89?= =?UTF-8?q?API=E8=BF=94=E5=9B=9E=E7=BB=93=E6=9E=9C=E4=B8=AD,=E5=BE=88?= =?UTF-8?q?=E5=8F=AF=E8=83=BD=E6=98=AF=E8=AF=A5=E6=BA=90=E7=AB=99=E5=B7=B2?= =?UTF-8?q?=E7=BB=8F=E5=A4=B1=E6=95=88,=E7=9B=B4=E6=8E=A5=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E7=A9=BA=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lib/site/tools.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/lib/site/tools.js b/src/lib/site/tools.js index 1cb4a67..a90133b 100644 --- a/src/lib/site/tools.js +++ b/src/lib/site/tools.js @@ -111,7 +111,8 @@ const zy = { axios.get(url).then(res => { const data = res.data const json = parser.parse(data, this.xmlConfig) - const jsondata = json.rss === undefined ? json : json.rss + const jsondata = json?.rss === undefined ? json : json.rss + if (!jsondata?.class || !jsondata?.list) resolve() const arr = [] if (jsondata.class) { // 有些网站返回的分类名里会含有一串包含在{}内的字符串,移除掉 @@ -218,7 +219,7 @@ const zy = { axios.get(url, { timeout: 3000 }).then(res => { const data = res.data const json = parser.parse(data, this.xmlConfig) - const jsondata = json.rss === undefined ? json : json.rss + const jsondata = json?.rss === undefined ? json : json.rss if (json && jsondata && jsondata.list) { let videoList = jsondata.list.video if (Object.prototype.toString.call(videoList) === '[object Object]') videoList = [].concat(videoList) @@ -228,6 +229,8 @@ const zy = { } else { resolve() } + } else { + resolve() } }).catch(err => { reject(err) @@ -250,8 +253,9 @@ const zy = { axios.get(url).then(res => { const data = res.data const json = parser.parse(data, this.xmlConfig) - const jsondata = json.rss === undefined ? json : json.rss - const videoList = jsondata.list.video + const jsondata = json?.rss === undefined ? json : json.rss + const videoList = jsondata?.list?.video + if (!videoList) resolve() // Parse video lists let fullList = [] let index = 0