写了一个自建 Kindle 推送服务 KPush

2017-10-17 22:27:26 +08:00
 qiuyk

可以定制个人专属的 Kindle 电子书推送服务,放在服务器高端口自用

项目地址:KPush

安装

首先需要安装 Node.js 环境,且版本大于 8 (当然 7 也可以,支持 async/await 就好)

npm 源

# 全局安装
$ npm i -g kpush

使用

帮助:

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 test@163.com -s test -k test@kindle.cn

以自定义配置运行:

# 请提供配置的绝对路径,以自定义配置运行时将忽略其他设置选项
$ sslocal -c /usr/local/ss-n/lib/local/config.json

配置格式如下,字段含义见帮助:

{
  "port": "7001",
  "smtp": "smtp.163.com",
  "user": "test@163.com",
  "pass": "test",
  "kindle": "test@kindle.cn"
}

运行后,浏览器访问 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

5316 次点击
所在节点    Node.js
8 条回复
CcChen
2017-10-17 22:32:31 +08:00
先收藏。到时再看看
Shura
2017-10-17 22:55:53 +08:00
sslocal 瞩目
qiuyk
2017-10-17 23:02:43 +08:00
@Shura 直接复制的 readme 过来的 忘改了...
wangysong
2017-10-18 09:31:02 +08:00
给你一个星哈,以后我拿来商用吧,哈哈哈
guonning
2017-10-18 09:54:59 +08:00
这个好啊,收藏了
wangxn
2017-10-18 10:00:10 +08:00
不错。
然而是 Node.js 写的。感觉用这个来开发的软件安装起来都很不友好,看上去要先装 npm 才行。不知道有没有一个单独的安装包?
qiuyk
2017-10-18 10:07:36 +08:00
@wangxn 因为写着玩的没考虑这个问题 回头我写个安装部署脚本好了
friejq
2017-10-18 11:06:42 +08:00
收藏先

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/398464

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX