diff --git a/lib/routes/dongqiudi/daily.js b/lib/routes/dongqiudi/daily.js
index ab23f1aa0..c58c21034 100644
--- a/lib/routes/dongqiudi/daily.js
+++ b/lib/routes/dongqiudi/daily.js
@@ -1,7 +1,6 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const utils = require('./utils');
-const date = require('@/utils/date');
module.exports = async (ctx) => {
const response = await got.get('https://www.dongqiudi.com/special/48');
@@ -41,24 +40,11 @@ module.exports = async (ctx) => {
const responses = await got.all(proList);
for (let i = 0; i < proList.length; i++) {
- const $ = utils.ProcessVideo(cheerio.load(responses[i].data));
- const full = $('div.detail');
-
- out[i].description = utils.ProcessHref(full.find('div:nth-of-type(1)')).html();
- out[i].author = full.find('span.name').text();
- out[i].pubDate = date(
- full
- .find('span.time')
- .text()
- .trim(),
- 8
- );
-
- ctx.cache.set(out[i].itemUrl, JSON.stringify(out[i]));
+ utils.ProcessFeedType2(out[i], responses[i].data);
}
ctx.state.data = {
title: '懂球帝早报',
link: 'http://www.dongqiudi.com/special/48',
- item: out.filter((e) => e !== undefined),
+ item: out.filter((e) => e.description !== undefined),
};
};
diff --git a/lib/routes/dongqiudi/special.js b/lib/routes/dongqiudi/special.js
index 4f189e2f0..592da0fce 100644
--- a/lib/routes/dongqiudi/special.js
+++ b/lib/routes/dongqiudi/special.js
@@ -1,7 +1,6 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const utils = require('./utils');
-const date = require('@/utils/date');
module.exports = async (ctx) => {
const id = ctx.params.id;
@@ -41,20 +40,7 @@ module.exports = async (ctx) => {
const responses = await got.all(proList);
for (let i = 0; i < proList.length; i++) {
- const $ = utils.ProcessVideo(cheerio.load(responses[i].data));
- const full = $('div.detail');
-
- out[i].description = utils.ProcessHref(full.find('div:nth-of-type(1)')).html();
- out[i].author = full.find('span.name').text();
- out[i].pubDate = date(
- full
- .find('span.time')
- .text()
- .trim(),
- 8
- );
-
- ctx.cache.set(out[i].itemUrl, JSON.stringify(out[i]));
+ utils.ProcessFeedType2(out[i], responses[i].data);
}
ctx.state.data = {
title: `懂球帝专题-${id}`,
diff --git a/lib/routes/dongqiudi/top_news.js b/lib/routes/dongqiudi/top_news.js
index c4e36dbef..be4bfe373 100644
--- a/lib/routes/dongqiudi/top_news.js
+++ b/lib/routes/dongqiudi/top_news.js
@@ -1,7 +1,5 @@
const got = require('@/utils/got');
-const cheerio = require('cheerio');
const utils = require('./utils');
-const date = require('@/utils/date');
module.exports = async (ctx) => {
const id = ctx.params.id || 1;
@@ -34,18 +32,7 @@ module.exports = async (ctx) => {
const responses = await got.all(proList);
for (let i = 0; i < proList.length; i++) {
- const $ = utils.ProcessVideo(cheerio.load(responses[i].data));
- const full = $('div.detail');
-
- out[i].description = utils.ProcessHref(full.find('div:nth-of-type(1)')).html();
- out[i].author = full.find('span.name').text();
- out[i].pubDate = date(
- full
- .find('span.time')
- .text()
- .trim(),
- 8
- );
+ utils.ProcessFeedType2(out[i], responses[i].data);
}
ctx.state.data = {
title: `懂球帝 - ${label}`,
diff --git a/lib/routes/dongqiudi/utils.js b/lib/routes/dongqiudi/utils.js
index e0aa5d87e..26c846c30 100644
--- a/lib/routes/dongqiudi/utils.js
+++ b/lib/routes/dongqiudi/utils.js
@@ -1,24 +1,31 @@
const cheerio = require('cheerio');
const got = require('@/utils/got');
+const url = require('url');
const jsdom = require('jsdom');
const { JSDOM } = jsdom;
const ProcessVideo = (content) => {
content('div.video').each((i, v) => {
- let link = v.attribs.src;
- switch (v.attribs.site) {
- case 'qiniu':
- // 临时解决七牛 CDN 证书过期
- link = link.replace('https://', 'http://');
- content(``).insertAfter(v);
- content(v).remove();
- break;
- case 'youku':
- content(``).insertAfter(v);
- content(v).remove();
- break;
- default:
- break;
+ let link = url.parse(v.attribs.src);
+ if (link.host === 'm.miguvideo.com') {
+ content(` ▶️ 观看视频
`).insertAfter(v);
+ content(v).remove();
+ } else {
+ link = v.attribs.src;
+ switch (v.attribs.site) {
+ case 'qiniu':
+ // 临时解决七牛 CDN 证书过期
+ link = link.replace('https://', 'http://');
+ content(``).insertAfter(v);
+ content(v).remove();
+ break;
+ case 'youku':
+ content(``).insertAfter(v);
+ content(v).remove();
+ break;
+ default:
+ break;
+ }
}
});
@@ -26,7 +33,7 @@ const ProcessVideo = (content) => {
content('iframe.media-iframe, .edui-faked-video').each((i, v) => {
const link = v.attribs.src;
if (link.startsWith('http://ssports.iqiyi.com')) {
- content(`观看视频
`).insertAfter(v);
+ content(` ▶️ 观看视频
`).insertAfter(v);
}
content(v).remove();
@@ -36,16 +43,11 @@ const ProcessVideo = (content) => {
};
const ProcessHref = (content) => {
- content.each((i, v) => {
- cheerio
- .load(v)('a')
- .each((j, y) => {
- if (y.attribs.href) {
- y.attribs.href = y.attribs.href.replace('dongqiudi:///news', 'https://www.dongqiudi.com/share/article');
- }
- });
+ content.each((j, y) => {
+ if (y.attribs.href) {
+ y.attribs.href = y.attribs.href.replace('dongqiudi:///news', 'https://www.dongqiudi.com/share/article');
+ }
});
- return content;
};
const ProcessFeed = async (ctx, link, type) => {
@@ -90,7 +92,7 @@ const ProcessFeed = async (ctx, link, type) => {
}
});
- ProcessHref(content);
+ ProcessHref(content.find('a'));
const single = {
title: item.title,
@@ -111,8 +113,25 @@ const ProcessFeed = async (ctx, link, type) => {
};
};
+const ProcessFeedType2 = (item, response) => {
+ const dom = new JSDOM(response, {
+ runScripts: 'dangerously',
+ });
+
+ const data = dom.window.__NUXT__.data[1].newData;
+
+ if (Object.keys(data).length > 0) {
+ const body = ProcessVideo(cheerio.load(data.body));
+ ProcessHref(body('a'));
+ item.description = body.html();
+ item.author = data.writer;
+ item.pubDate = new Date(data.show_time * 1000).toUTCString();
+ }
+};
+
module.exports = {
ProcessVideo,
ProcessFeed,
+ ProcessFeedType2,
ProcessHref,
};