F-Droid app update (#726)

This commit is contained in:
Gary Williams 2018-09-17 23:15:42 +08:00 committed by DIYgod
parent 464903988a
commit cfdbf3324c
4 changed files with 71 additions and 0 deletions

View File

@ -871,6 +871,10 @@ GitHub 官方也提供了一些 RSS:
<route name="每日精品限免 / 促销应用" author="Andiedie" example="/appstore/xianmian" path="/appstore/xianmian"/>
### F-Droid
<route name="App更新" author="garywill" example="/fdroid/apprelease/com.termux" path="/fdroid/apprelease/:app" :paramsDesc="['App包名']">
### Greasy Fork
<route name="脚本更新" author="imlonghao" example="/greasyfork/zh-CN/bilibili.com" path="/greasyfork/:language/:domain?" :paramsDesc="['语言, 可在网站右上角找到, `all` 为所有语言', '按脚本生效域名过滤, 可选']"/>

View File

@ -170,6 +170,10 @@ If no matching results were found, the server returns only a HTTP status code `2
<routeEn name="In-App-Purchase Price Drop Alert" author="HenryQW" example="/appstore/iap/us/id953286746" path="/appstore/iap/:country/:id" :paramsDesc="['App Store Country, obtain from the app URL https://itunes.apple.com/us/app/id953286746, in this case, `us`', 'App Store app id, obtain from the app URL https://itunes.apple.com/us/app/id953286746, in this case, `id953286746`']" />
### F-Droid
<routeEn name="App Update" author="garywill" example="/fdroid/apprelease/com.termux" path="/fdroid/apprelease/:app" :paramsDesc="['App\'s package name']">
### Greasy Fork
<routeEn name="Script Update" author="imlonghao" path="/greasyfork/:language/:domain?" example="/greasyfork/en/google.com" :paramsDesc="['language, located on the top right corner of Greasy Fork\'s search page, set to `all` for including all languages', 'the script\'s target domain']" />

View File

@ -288,6 +288,9 @@ router.get('/github/issue/:user/:repo', require('./routes/github/issue'));
router.get('/github/user/followers/:user', require('./routes/github/follower'));
router.get('/github/stars/:user/:repo', require('./routes/github/star'));
// f-droid
router.get('/fdroid/apprelease/:app', require('./routes/fdroid/apprelease'));
// konachan
router.get('/konachan/post/popular_recent', require('./routes/konachan/post_popular_recent'));
router.get('/konachan.com/post/popular_recent', require('./routes/konachan/post_popular_recent'));

View File

@ -0,0 +1,60 @@
const axios = require('../../utils/axios');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const response = await axios.get(`https://f-droid.org/en/packages/${ctx.params.app}/`);
const data = response.data;
const $ = cheerio.load(data);
const app_name = $('.package-title')
.find('h3')
.text();
const app_descr = $('.package-title')
.find('.package-summary')
.text();
const items = [];
$('.package-versions-list')
.find('.package-version')
.each(function() {
const item = {};
const version = $(this)
.find('.package-version-header')
.find('a')
.eq(0)
.attr('name');
item.title = version;
item.guid = $(this)
.find('.package-version-header')
.find('a')
.eq(1)
.attr('name');
item.pubDate = new Date(
$(this)
.find('.package-version-header')
.text()
.split('Added on ')[1]
).toUTCString();
item.description = [
$(this)
.find('.package-version-download')
.html(),
$(this)
.find('.package-version-requirement')
.html(),
$(this)
.find('.package-version-source')
.html(),
].join('<br/>');
item.link = `https://f-droid.org/en/packages/${ctx.params.app}/#${version}`;
items.push(item);
});
ctx.state.data = {
title: `${app_name} releases on F-Droid`,
discription: app_descr,
link: `https://f-droid.org/en/packages/${ctx.params.app}/`,
item: items,
};
};