Skip to content

Commit

Permalink
F-Droid app update (#726)
Browse files Browse the repository at this point in the history
  • Loading branch information
garywill authored and DIYgod committed Sep 17, 2018
1 parent 4649039 commit cfdbf33
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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` 为所有语言', '按脚本生效域名过滤, 可选']"/>
Expand Down
4 changes: 4 additions & 0 deletions docs/en/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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']" />
Expand Down
3 changes: 3 additions & 0 deletions router.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down
60 changes: 60 additions & 0 deletions routes/fdroid/apprelease.js
Original file line number Diff line number Diff line change
@@ -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,
};
};

0 comments on commit cfdbf33

Please sign in to comment.