Skip to content

Commit

Permalink
0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
layerssss committed Sep 29, 2014
1 parent b32d0ab commit 05a8d23
Show file tree
Hide file tree
Showing 550 changed files with 187 additions and 73,215 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ pids
logs
results
npm-debug.log
node_modules
.lixian-portal.*
3 changes: 2 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/node_modules
node_modules
.lixian-portal.*
19 changes: 8 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
lixian-portal
=============

`iambus/xunlei-lixian`做的一个简洁实用的webui。(不明真相的同学赶快先去膜拜了[iambus/xunlei-lixian](https://github.com/iambus/xunlei-lixian)了再回来)
一个简洁实用的 Web 版迅雷离线下载程序。

# 这是啥

我也不知道这是啥,见下一章说明吧

# 典型使用场景

1. 家里有个连着移动硬盘的树莓派
1. 家里有个 HTPC,运行着这个程序
2. 我平常刷微博时发现先几个好看的电影,和想玩的游戏,然后再xxx上找到这些电影和游戏的ed2k链接,然后输入进去
3. 周末我通过smb文件共享打开树莓派里已经下好的电影和游戏,看之且玩之
3. 周末我通过 samba 文件共享打开这个程序已经下好的电影和游戏,看之且玩之
4. 室友也可以看(如果有室友的话)

# 界面预览
Expand All @@ -22,18 +22,15 @@ lixian-portal

# 环境

* linux/osx (如果你想用windows来做下载服务器,你得先在windows上安装好wget)
* python2
* nodejs
* [NodeJS](http://nodejs.org/)

# 安装方法

* 下载代码并解压缩
* 运行命令启动`node /path/to/lixian-portal`
* 使用 NodeJS 自带的包管理器 npm 来安装该程序:`npm install lixian-portal -g`
* 运行命令启动`lixian-portal`
* 下载的位置为启动这个程序的目录(Current Working Directory)
* 如需下载到其他位置,可以设置环境变量`LIXIAN_PORTAL_HOME`,例如:可以这样启动程序`LIXIAN_PORTAL_HOME=/mnt/sdb1 node /path/to/lixan-portal`
* 如需下载到其他位置,可以设置环境变量`LIXIAN_PORTAL_HOME`,例如:可以这样启动程序`LIXIAN_PORTAL_HOME=/mnt/sdb1 lixian-portal`

# Tricks

* 如果想让它一直在后运行,可以使用这个命令启动`nohup node /path/to/lixian-portal &`
* `lixian-portal`兼容`xunlei-lixian`的设置,按这样的命令格式设置即可`HOME=/path/to/lixian-portal/Downloads lx config output-dir /mnt/Downloads`
* 如果想让它一直在后运行,可以使用这个命令启动`nohup lixian-portal &`
36 changes: 12 additions & 24 deletions app.iced
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,6 @@ app.use express.methodOverride()

client.startCron()
queue = client.queue
autorefresh = ->
queue.append
name: "刷新任务列表"
func: queue.tasks.updateTasklist
setTimeout autorefresh, 60000 * (1 + Math.random() * 3)
autorefresh()


app.get '/', (req, res, n)->
return res.redirect '/login' if client.stats.requireLogin
Expand All @@ -43,44 +36,34 @@ app.all '*', (req, res, n)->
ip = ip.split(',')[0].trim()
return n 403 if process.env.ONLYFROM && -1 == process.env.ONLYFROM.indexOf ip
n null
app.post '/refresh', (req, res, n)->

queue.append
name: "刷新任务列表"
func: queue.tasks.updateTasklist
res.redirect 'back'

app.post '/', (req, res, n)->
if req.files && req.files.bt && req.files.bt.path && req.files.bt.length
bt = req.files.bt
await fs.rename bt.path, "#{bt.path}.torrent", defer e
return n e if e
await queue.tasks.addBtTask bt.name, "#{bt.path}.torrent", defer e
await queue.execute 'addBtTask', bt.name, "#{bt.path}.torrent", defer e
return n e if e
else
await queue.tasks.addTask req.body.url, defer e
if req.body.url && req.body.url.length
await queue.execute 'addTask', req.body.url, defer e
return n e if e
res.redirect '/'

app.get '/login', (req, res)->
res.locals.vcode = null
res.render 'login'
app.post '/login', (req, res, n)->
await queue.tasks.login req.body.username, req.body.password, req.body.vcode, defer e
await queue.execute 'login', req.body.username, req.body.password, defer e
return n e if e
res.redirect '/'
app.get '/logout', (req, res, n)->
await queue.tasks.logout defer e
await queue.execute 'logout', defer e
return n e if e
res.redirect '/'

app.delete '/tasks/:id', (req, res, n)->
if client.stats.retrieving?.task.id
client.stats.retrieving.kill()
queue.append
name: "删除任务 #{task.id}"
func: (fcb)->
queue.tasks.deleteTask req.params.id, fcb
await queue.execute 'deleteTask', req.params.id, defer e
return cb e if e
res.redirect '/'


Expand All @@ -90,6 +73,11 @@ app.use (e, req, res, next)->
await client.init defer e
throw e if e

autorefresh = ->
await queue.execute 'updateTasklist', defer(e)
setTimeout autorefresh, 60000 * (1 + Math.random() * 3)
autorefresh()

port = process.env.PORT || 3000
if isNaN Number port
await exec "fuser #{port}", defer e
Expand Down
Loading

0 comments on commit 05a8d23

Please sign in to comment.