def method_add_torrent(self, torrent, download_to=None): torrent_dump = base64encode(torrent).decode('utf-8') return self.query( self.build_request_payload( 'webapi.add_torrent', [torrent_dump, {'download_location': download_to}] ) )
def method_add_torrent(self, torrent, download_to=None): args = { 'metainfo': base64encode(torrent), } if download_to is not None: args['download-dir'] = download_to return self.query(self.build_request_payload('torrent-add', args)) # torrent-added
def method_add_torrent(self, torrent, download_to=None): torrent_dump = base64encode(torrent).decode('utf-8') return self.query( self.build_request_payload( 'webapi.add_torrent', [torrent_dump, { 'download_location': download_to }]))
def test_base64encode_str(): string_to_encode = 'this is string' encoded_bytes = utils.base64encode(string_to_encode) assert isinstance(encoded_bytes, bytes) assert encoded_bytes == b'dGhpcyBpcyBzdHJpbmc=\n'
def test_base64encode_bytes(): bytes_to_encode = b'this is bytes to encode' encoded_bytes = utils.base64encode(bytes_to_encode) assert isinstance(encoded_bytes, bytes) assert encoded_bytes == b'dGhpcyBpcyBieXRlcyB0byBlbmNvZGU=\n'
def test_base64encode_str(): string_to_encode = 'this is string' encoded_string = utils.base64encode(string_to_encode) assert isinstance(encoded_string, str) assert encoded_string == "dGhpcyBpcyBzdHJpbmc=\n"
def test_base64encode_bytes(): bytes_to_encode = b'this is bytes to encode' encoded_string = utils.base64encode(bytes_to_encode) assert isinstance(encoded_string, str) assert encoded_string == 'dGhpcyBpcyBieXRlcyB0byBlbmNvZGU=\n'