feat(route): add Gumroad (#9795)
* feat(route): add Gumroad * Update lib/v2/gumroad/maintainer.js
This commit is contained in:
@@ -62,6 +62,16 @@ Parameter `time` only works when `mostwanted` is chosen as the category.
|
||||
|
||||
<RouteEn author="nczitzk" example="/guiltfree/onsale" path="/guiltfree/onsale"/>
|
||||
|
||||
## Gumroad
|
||||
|
||||
### Products
|
||||
|
||||
<RouteEn author="Fatpandac" example="/gumroad/afkmaster/Eve10" path="/gumroad/:username/:products" :paramsDesc="['username, can be found in URL', 'products name, can be found in URL']" radar="1" rssbud="1">
|
||||
|
||||
`https://afkmaster.gumroad.com/l/Eve10` -> `/gumroad/afkmaster/Eve10`
|
||||
|
||||
</RouteEn>
|
||||
|
||||
## hotukdeals
|
||||
|
||||
### thread
|
||||
|
||||
@@ -75,6 +75,16 @@ pageClass: routes
|
||||
|
||||
<Route author="nczitzk" example="/guiltfree/onsale" path="/guiltfree/onsale"/>
|
||||
|
||||
## Gumroad
|
||||
|
||||
### 商品
|
||||
|
||||
<Route author="Fatpandac" example="/gumroad/afkmaster/Eve10" path="/gumroad/:username/:products" :paramsDesc="['链接中用户名称,可在链接中获取', '商品名称,可在链接中获取']" radar="1" rssbud="1">
|
||||
|
||||
如:`https://afkmaster.gumroad.com/l/Eve10` 则为 `/gumroad/afkmaster/Eve10`
|
||||
|
||||
</Route>
|
||||
|
||||
## hotukdeals
|
||||
|
||||
### thread
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { art } = require('@/utils/render');
|
||||
const path = require('path');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const username = ctx.params.username;
|
||||
const products = ctx.params.products;
|
||||
const url = `https://${username}.gumroad.com/l/${products}`;
|
||||
|
||||
const response = await got(url);
|
||||
const $ = cheerio.load(response.data);
|
||||
const title = $('section.product-content.product-content__row > header > h1').text();
|
||||
const userFullName = $('section.product-content.product-content__row > section.details > a').text();
|
||||
|
||||
const item = [
|
||||
{
|
||||
title,
|
||||
link: url,
|
||||
description: art(path.join(__dirname, 'templates/products.art'), {
|
||||
img: response.data.match(/data-preview-url="(.*?)"/)[1],
|
||||
productsName: title,
|
||||
price: $('div.price').text(),
|
||||
desc: $('section.product-content.product-content__row > section:nth-child(3) > div').html(),
|
||||
stack: $('div.product-info').find('ul.stack').html(),
|
||||
}),
|
||||
},
|
||||
];
|
||||
|
||||
ctx.state.data = {
|
||||
link: url,
|
||||
title: `Gumroad - ${userFullName}/${title}`,
|
||||
item,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = {
|
||||
'/:username/:products': ['Fatpandac'],
|
||||
};
|
||||
@@ -0,0 +1,17 @@
|
||||
module.exports = {
|
||||
'gumroad.com': {
|
||||
_name: 'Gumroad',
|
||||
'.': [
|
||||
{
|
||||
title: '产品',
|
||||
docs: 'https://docs.rsshub.app/shopping.html#gumroad',
|
||||
source: ['/l/:products'],
|
||||
target: (params, url) => {
|
||||
const username = new URL(url).host.split('.')[0];
|
||||
|
||||
return `/gumroad/${username}/${params.products}`;
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = function (router) {
|
||||
router.get('/:username/:products', require('./index'));
|
||||
};
|
||||
@@ -0,0 +1,7 @@
|
||||
<img src="{{img}}"/>
|
||||
<h1>{{productsName}}</h1>
|
||||
<p style="color: red;">{{price}}</p>
|
||||
{{@ desc}}
|
||||
<hr>
|
||||
{{@ stack}}
|
||||
|
||||
Reference in New Issue
Block a user