Skip to content

Commit

Permalink
update aria2 config files && convert python file to unix format
Browse files Browse the repository at this point in the history
  • Loading branch information
yangxuan8282 committed Nov 16, 2016
1 parent 849d7c2 commit 6c67949
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 81 deletions.
4 changes: 1 addition & 3 deletions README-zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ python wechat_remote.py
diana list
```

百度云的话可以将手机浏览器的浏览器标识改为 iPhone,进入文件下载页面点击 `打开` 按钮获取url
百度云的话可以将手机浏览器的浏览器标识改为 `Symbian`,进入文件下载页面点击 `下载` 按钮获取url
然后发送给登陆的微信账号,格式如下

```bash
Expand All @@ -122,8 +122,6 @@ python wechat_remote.py

加双引号是为了防止地址被断开

需要注意的是这种地址下载过程会间歇式进行,下一段时间会停顿,不如 Chrome 插件 [BaiduExporter](https://github.com/acgotaku/BaiduExporter) 获取的地址快,但是 BaiduExporter 获取的地址需要获取 cache,过程相对复杂一些


2. 下载视频 (youtube-dl)

Expand Down
16 changes: 6 additions & 10 deletions aria2.conf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 基本配置
# 下载目录
dir=/home/pi
dir=/home/pi/Download
# 下载从这个文件中找到的urls, 需自己建立这个文件
# touch /home/pi/.aria2/aria2.session
input-file=/home/pi/.aria2/aria2.session
Expand All @@ -14,8 +14,7 @@ continue=true
#lowest-speed-limit=0
# 对于每个下载在同一个服务器上的连接数,默认 1
max-connection-per-server=5
# 每个文件最小分片大小,例如文件 20M,设置 size 为 10M,
则用2个连接下载,默认 20M
# 每个文件最小分片大小,例如文件 20M,设置 size 为 10M, 则用2个连接下载,默认 20M
#min-split-size=10M
# 下载一个文件的连接数,默认 5
#split=5
Expand Down Expand Up @@ -66,11 +65,9 @@ rpc-listen-port=6800
# This is useful if you have to use broken DNS and
# want to avoid terribly slow AAAA record lookup.
# 默认 false
disable-ipv6=true
#
指定文件分配方法,预分配能有效降低文件碎片,提高磁盘性能,缺点是预分配时间稍长
# 如果使用新的文件系统,例如 ext4 (with extents support), btrfs, xfs or
NTFS(MinGW build only), falloc 是最好的选择
#disable-ipv6=true
# 指定文件分配方法,预分配能有效降低文件碎片,提高磁盘性能,缺点是预分配时间稍长
# 如果使用新的文件系统,例如 ext4 (with extents support), btrfs, xfs or NTFS(MinGW build only), falloc 是最好的选择
# 如果设置为 none,那么不预先分配文件空间,默认 prealloc
file-allocation=none
# 整体下载速度限制,默认 0
Expand All @@ -80,8 +77,7 @@ file-allocation=none
# 保存错误或者未完成的下载到这个文件
# 和基本配置中的 input-file 一起使用,那么重启后仍可继续下载
save-session=/home/pi/.aria2/aria2.session
# 每5分钟自动保存错误或未完成的下载,如果为 0, 只有 aria2
正常退出才回保存,默认 0
# 每5分钟自动保存错误或未完成的下载,如果为 0, 只有 aria2 正常退出才回保存,默认 0
save-session-interval=300

# 若要用于 PT 下载,需另外的配置,这里没写
10 changes: 3 additions & 7 deletions aria2c
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,14 @@

#VAR
RUN="/usr/bin/aria2c"
ARIA_PID=$(ps ux | awk '/aria2c --daemon=true --enable-rpc/ && !/awk/
{print $2}')
ARIA_PID=$(ps ux | awk '/aria2c --daemon=true --enable-rpc/ && !/awk/ {print $2}')

# Carry out specific functions when asked to by the system
case "$1" in
start)
echo "Starting script aria2c "
if [ -z "$ARIA_PID" ]; then
$RUN --daemon=true --enable-rpc=true -D
--conf-path=/home/pi/.aria2/aria2.conf
$RUN --daemon=true --enable-rpc=true -D --conf-path=/home/pi/.aria2/aria2.conf
echo "Started"
else
echo "aria2c already started"
Expand All @@ -41,8 +39,7 @@ case "$1" in
kill $ARIA_PID
fi
sleep 3 # TODO:Maybe need to be adjust
$RUN --daemon=true --enable-rpc=true -D
--conf-path=/home/pi/.aria2/aria2.conf
$RUN --daemon=true --enable-rpc=true -D --conf-path=/home/pi/.aria2/aria2.conf
echo "OK"
;;
status)
Expand All @@ -58,4 +55,3 @@ case "$1" in
;;
esac
exit 0

122 changes: 61 additions & 61 deletions wechat_remote.py
Original file line number Diff line number Diff line change
@@ -1,61 +1,61 @@
#!/usr/bin/env python
#coding=utf-8
# Author: yangxuan([email protected])
# remote for WeChat (based on ItChat: https://github.com/littlecodersh/ItChat)
# modified from this demo(https://github.com/littlecodersh/ItChat/issues/24#issuecomment-228583833)
# you can use this scripts to interact with your computer(such as RaspberryPi)
# it should support most commands you use in terminal, for instance `uname` or `df -h`

import os
import sys
#import subprocess
import itchat
import time

if os.name == 'posix' and sys.version_info[0] < 3:
import subprocess32 as subprocess
else:
import subprocess

help = '''\
WeChat remote:
* download file: diana add url
* download video: youtube-dl url
* online video: mpv url
* & most commands you use in terminal
* help(show this message)\
'''

@itchat.msg_register('Text')
def remote(msg):

if not msg['FromUserName'] == msg['ToUserName']: return # comment this line if you can't send message to yourself
if msg['Text'] in ['help', u'帮助']:
return help
else:
commands = msg.get('Content', '')
args = commands.split()

# Custom aliases
if args[0] == 'bilidan':
args[0] = '/home/pi/BiliDan/bilidan.py'

if args[0] == 'dad':
args[0] = '/home/pi/diana/dad'

if args[0] == 'diana':
args[0] = '/home/pi/diana/diana'

try:
proc = subprocess.Popen(args,
# shell=True,
# executable='/bin/bash',
# stderr=subprocess.PIPE,
stdout=subprocess.PIPE)
return proc.communicate()[0].strip()
except OSError as e:
return u'Commands/Files not found'


itchat.auto_login(enableCmdQR = True, hotReload = True)
itchat.run()
#!/usr/bin/env python
#coding=utf-8
# Author: yangxuan([email protected])
# remote for WeChat (based on ItChat: https://github.com/littlecodersh/ItChat)
# modified from this demo(https://github.com/littlecodersh/ItChat/issues/24#issuecomment-228583833)
# you can use this scripts to interact with your computer(such as RaspberryPi)
# it should support most commands you use in terminal, for instance `uname` or `df -h`

import os
import sys
#import subprocess
import itchat
import time

if os.name == 'posix' and sys.version_info[0] < 3:
import subprocess32 as subprocess
else:
import subprocess

help = '''\
WeChat remote:
* download file: diana add url
* download video: youtube-dl url
* online video: mpv url
* & most commands you use in terminal
* help(show this message)\
'''

@itchat.msg_register('Text')
def remote(msg):

#if not msg['FromUserName'] == msg['ToUserName']: return # comment this line if you can't send message to yourself
if msg['Text'] in ['help', u'帮助']:
return help
else:
commands = msg.get('Content', '')
args = commands.split()

# Custom aliases
# if args[0] == 'bilidan':
# args[0] = '/home/pi/BiliDan/bilidan.py'

# if args[0] == 'dad':
# args[0] = '/home/pi/diana/dad'

# if args[0] == 'diana':
# args[0] = '/home/pi/diana/diana'

try:
proc = subprocess.Popen(args,
# shell=True,
# executable='/bin/bash',
# stderr=subprocess.PIPE,
stdout=subprocess.PIPE)
return proc.communicate()[0].strip()
except OSError as e:
return u'Commands/Files not found'


itchat.auto_login(enableCmdQR = True, hotReload = True)
itchat.run()

0 comments on commit 6c67949

Please sign in to comment.