diff options
author | Jon Bergli Heier <snakebite@jvnv.net> | 2009-11-02 15:20:17 +0100 |
---|---|---|
committer | Jon Bergli Heier <snakebite@jvnv.net> | 2009-11-02 15:20:17 +0100 |
commit | cf4160dbe6df5a54d27773eed669c9170f78bc19 (patch) | |
tree | 3504a8e15490088b786470c2e6f74e1dbd4efab4 | |
parent | 528cd7438ca34880844b2c808a6eca30a06f80aa (diff) |
Implemented ANIMEDESC.
-rw-r--r-- | pyanidb/__init__.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/pyanidb/__init__.py b/pyanidb/__init__.py index 57c44c2..ccb8a89 100644 --- a/pyanidb/__init__.py +++ b/pyanidb/__init__.py @@ -51,6 +51,9 @@ class AniDBNotInMylist(AniDBError): class AniDBUnknownAnime(AniDBError): pass +class AniDBUnknownDescription(AniDBError): + pass + class AniDB: def __init__(self, username, password, localport = 1234, server = ('api.anidb.info', 9000)): self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) @@ -199,3 +202,24 @@ class AniDB: self.auth() else: raise AniDBReplyError(code, text) + + def get_animedesc(self, aid, retry = False): + args = {'aid': aid, 'part': 0, 's': self.session} + description = '' + while 1: + code, text, data = self.execute('ANIMEDESC', args, retry) + if code == 233: + curpart, maxpart, desc = data[0] + description += desc + if curpart == maxpart: + return description + else: + args['part'] = int(curpart)+1 + elif code == 330: + raise AniDBUnknownAnime() + elif code == 333: + raise AnidBUnknownDescription() + elif code in (501, 506): + self.auth() + else: + raise AniDBReplyError(code, text) |