Files
RSSHub/lib/routes/mzitu/post.js
T
2018-12-26 18:35:10 +08:00

36 lines
962 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
const axios = require('../../utils/axios');
module.exports = async (ctx) => {
const { id } = ctx.params;
const contentUrl = `http://adr.meizitu.net/wp-json/wp/v2/i?id=${id}`;
const postUrl = `http://adr.meizitu.net/wp-json/wp/v2/posts/${id}`;
const link = `http://www.mzitu.com/${id}`;
const contentResponse = await axios({
method: 'get',
url: contentUrl,
});
const content = contentResponse.data.content.split(',');
const postResponse = await axios({
method: 'get',
url: postUrl,
});
const { title } = postResponse.data;
ctx.state.data = {
title: title,
link,
item: content.map((url, index) => {
url = url.replace(/"/g, '');
return {
title: `${title}(${index + 1})`,
description: `<img referrerpolicy="no-referrer" src="${url}">`,
link: url,
};
}),
};
};