Skip to main content

xunleipy: XunLei SDK for Python

Project description

xunleipy
========
[![Build Status](https://travis-ci.org/lazygunner/xunleipy.svg?branch=master)](https://travis-ci.org/lazygunner/xunleipy)

### XunLei SDK
1. 模拟登录迅雷
2. 查看远程下载项目
3. 添加远程下载项目

### 远程下载使用方法
0. 安装&引用 xunleipy
```
pip install xunleipy
```
```
from xunleipy.remote import XunLeiRemote
```
1. 初始化迅雷远程对象
```
remote_client = XunLeiRemote(username, password, rk_username, rk_password, proxy=proxy)
```
* username - 迅雷账号
* password - 迅雷密码
* rk_username - 若快账号(用来自动识别验证码)
* rk_password - 若快密码(用来自动识别验证码)
* proxy - 代理地址,如果异地登录最好使用常用地区IP做代理(eg. http://192.168.1.1:8888)

2. 迅雷登录
```
remote_client.login() // 登录成功返回 True
```


3. 获取远程终端列表
```
peer_list = remote_client.get_remote_peer_list()
```
```
 返回数据
{
"rtn": 0,
"peerList": [
{
"category": "",
"status": 0,
"name": "GUNNER_NAS",
"vodPort": 8002,
"company": "XUNLEI_ARM_LE_ARMV5TE",
"pid": "F322***************",
"lastLoginTime": 1491282477,
"accesscode": "",
"localIP": "192.168.2.153",
"location": "",
"online": 1,
"path_list": "C:/",
"type": 30,
"deviceVersion": 22153310
},
{
"category": "",
"status": 0,
"name": "gunner-pc",
"vodPort": 0,
"company": "",
"pid": "0026***************",
"lastLoginTime": 1491121317,
"accesscode": "",
"localIP": "192.168.2.42",
"location": "",
"online": 0,
"path_list": "C:/迅雷下载/",
"type": 2,
"deviceVersion": 0
}
]
}
```

4. 添加下载链接
```
remote_data = {
'url': 'ed2k://|file|%E4%BA%BF%E4%B8%87.Billions.S02E01.%E4%B8%AD%E8%8B%B1%E5%AD%97%E5%B9%95.HDTVrip.720p.x264.mp4|633029318|3c85f90ef272d6581475c5c53c0be6f8|h=rilqokejso4mxrz3l2njyu6ee6u76bl3|/',
'name': 亿万.Billions.S02E01.中英字幕.HDTVrip.720p.x264.mp4,
'gcid': '',
'cid': '',
'file_size': 633029318
}
rtn = remote_client.add_tasks_to_remote(
peer_list[0]['pid'],   //要保证peer在线, 即peer['online'] == 1
'C:/TV/亿万 Billions/2/亿万.Billions.S02E01.中英字幕.HDTVrip.720p.x264.mp4', //路径可以自定义,但要确保存在
[remote_data]
)

if rtn['rtn'] != 0:
print '添加下载成功'
```

### 写在后面
这个项目断断续续写了有几年了,最主要的还是供自己的NAS自动下载更新的美剧,代码很多地方写的很丑,后续会逐渐优化

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xunleipy-0.4.1.tar.gz (14.2 kB view details)

Uploaded Source

File details

Details for the file xunleipy-0.4.1.tar.gz.

File metadata

  • Download URL: xunleipy-0.4.1.tar.gz
  • Upload date:
  • Size: 14.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for xunleipy-0.4.1.tar.gz
Algorithm Hash digest
SHA256 f60c47eb38849cb18d5c2478421b3d63e2151a0edba4aa917cff630c30efdaf2
MD5 abf227f9d376db0206bf41468a70f241
BLAKE2b-256 3c48aa4631a93911146d3234b77efe679202ede02ea01f01400a0df7e62347ef

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page