Fix invalid pubDate (#1425)

根据 https://travis-ci.org/DIYgod/RSSHub/builds/478233072 修正了大部分无效的 pubDate

prprpr
This commit is contained in:
imlonghao 2019-01-17 23:56:26 +08:00 committed by DIYgod
parent c7961a241e
commit 7e43bd2f2c
38 changed files with 75 additions and 60 deletions

View File

@ -1,16 +1,23 @@
const axios = require('../../utils/axios');
const { DateTime } = require('luxon');
module.exports = async (ctx) => {
const { new_anime } = await axios.get('https://api.gamer.com.tw/mobile_app/anime/v1/index.php').then((r) => r.data);
ctx.state.data = {
title: '動畫瘋最後更新',
link: 'https://ani.gamer.com.tw/',
item: new_anime.date.map((item) => ({
title: item.title,
description: item.info,
link: `https://ani.gamer.com.tw/animeRef.php?sn=${item.anime_sn}`,
pubDate: DateTime.fromFormat(item.info.split(' ')[0], 'mm/dd').toRFC2822(),
})),
item: new_anime.date.map((item) => {
const date = new Date();
const month = item.info.split('/')[0] - 1;
const day = item.info.split(' ')[0].split('/')[1];
const pubdatetemp = new Date(date.getFullYear(), month, day);
const pubdate = pubdatetemp > date ? new Date(date.getFullYear() - 1, month, day) : pubdatetemp;
return {
title: item.title,
description: item.info,
link: `https://ani.gamer.com.tw/animeRef.php?sn=${item.anime_sn}`,
pubDate: pubdate.toUTCString(),
};
}),
};
};

View File

@ -17,10 +17,12 @@ module.exports = async (ctx) => {
.find('.vul-type-item')
.text()
.replace(/\s+/g, '');
const date = item
.find('td:nth-last-child(2)')
.text()
.replace(/\s+/g, '');
const date = new Date(
item
.find('td:nth-last-child(2)')
.text()
.replace(/\s+/g, '')
).toUTCString();
const href = item.find('a').attr('href');
return {

View File

@ -1,6 +1,5 @@
const axios = require('../../../utils/axios');
const cheerio = require('cheerio');
const DateTime = require('luxon').DateTime;
module.exports = async (ctx) => {
// bangumi.tv未提供获取小组话题的API因此仍需要通过抓取网页来获取
@ -38,7 +37,7 @@ module.exports = async (ctx) => {
title: `${c.author}回复了小组话题《${title}`,
description: c.content,
guid: c.id,
pubDate: DateTime.fromFormat(c.date, 'yyyy-L-dd HH:mm'),
pubDate: new Date(c.date).toUTCString(),
link,
})),
};

View File

@ -1,6 +1,5 @@
const axios = require('../../../utils/axios');
const cheerio = require('cheerio');
const DateTime = require('luxon').DateTime;
const resolve_url = require('url').resolve;
const base_url = 'https://bgm.tv/';
@ -19,7 +18,7 @@ module.exports = async (ctx) => {
.map((_, elem) => ({
link: resolve_url(base_url, $('.subject a', elem).attr('href')),
title: $('.subject a', elem).attr('title'),
pubDate: DateTime.fromFormat($('.lastpost .time', elem).text(), 'yyyy-L-dd'),
pubDate: new Date($('.lastpost .time', elem).text()).toUTCString(),
description: 'Author: ' + $('.author a', elem).text() + '<br>' + 'Replay: ' + $('.posts', elem).text(),
}))
.get(),

View File

@ -28,7 +28,7 @@ module.exports = async (ctx) => {
title: `${personName}${c.job}的身份参与了作品《${c.work}`,
description: c.workInfo,
link: c.workURL,
pubDate: new Date(c.workInfo.substring(0, c.workInfo.indexOf(' /'))).toUTCString(),
pubDate: c.workInfo.substring(0, c.workInfo.indexOf(' /')) === '' ? new Date(0).toUTCString() : new Date(c.workInfo.substring(0, c.workInfo.indexOf(' /'))).toUTCString(),
})),
};
};

View File

@ -54,7 +54,7 @@ module.exports = async (ctx) => {
link: itemLink,
author: author,
description: description,
pubDate: new Date(item.createTime),
pubDate: new Date(item.createTime).toUTCString(),
};
return single;

View File

@ -26,7 +26,7 @@ module.exports = async (ctx) => {
title: title,
link: link,
author: author,
pubDate: new Date(item.passtime * 1000),
pubDate: new Date(item.passtime * 1000).toUTCString(),
description: description,
};

View File

@ -35,7 +35,7 @@ module.exports = async (ctx) => {
item: data.archives.map((item) => ({
title: item.title,
description: `${item.desc}<br><img referrerpolicy="no-referrer" src="${item.pic}">`,
pubDate: new Date(item.fav_at * 1000).toUTCString(),
pubDate: new Date(item.pubdate * 1000).toUTCString(),
link: `https://www.bilibili.com/video/av${item.aid}`,
})),
};

View File

@ -22,7 +22,7 @@ module.exports = async (ctx) => {
item.title = data.app.name + ' ' + data.app.releases.master.version + '(' + data.app.releases.master.build + ')';
item.description = data.app.releases.master.changelog;
item.link = `https://fir.im/x9zu?release_id=${data.app.releases.master.id}`;
item.pubDate = new Date(data.app.releases.master.created_at * 1000);
item.pubDate = new Date(data.app.releases.master.created_at * 1000).toUTCString();
ctx.state.data = {
title: title,
link: webUrl,

View File

@ -28,11 +28,12 @@ module.exports = async (ctx) => {
const time = `${item.find('.month').text()}${item.find('.day').text()}`;
const date = new Date();
const math = /(\d+)月(\d+)日/.exec(time);
const pubdate = new Date(date.getFullYear(), parseInt(math[1]) - 1, math[2]);
return {
title: item.find('h1').text(),
description: `${item.find('.info p').text()}`,
pubDate: new Date(date.getFullYear(), parseInt(math[1]) - 1, math[2]).toUTCString(),
pubDate: pubdate > date ? new Date(date.getFullYear() - 1, parseInt(math[1]) - 1, math[2]).toUTCString() : pubdate.toUTCString(),
link: item.find('h1 a').attr('href'),
};
})

View File

@ -60,7 +60,7 @@ module.exports = async (ctx) => {
title: title,
link: link,
guid: link,
pubDate: pubDate,
pubDate: pubDate.toUTCString(),
description: `<p>${author}</p>${desc}`,
};
return Promise.resolve(single);

View File

@ -45,7 +45,7 @@ module.exports = async (ctx) => {
link: `https://minapp.com/article/${item.id}`,
author: item.created_by.nickname,
description: item.content,
pubDate: new Date(item.created_at * 1000),
pubDate: new Date(item.created_at * 1000).toUTCString(),
}));
ctx.state.data = {

View File

@ -23,7 +23,7 @@ function getPubDate(time) {
return new Date(`${year}-${month}-${date} ${time}`);
}
if (isNormalDate(time)) {
return new Date(`${year}-${time}`);
return new Date(`${year}-${time}`) > now ? new Date(`${year - 1}-${time}`) : new Date(`${year}-${time}`);
}
if (isDate(time)) {
return new Date(time);

View File

@ -55,7 +55,7 @@ module.exports = async (ctx) => {
.html()
.replace(/src=".\//g, `src="${url.resolve(itemUrl, '.')}`)
.trim(),
pubDate: new Date(item.date),
pubDate: new Date(item.date).toUTCString(),
};
ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60);
return Promise.resolve(single);

View File

@ -28,7 +28,7 @@ module.exports = async (ctx) => {
.map((_, elem) => ({
link: url.resolve(pageUrl, elem.attribs.href),
title: elem.attribs.title,
pubDate: new Date(elem.attribs.href.replace(entryUrlRegex, '$1-$2-$3')),
pubDate: new Date(elem.attribs.href.replace(entryUrlRegex, '$1-$2-$3')).toUTCString(),
}))
.get(),
};

View File

@ -28,7 +28,7 @@ module.exports = async (ctx) => {
.map((_, elem) => ({
link: url.resolve(pageUrl, elem.attribs.href),
title: elem.attribs.title,
pubDate: new Date(elem.attribs.href.replace(entryUrlRegex, '$1-$2-$3')),
pubDate: new Date(elem.attribs.href.replace(entryUrlRegex, '$1-$2-$3')).toUTCString(),
}))
.get(),
};

View File

@ -18,7 +18,7 @@ module.exports = async (ctx) => {
.first()
.text()
.replace('[', '')
),
).toUTCString(),
link: url.resolve(baseUrl, $('a', el).attr('href')),
title: $('a', el).attr('title'),
}))

View File

@ -28,6 +28,7 @@ const map = {
module.exports = async (ctx) => {
const type = ctx.params.type || 'all';
const link = `${base_url}${map[type]}`;
const date = new Date();
const response = await axios({
method: 'get',
@ -43,10 +44,14 @@ module.exports = async (ctx) => {
link: link,
title: $('title').text(),
item: $('.pg-list>ul>li')
.slice(0, 35)
.map((_, elem) => ({
link: resolve_url(link, $('a', elem).attr('href')),
title: $('a', elem).text(),
pubDate: new Date($('span.food-time', elem).text()).toUTCString(),
pubDate:
new Date(`${date.getFullYear()}-${$('span.food-time', elem).text()}`) > date
? new Date(`${date.getFullYear() - 1}-${$('span.food-time', elem).text()}`).toUTCString()
: new Date(`${date.getFullYear()}-${$('span.food-time', elem).text()}`).toUTCString(),
}))
.get(),
};

View File

@ -22,11 +22,10 @@ module.exports = async (ctx) => {
item:
data.data &&
data.data.map((item) => {
const { meet_day = '', meet_time = '', company_name = '', school_name = '', address = '', company_property = '', industry_category = '', recommend_time = '', career_talk_id = '' } = item;
const { meet_day = '', meet_time = '', company_name = '', school_name = '', address = '', company_property = '', industry_category = '', career_talk_id = '' } = item;
return {
title: `${meet_day} ${meet_time}${company_name}`,
description: `时间:${meet_day} ${meet_time}<br>地点:${school_name ? `${school_name}-${address}` : address}<br>类别:${company_property}<br>行业类别:${industry_category}`,
pubDate: new Date(recommend_time).toUTCString(),
link: url.resolve(baseUrl, `/detail/career?id=${career_talk_id}`),
};
}),

View File

@ -21,11 +21,10 @@ module.exports = async (ctx) => {
item:
data.data &&
data.data.map((item) => {
const { meet_day = '', meet_time = '', title = '', school_name = '', address = '', recommend_time = '', fair_id = '' } = item;
const { meet_day = '', meet_time = '', title = '', school_name = '', address = '', fair_id = '' } = item;
return {
title: `${meet_day} ${meet_time}${title}`,
description: `时间:${meet_day} ${meet_time}<br>地点:${school_name ? `${school_name}-${address}` : address}`,
pubDate: new Date(recommend_time).toUTCString(),
link: url.resolve(baseUrl, `/detail/jobfair?id=${fair_id}`),
};
}),

View File

@ -41,7 +41,7 @@ module.exports = async (ctx) => {
.match(dataRegex)[0]
.split('/')
.join('-')
),
).toUTCString(),
}))
.get(),
};

View File

@ -32,7 +32,7 @@ module.exports = async (ctx) => {
return {
title: item.find('a').text(),
link: `${baseURL + $(item.find('a')).attr('href')}`,
pubDate: new Date(item.find('Article_PublishDate').text()).toUTCString(),
pubDate: new Date(item.find('.Article_PublishDate').text()).toUTCString(),
};
})
.get(),

View File

@ -68,7 +68,7 @@ module.exports = async (ctx) => {
title: title,
link: itemUrl,
description: description,
pubDate: new Date(date),
pubDate: new Date(date).toUTCString(),
};
ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60);
return Promise.resolve(single);

View File

@ -19,7 +19,7 @@ async function load(link) {
.text()
.slice(-10)
.match(/\d{4}-\d{2}-\d{2}/)
);
).toUTCString();
const images = $('img');
for (let k = 0; k < images.length; k++) {
$(images[k]).replaceWith(`<img src="${url.resolve(host, $(images[k]).attr('src'))}" referrerpolicy="no-referrer" />`);

View File

@ -11,7 +11,9 @@ module.exports = async (ctx) => {
});
const data = res.data;
const $ = cheerio.load(data);
const list = $('.listshow').find('li');
const list = $('.listshow')
.find('li')
.not('li.line');
ctx.state.data = {
title: $('title').text(),

View File

@ -60,7 +60,7 @@ module.exports = async (ctx) => {
.html()
.replace(/src="\//g, `src="${url.resolve(host, '.')}`)
.trim(),
pubDate: new Date(date),
pubDate: new Date(date).toUTCString(),
};
ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60);
return Promise.resolve(single);

View File

@ -43,7 +43,7 @@ module.exports = async (ctx) => {
.trim(),
link: itemUrl,
description: $('.rich_media_content').text(),
pubDate: new Date(info.date),
pubDate: new Date(info.date).toUTCString(),
};
ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60);
return Promise.resolve(single);
@ -62,7 +62,7 @@ module.exports = async (ctx) => {
$('.arti_update')
.text()
.replace('发布时间:', '')
),
).toUTCString(),
};
ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60);
return Promise.resolve(single);

View File

@ -39,10 +39,12 @@ module.exports = async (ctx) => {
.find('.department')
.text()
.trim(),
pubDate: item
.find('span')
.find('span')
.attr('content'),
pubDate: new Date(
item
.find('span')
.find('span')
.attr('content')
).toUTCString(),
link: host + item.find('a').attr('href'),
};
})

View File

@ -36,7 +36,7 @@ module.exports = async (ctx) => {
$('.date_1 span:first-of-type')
.text()
.trim()
),
).toUTCString(),
};
ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60);
return Promise.resolve(single);

View File

@ -42,7 +42,7 @@ module.exports = async (ctx) => {
link: itemUrl,
author: '上海交通大学电子信息与电气工程学院本科教务办',
description: $('.article_content').text(),
pubDate: new Date(item.date),
pubDate: new Date(item.date).toUTCString(),
};
ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60);
return Promise.resolve(single);

View File

@ -42,7 +42,7 @@ module.exports = async (ctx) => {
link: itemUrl,
author: '上海交通大学电子信息与电气工程学院本科教务办',
description: $('.article_content').text(),
pubDate: new Date(item.date),
pubDate: new Date(item.date).toUTCString(),
};
ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60);
return Promise.resolve(single);

View File

@ -42,7 +42,7 @@ module.exports = async (ctx) => {
link: itemUrl,
author: '上海交通大学电子信息与电气工程学院本科教务办',
description: $('.article_content').text(),
pubDate: new Date(item.date),
pubDate: new Date(item.date).toUTCString(),
};
ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60);
return Promise.resolve(single);

View File

@ -42,7 +42,7 @@ module.exports = async (ctx) => {
link: itemUrl,
author: '上海交通大学电子信息与电气工程学院本科教务办',
description: $('.article_content').text(),
pubDate: new Date(item.date),
pubDate: new Date(item.date).toUTCString(),
};
ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60);
return Promise.resolve(single);

View File

@ -42,7 +42,7 @@ module.exports = async (ctx) => {
link: itemUrl,
author: '上海交通大学电子信息与电气工程学院本科教务办',
description: $('.article_content').text(),
pubDate: new Date(item.date),
pubDate: new Date(item.date).toUTCString(),
};
ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60);
return Promise.resolve(single);

View File

@ -71,7 +71,7 @@ module.exports = async (ctx) => {
description: $('.article_box')
.text()
.slice(0, -7),
pubDate: new Date(item.date),
pubDate: new Date(item.date).toUTCString(),
};
ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60);
return Promise.resolve(single);

View File

@ -33,7 +33,7 @@ module.exports = async (ctx) => {
resultItem = {
title: title,
link: link,
pubDate: new Date(date),
pubDate: new Date(date).toUTCString(),
author: author,
};

View File

@ -39,7 +39,7 @@ module.exports = async (ctx) => {
resultItem = {
title: title,
link: link,
pubDate: new Date(date),
pubDate: new Date(date).toUTCString(),
author: author,
};

View File

@ -11,7 +11,7 @@ module.exports = async (ctx) => {
const res2 = await axios({
method: 'get',
url: 'https://xueqiu.com/v4/stock/portfolio/stocks.json?size=10000&type=1&pid=-1&category=2',
url: 'https://stock.xueqiu.com/v5/stock/portfolio/stock/list.json?category=1&size=1000',
params: {
uid: id,
},
@ -20,7 +20,7 @@ module.exports = async (ctx) => {
Referer: `https://xueqiu.com/u/${id}`,
},
});
const data = res2.data.stocks;
const data = res2.data.data.stocks;
const res3 = await axios({
method: 'get',
@ -40,10 +40,10 @@ module.exports = async (ctx) => {
link: `https://xueqiu.com/u/${id}`,
description: `@${screen_name} 的雪球自选动态`,
item: data.map((item) => ({
title: `@${screen_name} 关注了股票 ${item.stockName}`,
description: `@${screen_name}${new Date(item.createAt).toLocaleString()} 关注了 ${item.stockName}(${item.exchange}:${item.code})。`,
pubDate: new Date(item.createAt).toUTCString(),
link: `https://xueqiu.com/s/${item.code}`,
title: `@${screen_name} 关注了股票 ${item.name}`,
description: `@${screen_name}${new Date(item.created).toLocaleString()} 关注了 ${item.name}(${item.exchange}:${item.symbol})。`,
pubDate: new Date(item.created).toUTCString(),
link: `https://xueqiu.com/s/${item.symbol}`,
})),
};
};