summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pyanidb/__init__.py24
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)