forked from DIYgod/RSSHub
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
64 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,9 @@ | ||
const axios = require('../../utils/axios'); | ||
const cheerio = require('cheerio'); | ||
const dayjs = require('dayjs'); | ||
const utils = require('./utils'); | ||
|
||
module.exports = async (ctx) => { | ||
const id = ctx.params.id; | ||
const link = `https://www.dongqiudi.com/player/${id}.html`; | ||
const api = `https://www.dongqiudi.com/data/person/archive?person=${id}`; | ||
|
||
const axios_ins = axios.create({ | ||
headers: { | ||
'X-Requested-With': 'XMLHttpRequest', | ||
Referer: link, | ||
}, | ||
}); | ||
|
||
const response = await axios_ins.get(link); | ||
const $ = cheerio.load(response.data); | ||
const playerName = `${$('h1.name').text()} ${$('span.en_name').text()}`; | ||
|
||
const list = (await axios_ins.get(api)).data.data; | ||
|
||
const out = await Promise.all( | ||
list.map(async (item) => { | ||
const itemUrl = item.web_url; | ||
const res = await axios_ins.get(itemUrl); | ||
const content = cheerio.load(res.data); | ||
|
||
if (itemUrl.includes('/video/')) { | ||
content('div.video').each((i, v) => { | ||
const link = v.attribs.src; | ||
content('div.video').replaceWith(`<video width="100%" controls> <source src="${link}" type="video/mp4"> Your RSS reader does not support video playback. </video>`); | ||
}); | ||
} | ||
|
||
const serverOffset = new Date().getTimezoneOffset() / 60; | ||
const single = { | ||
title: content('h1').text(), | ||
guid: itemUrl, | ||
link: itemUrl, | ||
description: content('#con > div.left > div.detail > div:nth-child(3)').html(), | ||
pubDate: dayjs(content('#con h4 span.time').text()) | ||
.add(-8 - serverOffset, 'hour') | ||
.toISOString(), | ||
author: content('#con h4 span.name').text(), | ||
}; | ||
return Promise.resolve(single); | ||
}) | ||
); | ||
|
||
ctx.state.data = { | ||
title: `${playerName} - 相关新闻`, | ||
link, | ||
item: out, | ||
}; | ||
await utils.ProcessFeed(ctx, link, api); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,9 @@ | ||
const axios = require('../../utils/axios'); | ||
const cheerio = require('cheerio'); | ||
const dayjs = require('dayjs'); | ||
const utils = require('./utils'); | ||
|
||
module.exports = async (ctx) => { | ||
const team = ctx.params.team; | ||
const link = `https://www.dongqiudi.com/team/${team}.html`; | ||
const api = `https://www.dongqiudi.com/data/team/archive?team=${team}`; | ||
|
||
const axios_ins = axios.create({ | ||
headers: { | ||
'X-Requested-With': 'XMLHttpRequest', | ||
Referer: link, | ||
}, | ||
}); | ||
|
||
const response = await axios_ins.get(link); | ||
const $ = cheerio.load(response.data); | ||
const teamName = $('h1.name').text(); | ||
|
||
const list = (await axios_ins.get(api)).data.data; | ||
|
||
const out = await Promise.all( | ||
list.map(async (item) => { | ||
const itemUrl = item.web_url; | ||
const res = await axios_ins.get(itemUrl); | ||
const content = cheerio.load(res.data); | ||
|
||
if (itemUrl.includes('/video/')) { | ||
content('div.video').each((i, v) => { | ||
const link = v.attribs.src; | ||
content('div.video').replaceWith(`<video width="100%" controls> <source src="${link}" type="video/mp4"> Your RSS reader does not support video playback. </video>`); | ||
}); | ||
} | ||
|
||
const serverOffset = new Date().getTimezoneOffset() / 60; | ||
const single = { | ||
title: content('h1').text(), | ||
guid: itemUrl, | ||
link: itemUrl, | ||
description: content('#con > div.left > div.detail > div:nth-child(3)').html(), | ||
pubDate: dayjs(content('#con h4 span.time').text()) | ||
.add(-8 - serverOffset, 'hour') | ||
.toISOString(), | ||
author: content('#con h4 span.name').text(), | ||
}; | ||
return Promise.resolve(single); | ||
}) | ||
); | ||
|
||
ctx.state.data = { | ||
title: `${teamName} - 相关新闻`, | ||
link, | ||
item: out, | ||
}; | ||
await utils.ProcessFeed(ctx, link, api); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
const dayjs = require('dayjs'); | ||
const cheerio = require('cheerio'); | ||
const axios = require('../../utils/axios'); | ||
|
||
module.exports = { | ||
ProcessFeed: async (ctx, link, api) => { | ||
const axios_ins = axios.create({ | ||
headers: { | ||
'X-Requested-With': 'XMLHttpRequest', | ||
Referer: link, | ||
}, | ||
}); | ||
|
||
const response = await axios_ins.get(link); | ||
const $ = cheerio.load(response.data); | ||
const name = `${$('h1.name').text()} ${$('span.en_name').text()}`; | ||
|
||
const list = (await axios_ins.get(api)).data.data; | ||
const out = await Promise.all( | ||
list.map(async (item) => { | ||
const itemUrl = item.web_url; | ||
const res = await axios_ins.get(itemUrl); | ||
const content = cheerio.load(res.data); | ||
|
||
content('div.video').each((i, v) => { | ||
const link = v.attribs.src; | ||
switch (v.attribs.site) { | ||
case 'qiniu': | ||
content('div.video').replaceWith(`<video width="100%" controls> <source src="${link}" type="video/mp4"> Your RSS reader does not support video playback. </video>`); | ||
break; | ||
case 'youku': | ||
content('div.video').replaceWith(`<iframe height='100%' width='100%' src='${link}' frameborder=0 scrolling=no webkitallowfullscreen=true allowfullscreen=true></iframe>`); | ||
break; | ||
default: | ||
break; | ||
} | ||
}); | ||
|
||
const serverOffset = new Date().getTimezoneOffset() / 60; | ||
const single = { | ||
title: content('h1').text(), | ||
guid: itemUrl, | ||
link: itemUrl, | ||
description: content('#con > div.left > div.detail > div:nth-child(3)').html(), | ||
pubDate: dayjs(content('#con h4 span.time').text()) | ||
.add(-8 - serverOffset, 'hour') | ||
.toISOString(), | ||
author: content('#con h4 span.name').text(), | ||
}; | ||
return Promise.resolve(single); | ||
}) | ||
); | ||
|
||
ctx.state.data = { | ||
title: `${name} - 相关新闻`, | ||
link, | ||
item: out, | ||
}; | ||
}, | ||
}; |