fix(route): eztv empty response (#7514)

This commit is contained in:
Trim21 2021-05-15 11:10:30 +08:00 committed by GitHub
parent 65e74a1c5e
commit ac0e922057
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 3 deletions

View File

@ -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: `<img src="https:${item.large_screenshot}" />`,
description: `<img src='https:${item.large_screenshot}' />`,
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,
})),
};