Skip to content

Commit

Permalink
fix(route): migrate smzdm to new time parser, re DIYgod#6795 (DIYgod#…
Browse files Browse the repository at this point in the history
  • Loading branch information
cokemine authored May 12, 2021
1 parent b689e95 commit c06864c
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 13 deletions.
5 changes: 3 additions & 2 deletions lib/routes/smzdm/article.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const date = require('@/utils/date');
const parseDate = require('@/utils/parse-date');
const timezone = require('@/utils/timezone');

module.exports = async (ctx) => {
const link = `https://zhiyou.smzdm.com/member/${ctx.params.uid}/article/`;
Expand Down Expand Up @@ -41,7 +42,7 @@ module.exports = async (ctx) => {
title: title,
link: itemUrl,
description: description,
pubDate: date(pubdate),
pubDate: timezone(parseDate(pubdate, 'MM-DD H:mm'), +8),
};
ctx.cache.set(itemUrl, JSON.stringify(single));
return Promise.resolve(single);
Expand Down
3 changes: 1 addition & 2 deletions lib/routes/smzdm/baoliao.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const date = require('@/utils/date');

module.exports = async (ctx) => {
const link = `https://zhiyou.smzdm.com/member/${ctx.params.uid}/baoliao/`;
Expand Down Expand Up @@ -41,7 +40,7 @@ module.exports = async (ctx) => {
title: title,
link: itemUrl,
description: description,
pubDate: date(pubdate),
pubDate: new Date(pubdate),
};
ctx.cache.set(itemUrl, JSON.stringify(single));
return Promise.resolve(single);
Expand Down
5 changes: 3 additions & 2 deletions lib/routes/smzdm/haowen.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const date = require('@/utils/date');
const parseDate = require('@/utils/parse-date');
const timezone = require('@/utils/timezone');

module.exports = async (ctx) => {
const day = ctx.params.day || 'all';
Expand Down Expand Up @@ -44,7 +45,7 @@ module.exports = async (ctx) => {
title: title,
link: itemUrl,
description: description,
pubDate: date(pubdate),
pubDate: timezone(parseDate(pubdate, 'H:mm'), +8),
};
ctx.cache.set(itemUrl, JSON.stringify(single));
return Promise.resolve(single);
Expand Down
6 changes: 3 additions & 3 deletions lib/routes/smzdm/haowen_fenlei.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const date = require('@/utils/date');

const timezone = require('@/utils/timezone');
const parseDate = require('@/utils/parse-date');
module.exports = async (ctx) => {
const name = ctx.params.name;
const sort = ctx.params.sort || '0';
Expand Down Expand Up @@ -48,7 +48,7 @@ module.exports = async (ctx) => {
title: title,
link: itemUrl,
description: description,
pubDate: date(pubdate),
pubDate: timezone(parseDate(pubdate, 'H:mm'), +8),
};
ctx.cache.set(itemUrl, JSON.stringify(single));
return Promise.resolve(single);
Expand Down
5 changes: 3 additions & 2 deletions lib/routes/smzdm/keyword.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const formatPubDate = require('@/utils/date.js');
const parseDate = require('@/utils/parse-date');
const timezone = require('@/utils/timezone');

module.exports = async (ctx) => {
const keyword = ctx.params.keyword;
Expand Down Expand Up @@ -29,7 +30,7 @@ module.exports = async (ctx) => {
return {
title: `${item.find('.feed-block-title a').eq(0).text().trim()} - ${item.find('.feed-block-title a').eq(1).text().trim()}`,
description: `${item.find('.feed-block-descripe').contents().eq(2).text().trim()}<br>${item.find('.feed-block-extras span').text().trim()}<br><img src="http:${item.find('.z-feed-img img').attr('src')}">`,
pubDate: formatPubDate(item.find('.feed-block-extras').contents().eq(0).text().trim(), 8),
pubDate: timezone(parseDate(item.find('.feed-block-extras').contents().eq(0).text().trim(), 'H:mm'), +8),
link: `${item.find('.feed-block-title a').attr('href')}`,
};
})
Expand Down
4 changes: 2 additions & 2 deletions lib/routes/smzdm/ranking.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const got = require('@/utils/got');
const date = require('@/utils/date');
const timezone = require('@/utils/timezone');

module.exports = async (ctx) => {
const { rank_type, rank_id, hour } = ctx.params;
Expand Down Expand Up @@ -32,7 +32,7 @@ module.exports = async (ctx) => {
item: list.map((item) => ({
title: `${item.article_title} - ${item.article_price}`,
description: `${item.article_title} - ${item.article_price}<br><img src="${item.article_pic}">`,
pubDate: date(item.article_pubdate, 8),
pubDate: timezone(item.article_pubdate, +8),
link: item.article_url,
})),
};
Expand Down

0 comments on commit c06864c

Please sign in to comment.