可以定制个人专属的 Kindle 电子书推送服务,放在服务器高端口自用
项目地址:KPush
安装
首先需要安装 Node.js 环境,且版本大于 8 (当然 7 也可以,支持 async/await 就好)
npm 源
使用
帮助:
Usage: kpush [options] Options: -V, --version output the version number -c, --config <string> set kpush custom config -p, --port <number> set kpush server listening port -s, --smtp <string> set stmp server of pushing mail -u, --user <string> set user of pushing mail -s, --pass <string> set password of pushing mail -k, --kindle <string> set user of kindle received mail -h, --help output usage information 所有设置都会自动保存,再次使用时无需再进行设置
运行:
$ kpush 配置设置并运行:
# 可以只设置其中几项 $ sslocal -p 7001 -s smtp.163.com -u [email protected] -s test -k [email protected] 以自定义配置运行:
# 请提供配置的绝对路径,以自定义配置运行时将忽略其他设置选项 $ sslocal -c /usr/local/ss-n/lib/local/config.json 配置格式如下,字段含义见帮助:
{ "port": "7001", "smtp": "smtp.163.com", "user": "[email protected]", "pass": "test", "kindle": "[email protected]" } 运行后,浏览器访问 KPush 服务器监听端口即可使用,推荐移动端进行访问
mobi 源更换
这里默认用了走读派作为 mobi 电子书源,感谢一下。若更换其他 mobi 源,可自行开发,仅需要实现 model.js 中 getList 和 getUrl 方法即可,约定如下:
// KPush 自带依赖,用于发送请求以及解析页面 const request = require('superagent') const cheerio = require('cheerio') // 导出 model 对象 module.exports = { /** * 获取 mobi 电子书搜索列表 * * @param {string} q - 查询关键词 * @return {array} - 返回 list 数组 * * list 数组元素为 mobi 对象,包含 3 个字段,均为 string * mobi.id - mobi 电子书唯一索引,用于查询源下载链接 * mobi.img - mobi 电子书封面图链接 * mobi.ctx - mobi 电子书简介 */ async getList (q) { let list = [] list.push({ id: '123', img: 'http://test.com/test1.jpg', ctx: '简介' }) return list }, /** * 获取 mobi 电子书下载链接 * * @param {string} i - mobi 电子书索引 * @return {string} - 返回源中 mobi 电子书下载链接 */ async getUrl (i) { let url = 'http://test.com/download/123' return url } } 项目地址:KPush
