diff --git a/lib/v2/douban/other/list.js b/lib/v2/douban/other/list.js index 72e35072e..8e031e63a 100644 --- a/lib/v2/douban/other/list.js +++ b/lib/v2/douban/other/list.js @@ -8,40 +8,54 @@ module.exports = async (ctx) => { const routeParams = Object.fromEntries(new URLSearchParams(ctx.params.routeParams)); const playable = fallback(undefined, queryToInteger(routeParams.playable), 0); const score = fallback(undefined, queryToInteger(routeParams.score), 0); - const url = `https://m.douban.com/rexxar/api/v2/subject_collection/${type}/items?playable=${playable}`; - const response = await got({ - method: 'get', - url, - headers: { - Referer: `https://m.douban.com/subject_collection/${type}`, - }, - }); - const description = response.data.subject_collection.description; - const items = response.data.subject_collection_items - .filter((item) => { - const rate = item.rating ? item.rating.value : 0; - return rate >= score; // 保留rate大于等于score的项and过滤无评分项 - }) - .map((item) => { - const title = item.title; - const link = item.url; - const description = art(path.join(__dirname, '../templates/list_description.art'), { - ranking_value: item.ranking_value, - title, - original_title: item.original_title, - rate: item.rating ? item.rating.value : null, - card_subtitle: item.card_subtitle, - description: item.cards ? item.cards[0].content : item.abstract, - cover: item.cover_url || item.cover?.url, - }); - return { - title, - link, - description, - }; + let start = 0; + const count = 50; + let items = []; + let title = ''; + let description = ''; + let total = null; + while (total === null || start < total) { + const url = `https://m.douban.com/rexxar/api/v2/subject_collection/${type}/items?playable=${playable}&start=${start}&count=${count}`; + // eslint-disable-next-line no-await-in-loop + const response = await got({ + method: 'get', + url, + headers: { + Referer: `https://m.douban.com/subject_collection/${type}`, + }, }); + title = response.data.subject_collection.name; + description = response.data.subject_collection.description; + total = response.data.total; + const newItems = response.data.subject_collection_items + .filter((item) => { + const rate = item.rating ? item.rating.value : 0; + return rate >= score; // 保留rate大于等于score的项and过滤无评分项 + }) + .map((item) => { + const title = item.title; + const link = item.url; + const description = art(path.join(__dirname, '../templates/list_description.art'), { + ranking_value: item.ranking_value, + title, + original_title: item.original_title, + rate: item.rating ? item.rating.value : null, + card_subtitle: item.card_subtitle, + description: item.cards ? item.cards[0].content : item.abstract, + cover: item.cover_url || item.cover?.url, + }); + return { + title, + link, + description, + }; + }); + items = [...items, ...newItems]; + start += count; + } + ctx.state.data = { - title: `豆瓣 - ${response.data.subject_collection.name}`, + title: `豆瓣 - ${title}`, link: `https://m.douban.com/subject_collection/${type}`, item: items, description,