diff --git a/lib/v2/sourceforge/index.js b/lib/v2/sourceforge/index.js new file mode 100644 index 000000000..af4daf59b --- /dev/null +++ b/lib/v2/sourceforge/index.js @@ -0,0 +1,33 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); + +module.exports = async (ctx) => { + const routeParams = ctx.params.routeParams; + + const baseURL = 'https://sourceforge.net'; + const link = `https://sourceforge.net/directory/?${routeParams.toString()}`; + + const response = await got.get(link); + const $ = cheerio.load(response.data); + const itemList = $('ul.projects li[itemprop=itemListElement]'); + + ctx.state.data = { + title: $('.content h1').text().trim(), + link, + item: itemList.toArray().map((element) => { + const item = $(element); + const title = item.find('.result-heading-title').text().trim(); + const link = `${baseURL}${item.find('.result-heading-title').attr('href')}`; + const description = item.find('.result-heading-texts').html(); + const pubDate = parseDate(item.find('time').attr('datetime'), 'YYYY-MM-DD'); + + return { + title, + link, + description, + pubDate, + }; + }), + }; +}; diff --git a/lib/v2/sourceforge/maintainer.js b/lib/v2/sourceforge/maintainer.js new file mode 100644 index 000000000..c5843ab97 --- /dev/null +++ b/lib/v2/sourceforge/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/:routeParams?': ['JimenezLi'], +}; diff --git a/lib/v2/sourceforge/radar.js b/lib/v2/sourceforge/radar.js new file mode 100644 index 000000000..a38640319 --- /dev/null +++ b/lib/v2/sourceforge/radar.js @@ -0,0 +1,12 @@ +module.exports = { + 'sourceforge.net': { + _name: 'SourceForge', + www: [ + { + title: 'Software', + docs: 'https://docs.rsshub.app/routes/program-update#sourceforge', + source: '/directory', + }, + ], + }, +}; diff --git a/lib/v2/sourceforge/router.js b/lib/v2/sourceforge/router.js new file mode 100644 index 000000000..4e4a3fe0b --- /dev/null +++ b/lib/v2/sourceforge/router.js @@ -0,0 +1,3 @@ +module.exports = (router) => { + router.get('/:routeParams?', require('./index')); +}; diff --git a/website/docs/routes/program-update.md b/website/docs/routes/program-update.md index efe6afbf5..260e74a19 100644 --- a/website/docs/routes/program-update.md +++ b/website/docs/routes/program-update.md @@ -638,6 +638,16 @@ Open `https://www.sony.com/electronics/support` and search for the corresponding +## SourceForge {#sourceforge} + + + +For some URL like [https://sourceforge.net/directory/artificial-intelligence/windows/](https://sourceforge.net/directory/artificial-intelligence/windows/), it is equal to [https://sourceforge.net/directory/?topic=artificial-intelligence&os=windows"](https://sourceforge.net/directory/?topic=artificial-intelligence&os=windows), thus subscribing to `/sourceforge/topic=artificial-intelligence&os=windows`. + +URL params can duplicate, such as `/sourceforge/topic=artificial-intelligence&os=windows&os=linux`. + + + ## Thunderbird {#thunderbird} ### Changelog {#thunderbird-changelog}