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

This commit is contained in:
Trim21
2021-05-14 23:10:30 -04:00
committed by GitHub
parent 65e74a1c5e
commit ac0e922057
+9 -3
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,
})),
};