From ac0e92205739bc401f4f4ff9c806543c92877f5a Mon Sep 17 00:00:00 2001 From: Trim21 Date: Sat, 15 May 2021 11:10:30 +0800 Subject: [PATCH] fix(route): eztv empty response (#7514) --- lib/routes/eztv/imdb.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/routes/eztv/imdb.js b/lib/routes/eztv/imdb.js index 0e70a67d6c..f744b88ae0 100644 --- a/lib/routes/eztv/imdb.js +++ b/lib/routes/eztv/imdb.js @@ -1,3 +1,5 @@ +const dayjs = require('dayjs'); + const got = require('@/utils/got'); module.exports = async (ctx) => { @@ -11,18 +13,22 @@ module.exports = async (ctx) => { }, }); - const { torrents } = response.data; + let torrents = []; + if (response.data.torrents_count !== 0) { + torrents = response.data.torrents; + } ctx.state.data = { title: `EZTV's Torrents of IMBD ID: ${imdb_id}`, link: 'https://eztv.it', description: `EZTV's Torrents of IMBD ID: ${imdb_id}`, + allowEmpty: true, item: torrents.map((item) => ({ title: item.title, - description: ``, + description: ``, enclosure_url: item.magnet_url, enclosure_type: 'application/x-bittorrent', - pubDate: new Date(item.date_released_unix * 1000).toUTCString(), + pubDate: dayjs.unix(item.date_released_unix).toDate(), link: item.torrent_url, })), };