-
Notifications
You must be signed in to change notification settings - Fork 118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
运行downloadTorrent.py 出错+1 #5
Comments
恩恩。写完代码的时候那个时候还可以用,可以push request过来呢。 |
你的代码很给力,我已经在研究中,我的毕业设计,原型就选你这个了,希望楼主之后可以帮忙解决我一些不懂的问题,谢谢. |
好的没问题 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
个人建议把种子下载的方式改成国内迅雷的种子库
这样解决有些网站国内被墙的问题.
!/usr/bin/python
coding=utf-8
"""
magnet:?xt=urn:btih:B298DD7E3BF7B300FF1F235B90FD5441002FE440
magnet:?xt=urn:btih:506F4F0BE4D982E2E45711B7FA9BD4B03D3908CF
magnet:?xt=urn:btih:2F2D9E0C41B0CDB7B5B565532C3DB4F8EDB61E01
"""
import sys, os, urllib
def magnet_to_bt(magnet_address):
beg = magnet_address.rfind(':')
str = magnet_address[beg+1:]
b_word = str[0:2]
e_word = str[-2:]
bt_address = 'http://bt.box.n0808.com/' + b_word + '/' + e_word + '/' + str + '.torrent'
return bt_address
if name == 'main':
if len(sys.argv) > 2:
print("Usage:\n\t%s \nor\n\t%s [read from stdin]" % (sys.argv[0], sys.argv[0]))
sys.exit()
if len(sys.argv) == 2:
magnet = sys.argv[1]
if -1 == magnet.find(':'):
sys.exit('invalid magnet address')
bt_url = magnet_to_bt(magnet)
os.system("wget " + bt_url)
else:
for line in sys.stdin:
if -1 == line.find(':'):
continue
url = magnet_to_bt(line[0:-1])
pos = url.rfind('/')
file_name = url[pos+1:]
urllib.urlretrieve(url, file_name)
The text was updated successfully, but these errors were encountered: