def update(self, info_hash, fields): multi_call = xmlrpc_client.MultiCall(self._server) for key, val in fields.items(): method_name = 'd.%s.set' % key getattr(multi_call, method_name)(native_str(info_hash), native_str(val)) return multi_call()[0]
def torrent(self, info_hash, fields=None): """ Get the details of a torrent """ info_hash = native_str(info_hash) if not fields: fields = list(self.default_fields) fields = self._clean_fields(fields) multi_call = xmlrpc_client.MultiCall(self._server) for field in fields: method_name = 'd.%s' % field getattr(multi_call, method_name)(info_hash) resp = multi_call() # TODO: Maybe we should return a named tuple or a Torrent class? return dict(list(zip(self._clean_fields(fields, reverse=True), [val for val in resp])))