X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/disorder/blobdiff_plain/812b526d127c6657e571db8b33a58137af6709cd..bbaed9ec1e6fe1cc74787148535c7f3b9478d78e:/python/disorder.py.in diff --git a/python/disorder.py.in b/python/disorder.py.in index 3e1541e..fe054a9 100644 --- a/python/disorder.py.in +++ b/python/disorder.py.in @@ -50,7 +50,7 @@ import os import pwd import socket import binascii -import sha +import hashlib import sys import locale @@ -66,6 +66,18 @@ _unquoted = re.compile("[^\"' \\t\\n\\r][^ \t\n\r]*") _response = re.compile("([0-9]{3}) ?(.*)") +# hashes +_hashes = { + "sha1": hashlib.sha1, + "SHA1": hashlib.sha1, + "sha256": hashlib.sha256, + "SHA256": hashlib.sha256, + "sha384": hashlib.sha384, + "SHA384": hashlib.sha384, + "sha512": hashlib.sha512, + "SHA512": hashlib.sha512, +}; + version = "_version_" ######################################################################## @@ -387,8 +399,7 @@ class client: password = self.config['password'] else: password = self.password - # TODO support algorithms other than SHA-1 - h = sha.sha() + h = _hashes[algo]() h.update(password) h.update(binascii.unhexlify(challenge)) self._simple("user", user, h.hexdigest()) @@ -428,6 +439,16 @@ class client: res, details = self._simple("play", track) return unicode(details) # because it's unicode in queue() output + def playafter(self, target, tracks): + """Insert tracks into a specific point in the queue. + + Arguments: + target -- target ID or None to insert at start of queue + tracks -- a list of tracks to play""" + if target is None: + target = '' + self._simple("playafter", target, *tracks) + def remove(self, track): """Remove a track from the queue.