Code Monkey home page Code Monkey logo

xunlei-lixian's Introduction

xunlei-lixian

迅雷离线下载脚本。

更新

2016.11.20 抱歉,这个项目我基本上已经不维护了。我本人甚至很久没有续费迅雷会员了……最后一个更新尝试着修复了登录问题。现在登录密码只能使用明文,如果配置过lx config password的需要重新设置下。另外建议删除.xunlei.lixian.cookies文件。

声明

迅雷离线下载为会员功能。非会员无法使用。

Quick start

python lixian_cli.py login "Your Xunlei account" "Your password"
python lixian_cli.py login "Your password"
python lixian_cli.py login

python lixian_cli.py config username "Your Xunlei account"
python lixian_cli.py config password "Your password"

python lixian_cli.py list
python lixian_cli.py list --completed
python lixian_cli.py list --completed --name --original-url --download-url --no-status --no-id
python lixian_cli.py list --deleted
python lixian_cli.py list --expired
python lixian_cli.py list id1 id2
python lixian_cli.py list zip rar
python lixian_cli.py list 2012.04.04 2012.04.05

python lixian_cli.py download task-id
python lixian_cli.py download ed2k-url
python lixian_cli.py download --tool=wget ed2k-url
python lixian_cli.py download --tool=asyn ed2k-url
python lixian_cli.py download ed2k-url --output "file to save"
python lixian_cli.py download id1 id2 id3
python lixian_cli.py download url1 url2 url3
python lixian_cli.py download --input download-urls-file
python lixian_cli.py download --input download-urls-file --delete
python lixian_cli.py download --input download-urls-file --output-dir root-dir-to-save-files
python lixian_cli.py download bt://torrent-info-hash
python lixian_cli.py download 1.torrent
python lixian_cli.py download torrent-info-hash
python lixian_cli.py download --bt http://xxx/xxx.torrent
python lixian_cli.py download bt-task-id/file-id
python lixian_cli.py download --all
python lixian_cli.py download mkv
python lixian_cli.py download 2012.04.04
python lixian_cli.py download 0 1 2
python lixian_cli.py download 0-2

python lixian_cli.py add url
python lixian_cli.py add 1.torrent
python lixian_cli.py add torrent-info-hash
python lixian_cli.py add --bt http://xxx/xxx.torrent

python lixian_cli.py delete task-id
python lixian_cli.py delete url
python lixian_cli.py delete file-name-on-cloud-to-delete

python lixian_cli.py pause id

python lixian_cli.py restart id

python lixian_cli.py rename id name

python lixian_cli.py logout

安装指南

  1. 安装git(非github用户应该只需要执行第一步Download and Install Git)

    http://help.github.com/set-up-git-redirect

  2. 下载代码(Windows用户请在git-bash里执行)

     git clone git://github.com/iambus/xunlei-lixian.git
    
  3. 安装Python 2.x(请下载最新的2.7版本。不支持Python 3.x。)

    http://www.python.org/getit/

  4. 在命令行里运行

     python lixian_cli.py
    

注:不方便安装git的用户可以选择跳过前两步,在github网页上下载最新的源代码包(选择"Download as zip"或者"Download as tar.gz"):

https://github.com/iambus/xunlei-lixian/downloads

一些提示

  1. 你可以为python lixian_cli.py创建一个别名(比如lx),以减少敲键次数。

    Linux上可以使用:

     ln -s 你的lixian_cli.py路径 ~/bin/lx
    

    Windows上可以创建一个lx.bat脚本,放在你的PATH中:

     @echo off
     python 完整的lixian_cli.py路径 %*
    

    注:下文中提到的lx都是指python lixian_cli.py的别名。

  2. 你可以使用lx config保存一些配置。见“命令详解”一节。

     lx config delete
     lx config tool asyn
     lx config username your-id
     lx config password your-password
    

    注:密码保存的时候会加密(hash)

  3. 部分命令有短名字。lx d相当于lx download,lx a相当于lx add,lx l相当于lx list,lx x相当于lx list。也可以通过plugin api自己添加alias。

  4. 使用lx download下载的文件会自动验证hash。其中ed2k和bt会做完整的hash校验。http下载只做部分校验。

    注:包含多个文件的bt种子,如果没有完整下载所有文件,对于已下载的文件,可能有少量片段无法验证。如果很重视文件的正确性请选择下载bt种子中的所有文件。(目前还没有发现由于软件问题而导致hash验证失败的情况。)

  5. 如果觉得大文件的hash速度太慢,可以关掉:

     lx download --no-hash ...
    

    也可以使用lx config默认关掉它:

     lx config no-hash
    
  6. lx hash命令可以用于手动计算hash。见“其他工具”一节。

命令详解

注:下文中提到的lx都是指python lixian_cli.py的别名。

常用命令:

  • lx login
  • lx download
  • lx list
  • lx add
  • lx delete
  • lx pause
  • lx restart
  • lx rename
  • lx readd
  • lx config
  • lx info
  • lx help

lx login

登录,获得一个有效session,默认保存路径是~/.xunlei.lixian.cookies。一般来说,除非服务器故障或者执行了lx logout(或者你手动删除了cookies文件),否则session的有效期是一天左右。session过期之后需要手动重新执行login。但如果使用lx config password把密码保存到配置文件里,则会自动重新登录。后文会介绍lx config

lx login接受两个参数,用户名和密码。第二次登录可以只填密码。

lx login username password
lx login password

如果不希望明文显示密码,也可以直接运行

lx login

或者使用-代替密码

lx login username -

上面的命令会进入交互式不回显的密码输入。

可以用--cookies指定保存的session文件路径。-表示不保存(在login这个例子里,没什么实际意义)。

lx login username password --cookies some-path
lx login username password --cookies -

注意,除了lx login外,大多数lx命令,比如lx download,都需要先执行登录。这些命令大多支持--username和--password,以及--cookies参数,根据传递进来的参数,检查用户是否已经登录,如果尚未登录则尝试登录。一般来说不建议在其他命令里使用这些参数(因为麻烦),除非你不希望保存session信息到硬盘。

lx download

下载。目前支持普通的http下载,ed2k下载,和bt下载。可以使用thunder/flashget/qq旋风的连接(bt任务除外)。在信息足够的情况下(见“一些提示”一节的第3条),下载的文件会自动验证hash,出错了会重新下载(我个人目前还没遇到过下载文件损坏的情况)。见“一些提示”一节的第3条。

lx download id
lx download http://somewhere
lx download ed2k://somefile
lx download bt://info-hash
lx download link1 link2 link3 ...
lx download --all
lx download keywords
lx download date

对于bt任务,可以指定本地.torrent文件路径,或者torrent文件的info hash。(很多网站使用info hash来标识一个bt种子文件,这种情况你就不需要下载种子了,lx download可以自动下载种子,不过前提是之前已经有人使用迅雷离线下载过同样的种子。如后所述,你也可以使用lx hash --info-hash来手动生成bt种子的info hash。)

lx download Community.S03E01.720p.HDTV.X264-DIMENSION.torrent
lx download 61AAA3C6FBB8B71EBE2F5A2A3481296B51D882F6
lx download bt://61AAA3C6FBB8B71EBE2F5A2A3481296B51D882F6

如果url本身指向了要添加任务的种子文件,需要加上--bt参数告诉lx脚本这是一个种子。

lx download --bt http://tvu.org.ru/torrent.php?tid=64757

可以把多个连接保存到文件里,使用--input参数批量下载:

lx download --input links.txt

注意:在断点续传的情况下,如果文件已经存在,并且文件大小相等,并且使用了--continue,重新下载并不只是简单的忽略这个文件,而是先做hash校验,如果校验通过才忽略。如果文件比较多或者比较大,可能比较耗时。建议手动从--input文件里删除已经下载过的链接。也可以使用--mini-hash参数,如下。

如果指定了--mini-hash参数,对于已经下载过的文件,并且文件大小正确(一般意味着这个文件的正确性已经在前一次下载中验证过了),会做一个最简单的校验。对于尚未下载完成的任务,在完成之后还是会做完整的hash。

如果指定了--no-hash参数,永远不会做完整的hash。但还是会做文件大小检验和取样hash(很快)。

可以使用--delete参数在下载完成之后删除任务。

lx download link --delete

如果一个文件已经存在,使用参数--continue支持断点续传,使用--overwrite覆盖已存在的文件,重新下载。

你可能需要用--tool参数来指定下载工具。默认的下载工具是wget,有些环境的wget是最低功能版本,不支持指定cookie或者断点续传。这种情况可以使用--tool=asyn。这在“支持的下载工具”一节有说明。

lx download --tool=wget link
lx download --tool=asyn link

--output和--output-dir分别用来指定保存文件的路径和目录。

如果要下载的文件尚未在离线任务里,会被自动添加。

你也可以使用指定要下载的任务id(lx list命令可以用来查看任务id):

lx download task-id

但是要注意,多任务下载的时候,不能混用id和url(以后可能会支持)。

类似任务id,也可以指定任务的序列号。序列号从0开始。可以使用lx list -n查看序列号。如果希望lx list默认显示序列号,可以使用lx config n。若要下载任务列表中的第一个任务:

lx download 0

要下载前三个任务:

lx download 0-2

对于bt任务,如果只想下载部分文件,可以在task id后指定文件id:

lx download bt-task-id/file-id bt-task-id/file-id2

或者:

lx download bt-task-id/[1,3,5-7]

注:上面的命令下载对应bt任务里文件id为1,3,5,6,7的五个文件。

也可以指定bt子文件的扩展名:

lx download bt-task-id/.mkv

或者:

lx download bt-task-id/[.mkv,.mp4]

更多的用法:TODO

可以使用--all参数下载所有的任务(如果已经在参数中指定了要下载的链接或者任务id,--all参数会被忽略):

lx download --all

也可以使用一个简单的关键字匹配要下载的文件名:

lx download mkv

也可以搜索多个关键字(满足其中一个就算匹配):

lx download mkv mp4

任务的添加日期也可以作为关键字:

lx download 2012.04.04
lx download 2012.04.04 2012.04.05

lx list

列出已存在的离线任务。默认只会列出任务id,任务名,以及状态。可以使用--original-url和--download-url参数来列出原始链接和下载链接。--completed参数用于忽略未完成任务。

lx list
lx list --completed
lx list --no-status --original-url --download-url

如果要列出bt任务的子文件,可以在任务id后面加上/:

lx list id/

可以使用--deleted或者--expired参数来列出已删除和已过期的任务。

详细参数可以参考lx help list。

lx add

添加任务到迅雷离线服务器上。

lx add url1 url2 url3
lx add --input links.txt
lx add --bt torrent-file
lx add --bt torrent-url
lx add --bt info-hash

提示:lx download会自动添加任务,而无需执行lx add。

lx delete

从迅雷离线服务器上删除任务。

lx delete id1 id2
lx delete ed2k://...
lx delete mkv
lx delete --all mkv
lx delete --all mkv mp4

lx pause

暂停任务。

lx pause id1 id2
lx pause --all mkv

lx restart

重新开始任务。

lx restart id1 id2
lx restart --all mkv

lx rename

重命名任务

lx rename task-id task-name

lx logout

不想保留session可以使用lx logout退出。一般用不着。

 lx logout
 lx logout --cookies your-cookies-file

lx readd

重新添加已过期或者已删除的任务。

lx readd --deleted task-id
lx readd --expired task-name

提示:可以用lx list --deleted或者lx list --expired列出已删除和过期的任务。

lx config

保存配置。配置文件的保存路径是~/.xunlei.lixian.config。虽然你可以差不多可以保存任何参数,但是目前只有以下几个参数会真正起作用:

  • username
  • password
  • tool
  • continue
  • delete
  • output-dir
  • hash
  • mini-hash
  • id
  • n
  • size
  • format-size
  • colors
  • wget-opts(见稍后的说明)
  • aria2-opts(见稍后的说明)(见支持的下载工具一节)
  • axel-opts(见稍后的说明)
  • watch-interval
  • log-level
  • log-path

(因为只有这几个参数我觉得是比较有用的。如果你觉得其他的参数有用可以发信给我或者直接open一个issue。)

不加参数会打印当前保存的所有配置:

lx config

可以使用--print打印指定的配置:

lx config --print password

添加一个新的参数:

lx config username your-username
lx config password your-password
lx config delete
lx config no-delete

删除一个参数:

lx config --delete password

注:密码是hash过的,不是明文保存。 注:如果不希望在命令行参数中明文保存密码,可以运行lx config password,或者lx config password -,会进入交互式不回显密码输入(只支持password配置)。

关于wget-opts/aria2-opts/axel-opts,因为这些工具的命令行参数一般都包含-,所以需要用额外的--转义。另外多个命令行参数需要用引号合并到一起:

lx config -- aria2-opts "-s10 -x10 -c"

lx info

打印cookies文件里保存的迅雷内部id,包括登录的ID,一个内部使用的ID,以及gdriveid。

关于gdriveid:理论上gdriveid是下载迅雷离线链接需要的唯一cookie,你可以用lx list --download-url获取下载地址,然后用lx info获取gdriveid,然后手动使用其他工具下载,比如wget "--header=Cookie: gdriveid=your-gdriveid" download-url。

-i参数可以只打印登录ID:

lx info -i

如果想把登录id复制到剪切板:

lx info -i | clip

lx help

打印帮助信息。

lx help
lx help examples
lx help readme
lx help download

支持的下载工具

  • wget:默认下载工具。注意有些Linux发行版(比如某些运行在路由设备上的mini系统)自带的wget可能无法满足功能要求。可以尝试使用其他工具。
  • asyn:内置的下载工具。在命令行中加上--tool=asyn可以启用。注意此工具的下载表现一般,在高速下载或者设备性能不太好的情况(比如运行在低端路由上),CPU使用可能稍高。在我的RT-N16上,以250K/s的速度下载,CPU使用大概在10%~20%。
  • urllib2:内置下载工具。不支持断点续传错误重连,不建议使用。
  • curl:尚未测试。
  • aria2:测试通过。注意某些环境里的aria2c需要加上额外的参数才能运行。可以使用lx config进行配置:lx config -- aria2-opts --event-poll=select
  • axel: 测试通过。注意官方版本的axel有一个URL重定向长度超过255被截断的bug,需要手动修改源代码编译。见issue #44.
  • 其他工具,比如ProZilla,暂时都不支持。有需要请可以我,或者直接提交一个issue。

其他工具

  • lx hash可以用于手动计算hash。

      lx hash --ed2k filename
      lx hash --info-hash torrent-file
      lx hash --verify-sha1 filename sha1
      lx hash --verify-bt filename torrent-file
    
  • lixian_batch.py是我自己用的一个简单的“多任务”下载脚本。其实就是多个--input文件,每个文件里定义的链接下载到文件所在的目录里。

      python lixian_batch.py folder1/links.txt folder2/links.txt ...
    

既知问题

  1. --tool=asyn的性能不是很好。见“支持的下载工具”一节里的说明。
  2. 有些时候任务添加到服务器上,但是马上刷新拿不到这个数据。这应该是服务器同步的问题。技术上可以自动重刷一遍,但是暂时没有做。用户可以自己重试下。
  3. bt下载的校验如果失败,可能需要重新下载所有文件。从技术上来讲这是没有必要的。但是一来重下出错的片段有些繁琐,二来我自己都从来没遇到过bt校验失败需要重下的情况,所以暂时不考虑支持片段修复。更新:bt校验失败不会重下。
  4. 有时候因为帐号异常,登录需要验证码。目前还不支持验证码。

以后

其实一开始是考虑做一个可以在路由器上运行的网页版离线下载管理器的。但是这个工作量比命令行版的大很多(不是一个数量级的),在资源消耗和出错概率上也大很多,而且可能还要有更多的依赖库,安装起来也不方便。当然主要还是精力和需求的原因。现在的这个命令行本对我来说已经够用了,也挺简单,短期就不考虑增加网页版了。

相关项目

特别感谢

群晖公司在部分产品中绑定了迅雷离线脚本,并且捐赠了作者一台DS213+作为反馈。再此表示感谢!

许可协议

xunlei-lixian使用MIT许可协议。

此文档未完成。

xunlei-lixian's People

Contributors

iambus avatar layerssss avatar leeroyding avatar leojay avatar sycx avatar tchaikov avatar wayhomeke avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

xunlei-lixian's Issues

磁力链接input报错

单个下没问题,放文本文件里调用报错。任务已存在的话也没问题。

lx download --input data\ed2k.txt

Adding below tasks:
magnet:?xt=urn:btih:UBAHAW54JZ2QPBN7OZ36UOSY6VZIQO6B

File "lixian_cli.py", line 355, in find_tasks_to_download
raise NotImplementedError('task not found, wired: '+link)
NotImplementedError: task not found, wired: magnet:?xt=urn:btih:UBAHAW54JZ2QPBN7
OZ36UOSY6VZIQO6B

bt下载完成以后校验出错

Hashing bt ...
Traceback (most recent call last):
File "lx", line 738, in
execute_command()
File "lx", line 735, in execute_command
commandscommand
File "lx", line 471, in download_task
download_multiple_tasks(client, download, tasks, **download_args)
File "lx", line 327, in download_multiple_tasks
download_single_task(client, download, task, output_dir=output_dir, delete=d
elete, resuming=resuming, overwrite=overwrite, mini_hash=mini_hash)
File "lx", line 310, in download_single_task
verified = lixian_hash_bt.verify_bt(filename, lixian_hash_bt.bdecode(torrent
_file)['info'], file_set=file_set, progress_callback=bar.update)
File "/thunder/lixian_hash_bt.py", line 219, in verify_bt
return verify_bt_multiple(path, info, file_set=file_set, progress_callback=p
rogress_callback)
File "/thunder/lixian_hash_bt.py", line 179, in verify_bt_multiple
if sha1sum.digest() != sha1_stream.next_sha1() and complete_piece:
File "/thunder/lixian_hash_bt.py", line 111, in next_sha1
self.progress_callback(float(self.processed)/self.total)
File "lx", line 228, in update
bar = '{:>3}%[{:<40}]'.format(percent, bar)
ValueError: zero length field name in format

运行环境是python 2.6.4-3

aria2c '--out'参数的问题

aria2 version 1.10.9
'--out'接受的参数会被整个当作一个文件名而不是路径来处理,所以最后指定任何绝对路径都会下载到lx所在目录下的相对路径下。
要解决的话需要同时传'--dir'和'--out'两个参数给aria2c。

--all --continue 参数的问题

有正在下载的任务时,如果修改lixian.vip.xunlei.com的任务列表(增加新任务),之后执行 --all --continue 会删除掉之前未完成的任务,并从最后一个添加的任务开始重新下载

环境为DD-WRT+Python2.7+wget完整版

强烈要求支持 axel

支持多线程,断点续传,Cookie 的好工具啊,下载速度比 wget 好多了。

谢谢,很好用。

请问未来迅雷会封杀这个分析工具吗?

另外你的N16是使用 原装固件还是TT或者DD-WRT呢?

可以加你gtalk或者我们email聊聊吗? 可能有很多话题可以讨论。:D
[email protected]

能否增加选择性下载全部的功能

很多人的离线帐号是两人共用的,添加任务时,可以加个前缀作为区别。
比如用户1的所有下载任务名前缀都是user1
能不能实现这样的功能。
lixian_cli.py download --all user1

呃……

retry次数问题

似乎只能重试3次?

以下是aria2c跟的结果:

Status Legend:
(ERR):error occurred.

aria2 will resume download if the transfer is restarted.
If there are any errors, then see the log file. See '-l' option in help/man page for details.
Traceback (most recent call last):
File "lixian_cli.py", line 709, in
execute_command()
File "lixian_cli.py", line 706, in execute_command
commandscommand
File "lixian_cli.py", line 393, in download_task
download_multiple_tasks(client, download, tasks, download_args)
File "lixian_cli.py", line 271, in download_multiple_tasks
download_single_task(client, download, task, options)
File "lixian_cli.py", line 264, in download_single_task
download2(client, download_url, filename, task)
File "lixian_cli.py", line 196, in download2
download1(client, url, path, size)
File "lixian_cli.py", line 178, in download1
download(client, url, path)
File "lixian_cli.py", line 128, in aria2_download
raise Exception('aria2c exited abnormaly')
Exception: aria2c exited abnormaly
因为上面都是进度条,所以看不到重试了多少次,只能重试3次是wget下跟的结果。在我的网络环境下,重试一般都是有效的,但过一段时间(不定),又会出现502或504错误,希望可以间隔30秒或60秒自动重试一次,并且不限制重试次数。

上传种子时报异常

Traceback (most recent call last):
File "lixian_cli.py", line 625, in
execute_command()
File "lixian_cli.py", line 622, in execute_command
commandscommand
File "lixian_cli.py", line 551, in add_task
tasks = find_torrents_task_to_download(client, links)
File "lixian_cli.py", line 339, in find_torrents_task_to_download
client.add_torrent_task_by_content(torrent, os.path.basename(link))
File "/Users/Jackie/scripts/xunlei-lixian/lixian.py", line 261, in add_torrent_task_by_content
response = self.urlopen(commit_url, data=data).read()
File "/Users/Jackie/scripts/xunlei-lixian/lixian.py", line 40, in urlopen
args['data'] = urllib.urlencode(args['data'])
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib.py", line 1294, in urlencode
v = quote_plus(str(v))

好像是编码问题,python 2.7不兼容?

HTTP Error 504: Gateway Time-out

need retry...

Traceback (most recent call last):
File "/root/bin/lx_batch", line 14, in
download_batch(sys.argv[1:])
File "/root/bin/lx_batch", line 11, in download_batch
lixian_cli.execute_command(['download', '--input', f, '--delete', '--continue'])
File "/opt/root/projects/xunlei-lixian/lixian_cli.py", line 666, in execute_command
commandscommand
File "/opt/root/projects/xunlei-lixian/lixian_cli.py", line 424, in download_task
download_multiple_tasks(client, download, tasks, *_download_args)
File "/opt/root/projects/xunlei-lixian/lixian_cli.py", line 328, in download_multiple_tasks
download_single_task(client, download, task, output_dir=output_dir, delete=delete, resuming=resuming, overwrite=overwrite)
File "/opt/root/projects/xunlei-lixian/lixian_cli.py", line 324, in download_single_task
client.delete_task(task)
File "/opt/root/projects/xunlei-lixian/lixian.py", line 290, in delete_task
self.delete_task_by_id(task['id'])
File "/opt/root/projects/xunlei-lixian/lixian.py", line 287, in delete_task_by_id
self.delete_tasks_by_id([id])
File "/opt/root/projects/xunlei-lixian/lixian.py", line 282, in delete_tasks_by_id
response = json.loads(re.match(r'^delete_task_resp((.+))$', self.urlopen(url).read()).group(1))
File "/opt/root/projects/xunlei-lixian/lixian.py", line 44, in urlopen
return self.opener.open(urllib2.Request(url, *_args))
File "/opt/lib/python2.7/urllib2.py", line 400, in open
response = meth(req, response)
File "/opt/lib/python2.7/urllib2.py", line 513, in http_response
'http', request, response, code, msg, hdrs)
File "/opt/lib/python2.7/urllib2.py", line 438, in error
return self._call_chain(_args)
File "/opt/lib/python2.7/urllib2.py", line 372, in _call_chain
result = func(_args)
File "/opt/lib/python2.7/urllib2.py", line 521, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 504: Gateway Time-out

为何批量下载没有效果

lx list查看离线任务id。用lx download task-id1 task-id2 task-id3等进行下载,下完task-id1之后便退出了。用lx download --all也无法下载全部的离线任务,只下载第一个任务。不知道是什么问题。

路由上多任务后台运行问题

ssh到路由运行的添加多个任务id后多任务下载如何避免ssh断开后进程结束导致下载停止?尝试采用lx download id1 id2 id3 --output-dir xxx &后发现断开ssh后,后台只执行download id1下载任务,id2 id3并没有后台下载,这个不是脚本问题,而是进程后台运行问题,想请教一下iambus是如何在路由上后台下载的。

BT文件数量BUG

经测试 list_bt(self, task)方法返回的JSON,有30的数量上限,当大于30个文件则会被忽略。

测试资源为:
--torrent bt://585b232d91bf6bace1e7882217826b9c4063f334

download incomplete bt task

when downloading with taskid/fileid, if the file is complete but the whole task is incomplete, current code won't download any file. should support this usage.

在config中加入Output-dir参数

这个脚本似乎会默认将文件下载到放置这个脚本的目录下面,请问能不能在lx config 中加入选项output-dir能够指定文件默认的下载目录?

support lx config

Add lx config to save default settings:
lx config --password ...
lx config --tool asyn

add --mini-hash option

If file already exists, and the file size is completed (usually means a full hash was already done before), a full hash still will be performed. Add a --mini-hash option, in such case, just run a dcid hash (supposed to be very fast). This is used to verify ID (whether user is providing a different file), not content (whether user is providing a corrupted file).

不知可否实现「任务链接导出」和「根据任务添加时间不同而下载」?

1、能不能给 list 加一个 output 参数?这样可以直接把链接批量保存下来,和不太懂这个的朋友分享资源的时候直接给他一个txt文件,让他把里面的多个链接直接复制到下载工具的批量下载里就可以下载了。
比如:
~/xunlei-lixian/lixian_cli.py list --search 720X400 --download-url --no-id --no-name --no-status --output ~/downloads.txt

2、能不能给 download 加一个时间类的参数?
比如「下载刚刚被添加的任务」,「下载离线任务列表的前3个任务」或者「下载剩余保留天数为7天的任务」。

3、能不能给 add 加一个 prefix 参数可以用于给任务名添加各种前缀以便于过滤?比如时间前缀。
比如:
~/xunlei-lixian/lixian_cli.py add --input list.txt --prefix-currenttime
这样 list.txt 里面每一个链接被添加到离线任务列表的时候都会在任务名称前添加当前时间作为前缀。
比如 【20120310122605】The.Big.Bang.Theory.S05E15.720p.HDTV.x264-DIMENSION.mkv

谢谢~真是已经开发了太棒的工具。

[Bug] utf-8 解码问题

因为与人共用账号,不知道他们离线了什么文件,资源的文件名包含有 0xe3 这样的非法字符。当获取资源列表时就会发生 utf-8 解码错误,请问是否可以考虑 req.read().decode('utf-8', 'replace') 避免此类问题?

Exception: Probably login failed 登陆失效问题

使用的命令式 "lx login 迅雷号 密码" 和config后直接直接这两种方式都出现下面的登陆异常, 之前丢服务器上都没什么问题,跑了1个月, 这两天突然就这样。 但是web登陆离线就没有问题, 会不会是迅雷的登陆机制做了更改? 请帮忙看看。

运行环境是windows和centos都是python2.7

Traceback (most recent call last):
File "lixian_cli.py", line 693, in
execute_command()
File "lixian_cli.py", line 690, in execute_command
commandscommand
File "lixian_cli.py", line 68, in login
client = XunleiClient(args.username, args.password, args.cookies)
File "H:\resource\iambus-xunlei-lixian-01eedc4\lixian.py", line 35, in _init
_
self.login(username, password)
File "H:\resource\iambus-xunlei-lixian-01eedc4\lixian.py", line 107, in login
self.id = self.get_userid()
File "H:\resource\iambus-xunlei-lixian-01eedc4\lixian.py", line 63, in get_use
rid
raise Exception('Probably login failed')
Exception: Probably login failed

lx help, and more cli doc

  1. improve lx --help
  2. support lx help download
  3. support lx help readme (this should print the README, a full doc)
  4. support lx download --help

请教迅雷离线下载在python2.6下的问题

在openwrt的python2.6环境下迅雷离线下载 lx download id之后出现
root@DreamBox:~# lx download 75688984323
Traceback (most recent call last):
File "/bin/lx", line 711, in
execute_command()
File "/bin/lx", line 708, in execute_command
commandscommand
File "/bin/lx", line 417, in download_task
download_multiple_tasks(client, download, tasks, download_args)
File "/bin/lx", line 273, in download_multiple_tasks
download_single_task(client, download, task, options)
File "/bin/lx", line 212, in download_single_task
filename = os.path.join(output_dir, filename)
File "/usr/lib/python2.6/posixpath.py", line 67, in join
elif path == '' or path.endswith('/'):
AttributeError: 'bool' object has no attribute 'endswith'
如何解决?有没有db120wg能用的python2.7的ipk?

hash校验

hash校验部分能否作为一个参数,下载大文件校验的时候路由cpu占用极高,甚至程序会无响应,导致队列里未下载任务中断。

wget: no response from server

Connecting to gdl.lixian.vip.xunlei.com (125.39.149.75:80)
wget: no response from server
Traceback (most recent call last):
File "/bin/lx", line 709, in
execute_command()
File "/bin/lx", line 706, in execute_command
commandscommand
File "/bin/lx", line 393, in download_task
download_multiple_tasks(client, download, tasks, download_args)
File "/bin/lx", line 271, in download_multiple_tasks
download_single_task(client, download, task, options)
File "/bin/lx", line 247, in download_single_task
download2(client, download_url, path, f)
File "/bin/lx", line 196, in download2
download1(client, url, path, size)
File "/bin/lx", line 178, in download1
download(client, url, path)
File "/bin/lx", line 105, in wget_download
raise Exception('wget exited abnormaly')
Exception: wget exited abnormaly

需要手动重新lx download id 好几次才行,建议加个检测
要不添加上任务后,出了这个问题,下载任务就停了。

python2.6运行lixian_cli.py发生错误以及aria2的支持。

python2.6运行lixian_cli.py发生一些错误,自己修改一下正常了,还有aria2输出文件名是--out选项。
以下是我的修改。
gdriveid = str(client.get_gdriveid())

  • aria2_opts = ['aria2c', '--header=Cookie: gdriveid='+gdriveid, download_url]
  • aria2_opts.extends(('--split', '5')) #AttributeError: 'list' object has no attribute 'extends'(python 2.6.5)
  • aria2_opts.extends(('--output-file', filename)) # TODO: this option seems not supported by aria2c ... use --out for aria2
  • aria2_opts = ['aria2c', '--header=Cookie: gdriveid='+gdriveid, '--split=5', '--out='+filename, download_url]
  • #aria2_opts.extends(('--split', '5'))
  • #aria2_opts.extends(('--out', filename)) # TODO: this option seems not supported by aria2c ...
    if resuming:
    aria2_opts.append('-c')
    exit_code = subprocess.call(aria2_opts)
    @@ -212,7 +212,7 @@ def aria2_download(client, download_url, filename, resuming=False):

TODO: support axel, ProZilla

def escape_filename(name):

  • name = re.sub(r'&(amp;)+', '&', name, flags=re.I) #TypeError: sub() got an unexpected keyword argument 'flags'
  • name = re.sub(r'&(amp;)+', '&', name, re.I)
    name = re.sub(r'[/:*?"<>|]', '-', name)
    return name

wget下载速度很慢,经常掉线!

直接用lx download id 下载,速度只有10K左右,而且很不稳定,经常掉线,不知是不是迅雷离线服务器的问题。换过几个资源下载都一样。重试几次后会出现如下错误。
2012-03-01 23:03:58 (2.29 KB/s) - Connection closed at byte 3385312. Retrying.

--2012-03-01 23:04:03-- (try: 6) http://dl.u.lixian.vip.xunlei.com/download?fid=xzjdc7io3itr3LFrz02b0uScHCZoWKrRAAAAAMTghvxDVkHVt6OggyFBBhCbZWRd&mid=666&threshold=150&tid=68EA12CD709F53EDCA046FC796B92CCE&srcid=4&verno=1&g=C4E086FC435641D5B7A3A083214106109B65645D&scn=t9&i=C4E086FC435641D5B7A3A083214106109B65645D&t=1&ui=15748173&ti=83104037640&s=3517601896&m=0&n=01115D85262D65706C4F03D46E322E30324F00D57173756E640443883E6E642E76121F852D73656E610D1FD36D30702E6D0A47E45F00000000&ff=0&co=FC27817ECF041EB4734C0132236F01BA&vod=vod25.c10
Connecting to dl.u.lixian.vip.xunlei.com|118.186.160.13|:80... connected.
HTTP request sent, awaiting response... 206 Partial Content
Length: 3517601896 (3.3G), 3514216584 (3.3G) remaining [application/octet-stream]
Saving to: `/mnt/sda1/Download/fairplay-epl.2012.02.11.sunderland.vs.arsenal.720p.mkv'

0% [ ] 3,649,472 --.-K/s in 2m 29s

2012-03-01 23:06:35 (1.74 KB/s) - Connection closed at byte 3649472. Retrying.

--2012-03-01 23:06:41-- (try: 7) http://dl.u.lixian.vip.xunlei.com/download?fid=xzjdc7io3itr3LFrz02b0uScHCZoWKrRAAAAAMTghvxDVkHVt6OggyFBBhCbZWRd&mid=666&threshold=150&tid=68EA12CD709F53EDCA046FC796B92CCE&srcid=4&verno=1&g=C4E086FC435641D5B7A3A083214106109B65645D&scn=t9&i=C4E086FC435641D5B7A3A083214106109B65645D&t=1&ui=15748173&ti=83104037640&s=3517601896&m=0&n=01115D85262D65706C4F03D46E322E30324F00D57173756E640443883E6E642E76121F852D73656E610D1FD36D30702E6D0A47E45F00000000&ff=0&co=FC27817ECF041EB4734C0132236F01BA&vod=vod25.c10
Connecting to dl.u.lixian.vip.xunlei.com|118.186.160.13|:80... connected.
HTTP request sent, awaiting response... 502 Bad Gateway
2012-03-01 23:06:51 ERROR 502: Bad Gateway.

Traceback (most recent call last):
File "/bin/lx", line 710, in
execute_command()
File "/bin/lx", line 707, in execute_command
commandscommand
File "/bin/lx", line 416, in download_task
download_multiple_tasks(client, download, tasks, download_args)
File "/bin/lx", line 272, in download_multiple_tasks
download_single_task(client, download, task, options)
File "/bin/lx", line 265, in download_single_task
download2(client, download_url, filename, task)
File "/bin/lx", line 197, in download2
download1(client, url, path, size)
File "/bin/lx", line 179, in download1
download(client, url, path)
File "/bin/lx", line 106, in wget_download
raise Exception('wget exited abnormaly')
Exception: wget exited abnormaly

support lx rename

sometimes the default task name from bt includes invalid chars. support "lx rename" to rename it.

--mini-hash is confusing

Actually --no-hash is a true mini hash, --mini-hash is not...need figure out a better name...

执行download命令下载时,会出现WindowsError [Error 2]

Downloading U2Game.Net-Toaru.Kagaku.no.Chou.Denjihou.CRK.JPN.科学超电磁炮.日版ISO-1191M.7z ...
Traceback (most recent call last):
File "F:\develop\xunlei-lixian\lixian_cli.py", line 690, in
execute_command()
File "F:\develop\xunlei-lixian\lixian_cli.py", line 687, in execute_command
commandscommand
File "F:\develop\xunlei-lixian\lixian_cli.py", line 409, in download_task
download_multiple_tasks(client, download, tasks, download_args)
File "F:\develop\xunlei-lixian\lixian_cli.py", line 265, in download_multiple_tasks
download_single_task(client, download, task, options)
File "F:\develop\xunlei-lixian\lixian_cli.py", line 258, in download_single_task
download2(client, download_url, filename, task)
File "F:\develop\xunlei-lixian\lixian_cli.py", line 194, in download2
download1(client, url, path, size)
File "F:\develop\xunlei-lixian\lixian_cli.py", line 176, in download1
download(client, url, path)
File "F:\develop\xunlei-lixian\lixian_cli.py", line 102, in wget_download
exit_code = subprocess.call(wget_opts)
File "f:\python27\lib\subprocess.py", line 486, in call
return Popen(_popenargs, *_kwargs).wait()
File "f:\python27\lib\subprocess.py", line 672, in init
errread, errwrite)
File "f:\python27\lib\subprocess.py", line 882, in _execute_child
startupinfo)
WindowsError: [Error 2]

感觉好像是中文任务名的问题。

[FEATURE REQUEST] wish to download all completed job by one command

Hi, do you have a plan to support another command argument to download all completed items one time.

Now I can specify jobs' id to download them manually. However, if I could run a batch command, maybe lx download --completed, then all completed items are downloaded one by one automatically. I think it should be more useful :)

utf-8 编码问题

$ lx list

File "/workshop/xunlei-lixian/lixian_cli.py", line 709, in <module>
    execute_command()
File "/workshop/xunlei-lixian/lixian_cli.py", line 706, in execute_command
    commands[command](args[1:])
File "/workshop/xunlei-lixian/lixian_cli.py", line 526, in list_task
    tasks = client.read_all_tasks()
File "/workshop/xunlei-lixian/lixian.py", line 169, in read_all_tasks
    links, next_link = self.read_task_page(st)
File "/workshop/xunlei-lixian/lixian.py", line 162, in read_task_page
   return self.read_task_page_url(url)
File "/workshop/xunlei-lixian/lixian.py", line 145, in read_task_page_url
   page = req.read().decode('utf-8')
File "/usr/lib/python2.7/encodings/utf_8.py", line 16, in decode
   return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xef in position 49351: invalid continuation byte

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.