xunleipy: XunLei SDK for Python


Keywords
XunLei
License
MIT
Install
pip install xunleipy==0.4.1

Documentation

xunleipy

Build Status

XunLei SDK

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

远程下载使用方法

  1. 安装&引用 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)
  1. 迅雷登录
  remote_client.login() // 登录成功返回 True
  1. 获取远程终端列表
  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
        }
    ]
}
  1. 添加下载链接
  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自动下载更新的美剧,代码很多地方写的很丑,后续会逐渐优化