From 94b459a32ec5cafb879536c99fa3012eb27ee363 Mon Sep 17 00:00:00 2001 From: chliny Date: Sun, 2 Jun 2013 10:01:12 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=9D=E8=AF=95=E5=A2=9E=E5=8A=A0BT=E4=B8=8B?= =?UTF-8?q?=E8=BD=BD=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + README | 2 +- xfdown.py | 43 ++++++++++++++++++++++++++++++++++++------- 3 files changed, 38 insertions(+), 8 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..871bb87 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +cookie diff --git a/README b/README index 80d15d8..43368b7 100644 --- a/README +++ b/README @@ -6,4 +6,4 @@ http://lixian.qq.com/ 调用aria2下载 可实现多线程,断点续传等特性 -12 12 29 修复腾讯改版后无法登陆,和登陆验证referer \ No newline at end of file +12 12 29 修复腾讯改版后无法登陆,和登陆验证referer diff --git a/xfdown.py b/xfdown.py index f163aff..855ab0a 100755 --- a/xfdown.py +++ b/xfdown.py @@ -349,12 +349,40 @@ def __addtask(self): else: url = self._addurl filename=self.getfilename_url(url) - data={"down_link":url,\ - "filename":filename,\ - "filesize":0,\ - } - urlv="http://lixian.qq.com/handler/lixian/add_to_lixian.php" - str = self.__request(urlv,data) + if os.path.isfile(url): + filesize=os.path.getsize(filename) + orisize = filesize + dw=["B","K","M","G"] + for i in range(4): + _dw=dw[i] + if filesize>=1024: + filesize=filesize/1024 + else: + break + filesize="%.1f%s"%(filesize,_dw) + filecontent = open(filename,'rb').read() + hash = self.__md5(filecontent) + + data={"name":"myfile",\ + "ret":0,\ + "hash":hash,\ + "files":[{"file_name":filename,\ + "file_size":filesize,\ + "file_size_ori":orisize,\ + "file_index":0,\ + }] + } + print data + urlv="http://lixian.qq.com/handler/bt_handler.php?cmd=readinfo" + str = self.__request(urlv,data) + print str + else: + data={"down_link":url,\ + "filename":filename,\ + "filesize":0,\ + } + urlv="http://lixian.qq.com/handler/lixian/add_to_lixian.php" + str = self.__request(urlv,data) def __online(self): _print("输入需要在线观看的任务序号") @@ -440,7 +468,8 @@ def usage(): print(" -h,--help\tshow this usage and exit.") print(" -d ,--downloaddir=\n\tset the download dir.") print(" -p ,--player=\n\tset the player.") - print("\n\nsee https://github.com/kikyous/xfdown for most newest version and more information") + print(" -A ,--add=\n\tadd the url to offline task.") + print("\n\nsee https://github.com/chliny/xfdown for most newest version and more information") try: xf = XF() if not hasattr(xf,"_downpath"):