2

Why is it giving 400 bad request for the following code. We want to schedule a torrent using web API of utorrent.

import urllib2, base64

username = "username"
password = "password"

request = urllib2.Request("http://<my_ip>:<torrent_webapi_port>/gui/?action=add-url&s=%s" % urllib2.quote("http://torcache.net/torrent/CDADFE86960C3255EB37B15F7E45C281F3A3C937.torrent?title=[kickass.to]arrow.s02e14.hdtv.x264.lol.ettv"))
base64string = base64.encodestring('%s:%s' % (username, password)).replace('\n', '')
request.add_header("Authorization", "Basic %s" % base64string)
result = urllib2.urlopen(request)
print result.read()
4

1 回答 1

3

请阅读以下令牌认证系统。

您应该在所有请求中发送一个名为“token=”的额外参数。您可以从中获取 token_value

http://:utorrent_web_api_port/gui/token.html

http://www.utorrent.com/community/developers/webapi#devs4

详细解释在下面的链接中给出。

https://github.com/bittorrent/webui/wiki/TokenSystem

于 2014-02-27T20:57:52.227 回答