Skip to content

Commit

Permalink
添加torrent时选择文件
Browse files Browse the repository at this point in the history
  • Loading branch information
chliny committed Sep 27, 2013
1 parent 6a1f6a3 commit 46a1584
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
3 changes: 2 additions & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ http://lixian.qq.com/

12 12 29 修复腾讯改版后无法登陆,和登陆验证referer

13 09 27 支持添加BT任务,但仍无法实现将BT文件信息上传,因此离线服务器已有的资源能够秒下,但其他种子会出现下载失败需要在网页上添加。
13 09 27 支持添加BT任务,但仍无法实现将BT文件信息上传,因此离线服务器已有的资源能够秒下,但其他种子会出现下载失败仍需要在网页上添加。
支持magnet,但同样只有离线服务器已有的资源能下载
31 changes: 29 additions & 2 deletions xfdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,8 +364,11 @@ def __addtask(self):
if pid:
return
torinfo = self.__getmeta(url)
fileinfo = torinfo.metadata
else:
torinfo = torrent_info(uniurl)
#fileinfo = open(url).read()
fileinfo = torinfo.metadata()

torhash = torinfo.info_hash()
if torhash.is_all_zeros():
Expand All @@ -377,7 +380,32 @@ def __addtask(self):
btindexs = []
btsizes = []
index = 0
defaultchose = []
aversize = torinfo.total_size() / torinfo.num_files()
_print ("序号\t大小\t文件名")
for fileentry in torinfo.files():
name = fileentry.path.split("/")[-1]
size = int(fileentry.size)
_print ("%d\t%d\t%s" % (index,size,name))
if size > aversize:
defaultchose.append(str(index))

index += 1

chosestr = raw_input("请选择要下载的文件,空格隔开:(默认:%s)" % " ".join(defaultchose))
realchose = chosestr.strip().split()
if realchose is None or len(realchose) == 0:
realchose = defaultchose

for i in realchose:
i = int(i)
if i >= index:
_print("序号超出范围!")
if not pid:
sys.exit(-1)
return False

fileentry = torinfo.files()[i]
btfilenames.append(fileentry.path)
btindexs.append(str(index))
index += 1
Expand All @@ -387,7 +415,6 @@ def __addtask(self):
btfilename = "#".join(btfilenames)
btfilesize = "#".join(btsizes)

fileinfo = open(url).read()
#fileinfo = self.__toUnicode(fileinfo).encode("utf8")
#print fileinfo
data1={"name":"myfile",
Expand Down Expand Up @@ -427,7 +454,7 @@ def __addtask(self):
}
urlv="http://lixian.qq.com/handler/lixian/add_to_lixian.php"
istr = self.__request(urlv,data)
print istr
#print istr

def __getmeta(self,magneturl):
from libtorrent import session
Expand Down

0 comments on commit 46a1584

Please # to comment.