Documentation ¶
Overview ¶
Low-level AniDB UDP API client library
Implements the commands essential to setting up and tearing down an API connection, as well as an asynchronous layer. Throttles sends internally according to API spec.
This library doesn't implement caching; beware since aggressive caching is an implementation requirement. Not doing so can get you banned.
Index ¶
Constants ¶
const ( AniDBUDPServer = "api.anidb.net" AniDBUDPPort = 9000 )
Variables ¶
var TimeoutError = errors.New("Timeout")
The value APIReply.Error() returns after a timeout. Unrelated to the server-side error 604 TIMEOUT - DELAY AND RESUBMIT.
Functions ¶
This section is empty.
Types ¶
type APIReply ¶
type APIReply interface { // An opaque string used as identifying tag. Tag() string // The integer code for the reply. Code() int // The description for the reply (first line minus code). Text() string // Slice with all lines of the reply. Lines() []string // Indicates whether the network code detected truncation. Truncated() bool // Returns the underlying error, if any. Error() error }
The interface for all UDP API replies.
The user should call Error() to verify if the API call completed successfully.
type AniDBUDP ¶
type AniDBUDP struct { // Interval between keep-alive packets; only sent when PUSH notifications are enabled (default: 20 minutes) KeepAliveInterval time.Duration // The time to wait before a packet is considered lost (default: 45 seconds) Timeout time.Duration // Channel where PUSH notifications are sent to Notifications chan APIReply // contains filtered or unexported fields }
func (*AniDBUDP) Auth ¶
Authenticates the supplied user with the supplied password. Blocks until we have a reply. Needed before almost any other API command can be used.
If the udpKey is not "", then the connection will be encrypted, but the protocol's encryption uses the VERY weak ECB mode.
http://wiki.anidb.net/w/UDP_API_Definition#AUTH:_Authing_to_the_AnimeDB
http://wiki.anidb.net/w/UDP_API_Definition#ENCRYPT:_Start_Encrypted_Session
func (*AniDBUDP) Ping ¶
Simple echo command. The recommended way to verify if the server is alive and responding. Does not require authentication.
Returns a channel through which the eventual response will be sent.
http://wiki.anidb.net/w/UDP_API_Definition#PING:_Ping_Command
func (*AniDBUDP) SendRecv ¶
Sends the requested query to the AniDB UDP API server.
Returns a channel through which the eventual reply is sent.
See http://wiki.anidb.net/w/UDP_API_Definition for the defined commands.
func (*AniDBUDP) Uptime ¶
func (a *AniDBUDP) Uptime() <-chan *UptimeReply
Retrieves the server's uptime. The recommended way to verify if a session is valid.
Returns a channel through which the eventual response will be sent.
http://wiki.anidb.net/w/UDP_API_Definition#UPTIME:_Retrieve_Server_Uptime