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.
Merge pull request #1031 from DIYgod/master
[pull] master from diygod:master
- Loading branch information
Showing
96 changed files
with
2,495 additions
and
1,313 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
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
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
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
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
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
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
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,3 @@ | ||
module.exports = { | ||
'/:configId/posts': ['dzx-dzx'], | ||
}; |
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,28 @@ | ||
const config = require('@/config').value; | ||
const got = require('@/utils/got'); | ||
const RSSParser = require('@/utils/rss-parser'); | ||
|
||
module.exports = async (ctx) => { | ||
if (!config.discourse.config[ctx.params.configId]) { | ||
throw Error('Discourse RSS is disabled due to the lack of <a href="https://docs.rsshub.app/install">relevant config</a>'); | ||
} | ||
const { link, key } = config.discourse.config[ctx.params.configId]; | ||
|
||
const feed = await RSSParser.parseString( | ||
( | ||
await got(`${link}/posts.rss`, { | ||
headers: { | ||
'User-Api-Key': key, | ||
}, | ||
}) | ||
).data | ||
); | ||
|
||
feed.items = feed.items.map((e) => ({ | ||
description: e.content, | ||
author: e.creator, | ||
...e, | ||
})); | ||
|
||
ctx.state.data = { item: feed.items, ...feed }; | ||
}; |
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,3 @@ | ||
module.exports = (router) => { | ||
router.get('/:configId/posts', require('./posts')); | ||
}; |
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,81 @@ | ||
const cheerio = require('cheerio'); | ||
const got = require('@/utils/got'); | ||
const { getData, getList } = require('./utils'); | ||
const { art } = require('@/utils/render'); | ||
const path = require('path'); | ||
const asyncPool = require('tiny-async-pool'); | ||
|
||
const _website = 'dlnews'; | ||
const topics = { | ||
defi: 'DeFi', | ||
fintech: 'Fintech/VC/Deals', | ||
'llama-u': 'Llama U', | ||
markets: 'Markets', | ||
'people-culture': 'People & Culture', | ||
regulation: 'Regulation', | ||
snapshot: 'Snapshot', | ||
web3: 'Web3', | ||
}; | ||
const extractArticle = (ctx, item) => | ||
ctx.cache.tryGet(item.link, async () => { | ||
const { data: response } = await got(item.link); | ||
const $ = cheerio.load(response); | ||
const scriptTagContent = $('script#fusion-metadata').text(); | ||
const jsonData = JSON.parse(scriptTagContent.match(/Fusion\.globalContent=({.*?});Fusion\.globalContentConfig/)[1]).content_elements; | ||
const filteredData = []; | ||
for (const v of jsonData) { | ||
if (v.type === 'header' && v.content.includes('What we’re reading')) { | ||
break; | ||
} else if (v.type === 'custom_embed' && Boolean(v.embed.config.text)) { | ||
filteredData.push({ type: v.type, data: v.embed.config.text }); | ||
} else if (v.type === 'text' && !v.content.includes('<b>NOW READ: </b>')) { | ||
filteredData.push({ type: v.type, data: v.content }); | ||
} else if (v.type === 'header') { | ||
filteredData.push({ type: v.type, data: v.content }); | ||
} else if (v.type === 'list') { | ||
filteredData.push({ type: v.type, list_type: v.list_type, items: v.items }); | ||
} else if (v.type === 'image') { | ||
filteredData.push({ type: v.type, src: v.url, alt: v.alt_text, caption: v.subtitle }); | ||
} | ||
} | ||
item.description = art(path.resolve(__dirname, 'templates/description.art'), filteredData); | ||
return item; | ||
}); | ||
|
||
module.exports = async (ctx) => { | ||
const { category } = ctx.params; | ||
const baseUrl = 'https://www.dlnews.com'; | ||
const apiPath = '/pf/api/v3/content/fetch/articles-api'; | ||
let vertical; | ||
if (category) { | ||
vertical = category; | ||
} else { | ||
vertical = ''; | ||
} | ||
|
||
const query = { | ||
author: '', | ||
date: 'now-1y/d', | ||
offset: 0, | ||
query: '', | ||
size: 15, | ||
sort: 'display_date:desc', | ||
vertical, | ||
}; | ||
const data = await getData(`${baseUrl}${apiPath}?query=${encodeURIComponent(JSON.stringify(query))}&_website=${_website}`); | ||
const list = getList(data); | ||
const items = []; | ||
for await (const data of asyncPool(3, list, (item) => extractArticle(ctx, item))) { | ||
items.push(data); | ||
} | ||
|
||
ctx.state.data = { | ||
title: topics.hasOwnProperty(category) ? `${topics[category]} : DL News` : 'DL News', | ||
link: baseUrl, | ||
item: items, | ||
description: topics.hasOwnProperty(category) ? `${topics[category]} : News on dlnews.com` : 'Latest News on dlnews.com', | ||
logo: 'https://www.dlnews.com/pf/resources/favicon.ico?d=284', | ||
icon: 'https://www.dlnews.com/pf/resources/favicon.ico?d=284', | ||
language: 'en-us', | ||
}; | ||
}; |
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,3 @@ | ||
module.exports = { | ||
'/:category?': ['Rjnishant530'], | ||
}; |
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,19 @@ | ||
module.exports = { | ||
'dlnews.com': { | ||
_name: 'DL NEWS', | ||
'.': [ | ||
{ | ||
title: 'All Articles', | ||
docs: 'https://docs.rsshub.app/routes/finance#dl-news', | ||
source: ['/articles/'], | ||
target: '/dlnews/', | ||
}, | ||
{ | ||
title: 'Topic', | ||
docs: 'https://docs.rsshub.app/routes/finance#dl-news', | ||
source: ['/articles/:category'], | ||
target: '/dlnews/:category', | ||
}, | ||
], | ||
}, | ||
}; |
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,3 @@ | ||
module.exports = (router) => { | ||
router.get('/:category?', require('./category')); | ||
}; |
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,24 @@ | ||
{{ each $data d }} | ||
{{ if d.type == 'custom_embed' }} | ||
<ul> | ||
{{ each d.data.split('\n') line }} | ||
<li>{{@ line }}</li> | ||
{{ /each }} | ||
</ul> | ||
{{ else if d.type == 'header' }} | ||
<h2>{{@ d.data }}</h2> | ||
{{ else if d.type == 'list' }} | ||
{{ if d.list_type == 'unordered' }}<ul>{{ else }}<ol>{{ /if }} | ||
{{ each d.items item }} | ||
<li>{{@ item.content }}</li> | ||
{{ /each }} | ||
{{ if d.list_type == 'unordered' }}</ul>{{ else }}</ol>{{ /if }} | ||
{{ else if d.type == 'image' }} | ||
<figure> | ||
<img src="{{ d.src }}" alt="{{ d.alt }}"> | ||
<figcaption>{{@ d.caption }}</figcaption> | ||
</figure> | ||
{{ else if d.type == 'text' }} | ||
<p>{{@ d.data }}</p> | ||
{{ /if }} | ||
{{ /each }} |
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,22 @@ | ||
const got = require('@/utils/got'); | ||
const { parseDate } = require('@/utils/parse-date'); | ||
|
||
const baseUrl = 'https://www.dlnews.com'; | ||
const getData = async (url) => (await got.get(url).json()).content_elements; | ||
|
||
const getList = (data) => | ||
data.map((value) => { | ||
const { _id, headlines, description, publish_date, website_url, taxonomy, credits, promo_items } = value; | ||
return { | ||
id: _id, | ||
title: headlines.basic, | ||
link: `${baseUrl}${website_url}`, | ||
description: description.basic, | ||
author: credits.by.map((v) => v.name).join(', '), | ||
itunes_item_image: promo_items.basic.url, | ||
pubDate: parseDate(publish_date), | ||
category: taxonomy.sections.map((v) => v.name).join(', '), | ||
}; | ||
}); | ||
|
||
module.exports = { getData, getList }; |
Oops, something went wrong.
dc61635
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
rsshub-master – ./
rsshub-master.vercel.app
rsshub-master-auto-bot-ty.vercel.app
rsshub-master-git-master-auto-bot-ty.vercel.app