Merge pull request #763 from adam111316/adba_update

Update adba libs
This commit is contained in:
adam111316 2014-08-31 14:14:46 +08:00
commit 1f8cf44ea2
4 changed files with 139 additions and 7 deletions

View file

@ -244,6 +244,23 @@ class Connection(threading.Thread):
""" """
return self.handle(PushAckCommand(nid), callback) return self.handle(PushAckCommand(nid), callback)
def notification(self, aid=None, gid=None, type=None, priority=None, callback=None):
"""
Add a notification
parameters:
aid - Anime id
gid - Group id
type - Type of notification: type=> 0=all, 1=new, 2=group, 3=complete
priority - low = 0, medium = 1, high = 2 (unconfirmed)
structure of parameters:
[aid={int}|gid={int}]&type={int}&priority={int}
"""
return self.handle(Notification(aid, gid, type, priority), callback)
def notifyadd(self, aid=None, gid=None, type=None, priority=None, callback=None): def notifyadd(self, aid=None, gid=None, type=None, priority=None, callback=None):
""" """
Add a notification Add a notification
@ -261,6 +278,22 @@ class Connection(threading.Thread):
return self.handle(NotifyAddCommand(aid, gid, type, priority), callback) return self.handle(NotifyAddCommand(aid, gid, type, priority), callback)
def notifydel(self, aid=None, gid=None, type=None, priority=None, callback=None):
"""
Add a notification
parameters:
aid - Anime id
gid - Group id
type - Type of notification: type=> 0=all, 1=new, 2=group, 3=complete
priority - low = 0, medium = 1, high = 2 (unconfirmed)
structure of parameters:
[aid={int}|gid={int}]&type={int}&priority={int}
"""
return self.handle(NotifyDelCommand(aid, gid, type, priority), callback)
def notify(self, buddy=None, callback=None): def notify(self, buddy=None, callback=None):
""" """

View file

@ -99,9 +99,18 @@ class aniDBabstractObject(object):
priority - low = 0, medium = 1, high = 2 (unconfirmed) priority - low = 0, medium = 1, high = 2 (unconfirmed)
""" """
if (self.aid): if self.aid:
self.aniDB.notifyadd(aid=self.aid, type=1, priority=1) self.aniDB.notifyadd(aid=self.aid, type=1, priority=1)
def del_notification(self):
"""
type - Type of notification: type=> 0=all, 1=new, 2=group, 3=complete
priority - low = 0, medium = 1, high = 2 (unconfirmed)
"""
if self.aid:
self.aniDB.notifydel(aid=self.aid, type=1, priority=1)
class Anime(aniDBabstractObject): class Anime(aniDBabstractObject):
def __init__(self, aniDB, name=None, aid=None, tvdbid=None, paramsA=None, autoCorrectName=False, load=False): def __init__(self, aniDB, name=None, aid=None, tvdbid=None, paramsA=None, autoCorrectName=False, load=False):

View file

@ -103,6 +103,14 @@ class PushAckCommand(Command):
Command.__init__(self, 'PUSHACK', **parameters) Command.__init__(self, 'PUSHACK', **parameters)
class Notification(Command):
def __init__(self, aid=None, gid=None, type=None, priority=None):
if not (aid or gid) or (aid and gid):
raise AniDBIncorrectParameterError, "You must provide aid OR gid for NOTIFICATION command"
parameters = {'aid': aid, "gid": gid, "type": type, "priority": priority}
Command.__init__(self, 'NOTIFICATION', **parameters)
class NotifyAddCommand(Command): class NotifyAddCommand(Command):
def __init__(self, aid=None, gid=None, type=None, priority=None): def __init__(self, aid=None, gid=None, type=None, priority=None):
if not (aid or gid) or (aid and gid): if not (aid or gid) or (aid and gid):
@ -111,6 +119,14 @@ class NotifyAddCommand(Command):
Command.__init__(self, 'NOTIFICATIONADD', **parameters) Command.__init__(self, 'NOTIFICATIONADD', **parameters)
class NotifyDelCommand(Command):
def __init__(self, aid=None, gid=None, type=None, priority=None):
if not (aid or gid) or (aid and gid):
raise AniDBIncorrectParameterError, "You must provide aid OR gid for NOTIFICATIONDEL command"
parameters = {'aid': aid, "gid": gid, "type": type, "priority": priority}
Command.__init__(self, 'NOTIFICATIONDEL', **parameters)
class NotifyCommand(Command): class NotifyCommand(Command):
def __init__(self, buddy=None): def __init__(self, buddy=None):
parameters = {'buddy': buddy} parameters = {'buddy': buddy}

View file

@ -436,6 +436,27 @@ class MylistStatsResponse(Response):
self.coderep = () self.coderep = ()
class NotificationResponse(Response):
def __init__(self, cmd, restag, rescode, resstr, datalines):
"""
attributes:
data:
nid - notification id
unknown - unsure what this parameter is
type - Type of notification: type=> 0=all, 1=new, 2=group, 3=complete
aid - anime id
priority - low = 0, medium = 1, high = 2 (unconfirmed)
date - date notification subscribed to
"""
Response.__init__(self, cmd, restag, rescode, resstr, datalines)
self.codestr = 'NOTIFICATION'
self.codehead = ()
self.codetail = ('nid', 'unknown', 'type', 'aid', 'priority', 'date')
self.coderep = ()
class AnimeResponse(Response): class AnimeResponse(Response):
def __init__(self, cmd, restag, rescode, resstr, datalines): def __init__(self, cmd, restag, rescode, resstr, datalines):
Response.__init__(self, cmd, restag, rescode, resstr, datalines) Response.__init__(self, cmd, restag, rescode, resstr, datalines)
@ -759,6 +780,21 @@ class NotificationAddedResponse(Response):
self.codetail = ('nid') self.codetail = ('nid')
self.coderep = () self.coderep = ()
class NotificationDeletedResponse(Response):
def __init__(self, cmd, restag, rescode, resstr, datalines):
"""
attributes:
data:
nid - notofication id
"""
Response.__init__(self, cmd, restag, rescode, resstr, datalines)
self.codestr = 'NOTIFICATION_ITEM_DELETED'
self.codehead = ()
self.codetail = ()
self.coderep = ()
class NotificationUpdatedResponse(Response): class NotificationUpdatedResponse(Response):
def __init__(self, cmd, restag, rescode, resstr, datalines): def __init__(self, cmd, restag, rescode, resstr, datalines):
@ -776,6 +812,25 @@ class NotificationUpdatedResponse(Response):
self.coderep = () self.coderep = ()
class MultipleNotificationResponse(Response):
def __init__(self, cmd, restag, rescode, resstr, datalines):
"""
attributes:
data:
nid - notification id
type -
priority -
"""
Response.__init__(self, cmd, restag, rescode, resstr, datalines)
self.codestr = 'MULTIPLE NOTIFICATION ITEMS'
self.codehead = ()
self.codetail = ()
self.coderep = ('nid', 'type', 'priority',)
class NotificationEnabledResponse(Response): class NotificationEnabledResponse(Response):
def __init__(self, cmd, restag, rescode, resstr, datalines): def __init__(self, cmd, restag, rescode, resstr, datalines):
""" """
@ -913,7 +968,7 @@ class NotifyackSuccessfulNResponse(Response):
self.coderep = () self.coderep = ()
class NotificationResponse(Response): class NotificationStateResponse(Response):
def __init__(self, cmd, restag, rescode, resstr, datalines): def __init__(self, cmd, restag, rescode, resstr, datalines):
""" """
attributes: attributes:
@ -1233,6 +1288,21 @@ class MultipleFilesFoundResponse(Response):
self.coderep = ('fid',) self.coderep = ('fid',)
class NoSuchNotificationResponse(Response):
def __init__(self, cmd, restag, rescode, resstr, datalines):
"""
attributes:
data:
"""
Response.__init__(self, cmd, restag, rescode, resstr, datalines)
self.codestr = 'NO_SUCH_NOTIFICATION'
self.codehead = ()
self.codetail = ()
self.coderep = ()
class NoGroupsFoundResponse(Response): class NoGroupsFoundResponse(Response):
def __init__(self, cmd, restag, rescode, resstr, datalines): def __init__(self, cmd, restag, rescode, resstr, datalines):
""" """
@ -1868,6 +1938,7 @@ responses = {
'220': FileResponse, '220': FileResponse,
'221': MylistResponse, '221': MylistResponse,
'222': MylistStatsResponse, '222': MylistStatsResponse,
'224': NotificationResponse,
'225': GroupstatusResponse, '225': GroupstatusResponse,
'230': AnimeResponse, '230': AnimeResponse,
'231': AnimeBestMatchResponse, '231': AnimeBestMatchResponse,
@ -1875,7 +1946,9 @@ responses = {
'240': EpisodeResponse, '240': EpisodeResponse,
'245': ProducerResponse, '245': ProducerResponse,
'246': NotificationAddedResponse, '246': NotificationAddedResponse,
'247': NotificationDeletedResponse,
'248': NotificationUpdatedResponse, '248': NotificationUpdatedResponse,
'249': MultipleNotificationResponse,
'250': GroupResponse, '250': GroupResponse,
'253': BuddyListResponse, '253': BuddyListResponse,
'254': BuddyStateResponse, '254': BuddyStateResponse,
@ -1895,7 +1968,7 @@ responses = {
'280': PushackConfirmedResponse, '280': PushackConfirmedResponse,
'281': NotifyackSuccessfulMResponse, '281': NotifyackSuccessfulMResponse,
'282': NotifyackSuccessfulNResponse, '282': NotifyackSuccessfulNResponse,
'290': NotificationResponse, '290': NotificationStateResponse,
'291': NotifylistResponse, '291': NotifylistResponse,
'292': NotifygetMessageResponse, '292': NotifygetMessageResponse,
'293': NotifygetNotifyResponse, '293': NotifygetNotifyResponse,
@ -1914,6 +1987,7 @@ responses = {
'320': NoSuchFileResponse, '320': NoSuchFileResponse,
'321': NoSuchEntryResponse, '321': NoSuchEntryResponse,
'322': MultipleFilesFoundResponse, '322': MultipleFilesFoundResponse,
'324': NoSuchNotificationResponse,
'325': NoGroupsFoundResponse, '325': NoGroupsFoundResponse,
'330': NoSuchAnimeResponse, '330': NoSuchAnimeResponse,
'340': NoSuchEpisodeResponse, '340': NoSuchEpisodeResponse,