Skip to content

Commit

Permalink
fix(route): eztv empty response (DIYgod#7514)
Browse files Browse the repository at this point in the history
  • Loading branch information
trim21 authored May 15, 2021
1 parent 65e74a1 commit ac0e922
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lib/routes/eztv/imdb.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const dayjs = require('dayjs');

const got = require('@/utils/got');

module.exports = async (ctx) => {
Expand All @@ -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,
})),
};
Expand Down

0 comments on commit ac0e922

Please sign in to comment.