def _make_opener(realm, base_url, username, password): """uTorrent API need HTTP Basic Auth and cookie support for token verify.""" auth = HTTPBasicAuthHandler() auth.add_password(realm=realm, uri=base_url, user=username, passwd=password) opener = build_opener(auth) install_opener(opener) cookie_jar = http_cookiejar.CookieJar() cookie_handler = HTTPCookieProcessor(cookie_jar) handlers = [auth, cookie_handler] opener = build_opener(*handlers) return opener
def _make_opener(self): # create opener with cookie handler to carry QBitTorrent SID cookie cookie_handler = HTTPCookieProcessor(self.cookiejar) handlers = [cookie_handler] return build_opener(*handlers)