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.
feat(route): kindle software updates (DIYgod#12041)
* feat(route): kindle software updates * Update lib/v2/kindle/radar.js * Update lib/v2/kindle/radar.js * fix: kindle route config * chore(route): change path to amazon * fix: typo ---------
- Loading branch information
1 parent
dae0b25
commit 75901af
Showing
7 changed files
with
87 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
const got = require('@/utils/got'); | ||
const { art } = require('@/utils/render'); | ||
const path = require('path'); | ||
const cheerio = require('cheerio'); | ||
const host = 'https://www.amazon.com'; | ||
module.exports = async (ctx) => { | ||
const url = host + '/gp/help/customer/display.html'; | ||
const nodeIdValue = 'GKMQC26VQQMM8XSW'; | ||
const response = await got({ | ||
method: 'get', | ||
url, | ||
searchParams: { | ||
nodeId: nodeIdValue, | ||
}, | ||
}); | ||
const data = response.data; | ||
|
||
const $ = cheerio.load(data); | ||
const list = $('.a-row.cs-help-landing-section.help-display-cond') | ||
.map(function () { | ||
const data = {}; | ||
data.title = $(this).find('.sectiontitle').text(); | ||
data.link = $(this).find('a').eq(0).attr('href'); | ||
data.version = $(this).find('li').first().text(); | ||
data.website = `${url}?nodeId=${nodeIdValue}`; | ||
data.description = $(this) | ||
.find('.a-column.a-span8') | ||
.html() | ||
.replace(/[\n\t]/g, ''); | ||
return data; | ||
}) | ||
.get(); | ||
ctx.state.data = { | ||
title: 'Kindle E-Reader Software Updates', | ||
link: `${url}?nodeId=${nodeIdValue}`, | ||
description: 'Kindle E-Reader Software Updates', | ||
item: list.map((item) => ({ | ||
title: item.title + ' - ' + item.version, | ||
description: | ||
item.description + | ||
art(path.join(__dirname, 'templates/software-description.art'), { | ||
item, | ||
}), | ||
link: item.link, | ||
})), | ||
}; | ||
}; |
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 = { | ||
'/kindle/software-updates': ['NavePnow'], | ||
}; |
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,18 @@ | ||
module.exports = { | ||
'amazon.com': { | ||
_name: 'Amazon', | ||
'.': [ | ||
{ | ||
title: 'Kindle 软件更新', | ||
docs: 'https://docs.rsshub.app/program-update.html#amazon', | ||
source: ['/gp/help/customer/display.html'], | ||
target: (_, url) => { | ||
const nodeId = new URL(url).searchParams.get('nodeId'); | ||
if (nodeId === 'GKMQC26VQQMM8XSW') { | ||
return '/amazon/kindle/software-updates'; | ||
} | ||
}, | ||
}, | ||
], | ||
}, | ||
}; |
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 = function (router) { | ||
router.get('/kindle/software-updates', require('./kindle-software-updates')); | ||
}; |
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,4 @@ | ||
<div> | ||
<br><br> | ||
<a href={{item.website}}>Kindle Website</a> | ||
</div> |