]> git.lizzy.rs Git - go-anidb.git/log
go-anidb.git
10 years agomisc: Add an iterator to EpisodeRange
Diogo Franco (Kovensky) [Wed, 17 Jul 2013 20:54:10 +0000 (17:54 -0300)]
misc: Add an iterator to EpisodeRange

10 years agomisc: Rename (Episode).(Inc|Dec) to (Episode).(IncPart|DecPart)
Diogo Franco (Kovensky) [Wed, 17 Jul 2013 20:53:31 +0000 (17:53 -0300)]
misc: Rename (Episode).(Inc|Dec) to (Episode).(IncPart|DecPart)

10 years agomisc: Allow adding/removing arbitrary episodes to an EpisodeList
Diogo Franco (Kovensky) [Wed, 17 Jul 2013 17:57:56 +0000 (14:57 -0300)]
misc: Allow adding/removing arbitrary episodes to an EpisodeList

10 years agomisc: Be more cautious when merging partial ranges
Diogo Franco (Kovensky) [Wed, 17 Jul 2013 17:56:13 +0000 (14:56 -0300)]
misc: Be more cautious when merging partial ranges

Change the touch() method to not accept touches where the left side is a
partial episode with unknown number of parts. If the number of parts is
known, then only accept if it's the last part.

10 years agomisc: (*EpisodeRange).Split(*Episode) -- Splits a range
Diogo Franco (Kovensky) [Wed, 17 Jul 2013 17:26:02 +0000 (14:26 -0300)]
misc: (*EpisodeRange).Split(*Episode) -- Splits a range

Also define Inc/IncNumber/Dec/DecNumber for episodes, used internally by
Split. Includes test.

10 years agoConvert cache system to github.com/Kovensky/go-fscache
Diogo Franco (Kovensky) [Tue, 16 Jul 2013 22:47:39 +0000 (19:47 -0300)]
Convert cache system to github.com/Kovensky/go-fscache

Includes wrapper methods that keep the Cached timestamp more-or-less
synchronized with the cache. Internally assert that the objects that
are supposed to have embedded timestamps implement the right interface.

Changes intent map to use interface{}, as there's no reason for the
intents to have to be cacheable.

10 years agoanidb: Update documentation / comments
Diogo Franco (Kovensky) [Tue, 16 Jul 2013 17:06:32 +0000 (14:06 -0300)]
anidb: Update documentation / comments

10 years agomisc: CountEpisodes and convenience conversion functions
Diogo Franco (Kovensky) [Tue, 16 Jul 2013 17:06:13 +0000 (14:06 -0300)]
misc: CountEpisodes and convenience conversion functions

10 years agomisc: Always simplify EpisodeLists
Diogo Franco (Kovensky) [Tue, 16 Jul 2013 17:05:42 +0000 (14:05 -0300)]
misc: Always simplify EpisodeLists

10 years agoanidb: Cache finished anime for longer
Diogo Franco (Kovensky) [Tue, 16 Jul 2013 17:05:13 +0000 (14:05 -0300)]
anidb: Cache finished anime for longer

Once they've finished airing, it's more unlikely they'll get updates. We
only consider they as finished if they were cached more than one
AnimeCacheDuration after the end though.

10 years agoanidb: Change retry timer factors
Diogo Franco (Kovensky) [Tue, 16 Jul 2013 17:03:32 +0000 (14:03 -0300)]
anidb: Change retry timer factors

Now gives a progression of 10s, 20s, 40s and 60s waits.

10 years agoanidb: Remove unused struct errorReply
Diogo Franco (Kovensky) [Tue, 16 Jul 2013 17:02:50 +0000 (14:02 -0300)]
anidb: Remove unused struct errorReply

10 years agoanidb: Delete params s and tag from retries
Diogo Franco (Kovensky) [Tue, 16 Jul 2013 17:02:35 +0000 (14:02 -0300)]
anidb: Delete params s and tag from retries

These get added by (*udpapi.AniDBUDP).SendRecv(); we don't want to show
them in the log.

10 years agoanidb: Handle UDP API 601 (server down)
Diogo Franco (Kovensky) [Tue, 16 Jul 2013 17:01:34 +0000 (14:01 -0300)]
anidb: Handle UDP API 601 (server down)

We treat it the same as a ban: wait 30 minutes before allowing any
packets through.

10 years agoanidb: Handle invalid AID HTTP API response
Diogo Franco (Kovensky) [Tue, 16 Jul 2013 17:00:26 +0000 (14:00 -0300)]
anidb: Handle invalid AID HTTP API response

10 years agoanidb: Support files with partial/multiple episodes
Diogo Franco (Kovensky) [Tue, 16 Jul 2013 17:00:02 +0000 (14:00 -0300)]
anidb: Support files with partial/multiple episodes

Correct the parsing of OtherEpisodes, rename to RelatedEpisodes. Remove
old debug logging.

10 years agoanidb: Support FilesByGroup/FilesByGID
Diogo Franco (Kovensky) [Tue, 16 Jul 2013 16:57:49 +0000 (13:57 -0300)]
anidb: Support FilesByGroup/FilesByGID

Takes an Episode, for its recorded AID and episode number data.
Also includes helper method FIDsByGID.

10 years agomisc: Support partial episodes
Diogo Franco (Kovensky) [Tue, 16 Jul 2013 16:52:51 +0000 (13:52 -0300)]
misc: Support partial episodes

10 years agoanidb: Simplify (*AniDB).EpisodeByID()
Diogo Franco (Kovensky) [Tue, 16 Jul 2013 16:50:18 +0000 (13:50 -0300)]
anidb: Simplify (*AniDB).EpisodeByID()

Use (*Anime).EpisodeByEID() to search for the requested episode.

10 years agoanidb: Log HTTP API traffic
Diogo Franco (Kovensky) [Tue, 16 Jul 2013 16:48:23 +0000 (13:48 -0300)]
anidb: Log HTTP API traffic

10 years agoanidb: Log UDP traffic
Diogo Franco (Kovensky) [Tue, 16 Jul 2013 16:46:40 +0000 (13:46 -0300)]
anidb: Log UDP traffic

But only the first line of replies. ReAuth and Logout need special
handling since they don't use the sendQueue.

10 years agoudp, anidb: Lock shared data, return APIReply for authentication
Diogo Franco (Kovensky) [Tue, 16 Jul 2013 16:43:45 +0000 (13:43 -0300)]
udp, anidb: Lock shared data, return APIReply for authentication

Makes error reporting easier.

10 years agomisc: Add FormatLog method to Episode/EpisodeList/EpisodeRange
Diogo Franco (Kovensky) [Tue, 16 Jul 2013 16:34:16 +0000 (13:34 -0300)]
misc: Add FormatLog method to Episode/EpisodeList/EpisodeRange

EpisodeList.FormatLog takes an EpisodeCount instead of an int; and each
subrange is formatted according to the log of the count for its own
type.

10 years agoanidb: Refactor the intent map
Diogo Franco (Kovensky) [Tue, 16 Jul 2013 16:25:51 +0000 (13:25 -0300)]
anidb: Refactor the intent map

Allows notifications without closing the channels. All current users of
Notify were changed to NotifyClose.

10 years agoanidb: Add logging to titlecache, be more careful with caching
Diogo Franco (Kovensky) [Tue, 16 Jul 2013 16:20:22 +0000 (13:20 -0300)]
anidb: Add logging to titlecache, be more careful with caching

Only cache the new anime-titles.dat.gz (thus truncating an older one) if
we can download it entirely to memory (it's little less than 600KB).

10 years agoanidb: (*Anime).Episode(): be more helpful in the panic message
Diogo Franco (Kovensky) [Tue, 16 Jul 2013 16:18:19 +0000 (13:18 -0300)]
anidb: (*Anime).Episode(): be more helpful in the panic message

10 years agoanidb: Remove debug logging from cache
Diogo Franco (Kovensky) [Tue, 16 Jul 2013 16:17:28 +0000 (13:17 -0300)]
anidb: Remove debug logging from cache

10 years agoanidb: Immediately return error for clearly invalid IDs
Diogo Franco (Kovensky) [Tue, 16 Jul 2013 16:16:54 +0000 (13:16 -0300)]
anidb: Immediately return error for clearly invalid IDs

10 years agoanidb: Move EpisodeCount struct to misc
Diogo Franco (Kovensky) [Tue, 16 Jul 2013 16:02:26 +0000 (13:02 -0300)]
anidb: Move EpisodeCount struct to misc

10 years agoanidb: Add (*Anime).EpisodeByEID
Diogo Franco (Kovensky) [Tue, 16 Jul 2013 15:58:52 +0000 (12:58 -0300)]
anidb: Add (*Anime).EpisodeByEID

Also remove redundant type Episodes []*Episode -- the Episodes type
didn't have any methods.

10 years agohttp, udp: Remove debug logging
Diogo Franco (Kovensky) [Tue, 16 Jul 2013 15:39:12 +0000 (12:39 -0300)]
http, udp: Remove debug logging

Keep complaints about unknown resource types though, but mention that it
comes from the HTTP API.

10 years agoanidb: rename ed2kCache to fidCache
Diogo Franco (Kovensky) [Mon, 15 Jul 2013 15:41:55 +0000 (12:41 -0300)]
anidb: rename ed2kCache to fidCache

10 years agomisc: Fix Episode<->Episode comparison
Diogo Franco (Kovensky) [Mon, 15 Jul 2013 15:41:07 +0000 (12:41 -0300)]
misc: Fix Episode<->Episode comparison

10 years agoanidb: Change Episodes to be []*Episode
Diogo Franco (Kovensky) [Mon, 15 Jul 2013 13:40:03 +0000 (10:40 -0300)]
anidb: Change Episodes to be []*Episode

10 years agoanidb: Add missing loop 'break's to EpisodeByEID
Diogo Franco (Kovensky) [Mon, 15 Jul 2013 04:26:58 +0000 (01:26 -0300)]
anidb: Add missing loop 'break's to EpisodeByEID

Without the breaks, it's would be possible to query for an Anime
with AID 0, a clear waste of time.

Also move the 'ok = false' assignment closer to where it's documented.

10 years agoanidb: Always remove credentials on Logout()
Diogo Franco (Kovensky) [Mon, 15 Jul 2013 04:25:55 +0000 (01:25 -0300)]
anidb: Always remove credentials on Logout()

Even if they were never used.

10 years agoanidb: Document that credentials are needed for UDP queries
Diogo Franco (Kovensky) [Mon, 15 Jul 2013 04:25:32 +0000 (01:25 -0300)]
anidb: Document that credentials are needed for UDP queries

Commit messages aren't documentation :(

10 years agoanidb: Document which backend API is used on the Get* methods
Diogo Franco (Kovensky) [Mon, 15 Jul 2013 04:21:38 +0000 (01:21 -0300)]
anidb: Document which backend API is used on the Get* methods

Queries that depend on the UDP API can't be used without SetCredentials.

10 years agoanidb: Fix compilation
Diogo Franco (Kovensky) [Mon, 15 Jul 2013 04:11:53 +0000 (01:11 -0300)]
anidb: Fix compilation

10 years agoanidb: Check the HTTP API error as well for deleting invalid Anime
Diogo Franco (Kovensky) [Mon, 15 Jul 2013 04:09:51 +0000 (01:09 -0300)]
anidb: Check the HTTP API error as well for deleting invalid Anime

10 years agoanidb: Delete invalid cache data
Diogo Franco (Kovensky) [Mon, 15 Jul 2013 04:07:27 +0000 (01:07 -0300)]
anidb: Delete invalid cache data

If the API queries return errors specifically stating that requested
object doesn't exist, then delete the entry from the local cache.

10 years agoanidb: Return the previously available data if API refresh failed
Diogo Franco (Kovensky) [Mon, 15 Jul 2013 04:06:01 +0000 (01:06 -0300)]
anidb: Return the previously available data if API refresh failed

Makes the GetObjectByKey family of methods behave better if the API
is somehow unavailable.

10 years agoanidb: Simplify documentation
Diogo Franco (Kovensky) [Mon, 15 Jul 2013 04:03:41 +0000 (01:03 -0300)]
anidb: Simplify documentation

10 years agoanidb: Wait longer after each UDP API timeout
Diogo Franco (Kovensky) [Mon, 15 Jul 2013 03:27:04 +0000 (00:27 -0300)]
anidb: Wait longer after each UDP API timeout

Reset the wait after the first successful read.

10 years agoanidb: Implement GroupByName
Diogo Franco (Kovensky) [Mon, 15 Jul 2013 03:26:29 +0000 (00:26 -0300)]
anidb: Implement GroupByName

Also add the invalid key guard to GroupByID.

10 years agoanidb: fix ed2k caching
Diogo Franco (Kovensky) [Mon, 15 Jul 2013 03:22:20 +0000 (00:22 -0300)]
anidb: fix ed2k caching

Don't embed time.Time in the cache struct -- time.Time has its own
GobEncode and GobDecode methods, and we don't want them to be used.

10 years agoanidb: Fix cache_test.go compilation
Diogo Franco (Kovensky) [Mon, 15 Jul 2013 03:21:54 +0000 (00:21 -0300)]
anidb: Fix cache_test.go compilation

10 years agoanidb: Remove commented out code
Diogo Franco (Kovensky) [Sun, 14 Jul 2013 05:07:29 +0000 (02:07 -0300)]
anidb: Remove commented out code

10 years agoanidb: (*cacheDir).Get(): reduce the time a file lock is retained
Diogo Franco (Kovensky) [Sun, 14 Jul 2013 05:04:35 +0000 (02:04 -0300)]
anidb: (*cacheDir).Get(): reduce the time a file lock is retained

When reading from cache, read the entire file into a buffer before
attempting to decode; release the lock as soon as the read is done.

Also move the parameter sanity check to be earlier in the method.

10 years agoanidb: Fix compilation of flock_other
Diogo Franco (Kovensky) [Sun, 14 Jul 2013 04:54:46 +0000 (01:54 -0300)]
anidb: Fix compilation of flock_other

Also fixes inverted if test.

10 years agoanidb: Don't use a nil fileLock
Diogo Franco (Kovensky) [Sun, 14 Jul 2013 04:54:16 +0000 (01:54 -0300)]
anidb: Don't use a nil fileLock

10 years agoanidb: Update documentation
Diogo Franco (Kovensky) [Sun, 14 Jul 2013 15:42:42 +0000 (12:42 -0300)]
anidb: Update documentation

10 years agoanidb: panic if the default cache dir can't be set
Diogo Franco (Kovensky) [Sun, 14 Jul 2013 15:41:29 +0000 (12:41 -0300)]
anidb: panic if the default cache dir can't be set

Nothing works without a valid cache.

10 years agoanidb: Correct accidental docstring
Diogo Franco (Kovensky) [Sun, 14 Jul 2013 15:40:53 +0000 (12:40 -0300)]
anidb: Correct accidental docstring

10 years agoanidb: Support searching for multiple Episodes in an Anime
Diogo Franco (Kovensky) [Sun, 14 Jul 2013 23:20:41 +0000 (20:20 -0300)]
anidb: Support searching for multiple Episodes in an Anime

10 years agoanidb: Don't send UDP queries if we have no credentials
Diogo Franco (Kovensky) [Sun, 14 Jul 2013 23:19:51 +0000 (20:19 -0300)]
anidb: Don't send UDP queries if we have no credentials

We'd just get a 501 error and wouldn't be able to do anything about it.
Skip the middleman and return the 501 right away.

10 years agoanidb: New caching mechanism
Diogo Franco (Kovensky) [Sun, 14 Jul 2013 23:16:42 +0000 (20:16 -0300)]
anidb: New caching mechanism

Refactors the various parts of the code that interacted with the cache
to use the new cache. Moves the intent system to be decoupled from the
cache.

Caches requests made with invalid keys, avoids requerying the API for
InvalidKeyCacheDuration (1 hour).

Untested on !windows, since that uses a separate file locking mechanism.

10 years agoanidb: Make cached *File expire earlier if they're Incomplete
Diogo Franco (Kovensky) [Sun, 14 Jul 2013 18:03:46 +0000 (15:03 -0300)]
anidb: Make cached *File expire earlier if they're Incomplete

10 years agoanime: Make cached Anime expire earlier if they're Incomplete
Diogo Franco (Kovensky) [Sun, 14 Jul 2013 18:01:38 +0000 (15:01 -0300)]
anime: Make cached Anime expire earlier if they're Incomplete

10 years agoanime: Consistently name the *AniDB "adb" in *AniDB methods
Diogo Franco (Kovensky) [Sun, 14 Jul 2013 17:58:00 +0000 (14:58 -0300)]
anime: Consistently name the *AniDB "adb" in *AniDB methods

Makes the docs look better.

10 years agoanidb: Remove (*AniDB).ReAuth() method
Diogo Franco (Kovensky) [Sun, 14 Jul 2013 17:55:31 +0000 (14:55 -0300)]
anidb: Remove (*AniDB).ReAuth() method

10 years agotitles: Add module description comment
Diogo Franco (Kovensky) [Sun, 14 Jul 2013 17:52:40 +0000 (14:52 -0300)]
titles: Add module description comment

10 years agoanidb: rename SaveCurrentTitles to DumpTitles, convert to function
Diogo Franco (Kovensky) [Sun, 14 Jul 2013 17:49:47 +0000 (14:49 -0300)]
anidb: rename SaveCurrentTitles to DumpTitles, convert to function

It's part of the Dump family of functions, and doesn't actually need any
data from an AniDB struct.

10 years agoanidb: Initial attempt at high level AniDB library
Diogo Franco (Kovensky) [Sun, 14 Jul 2013 17:45:22 +0000 (14:45 -0300)]
anidb: Initial attempt at high level AniDB library

10 years agotitles: Check if the anime-titles database was loaded correctly
Diogo Franco (Kovensky) [Sun, 14 Jul 2013 17:44:47 +0000 (14:44 -0300)]
titles: Check if the anime-titles database was loaded correctly

10 years agotitles: Fix compilation of search_test
Diogo Franco (Kovensky) [Sun, 14 Jul 2013 17:44:08 +0000 (14:44 -0300)]
titles: Fix compilation of search_test

Forgotten commit.

10 years agotitles: LoadDB from an io.Reader instead of io.ReadCloser
Diogo Franco (Kovensky) [Sun, 14 Jul 2013 17:42:17 +0000 (14:42 -0300)]
titles: LoadDB from an io.Reader instead of io.ReadCloser

10 years agotitles: Correctly load anime-titles.dat for testing
Diogo Franco (Kovensky) [Sun, 14 Jul 2013 17:41:44 +0000 (14:41 -0300)]
titles: Correctly load anime-titles.dat for testing

10 years agoudpapi: Return pointers to reply structs
Diogo Franco (Kovensky) [Sun, 14 Jul 2013 17:38:24 +0000 (14:38 -0300)]
udpapi: Return pointers to reply structs

Keeps the reply structs convertible to APIReply. Also change the gob
registrations to use the pointer types.

10 years agoudpapi: Don't keep UDP API key in ecbState
Diogo Franco (Kovensky) [Sun, 14 Jul 2013 17:37:10 +0000 (14:37 -0300)]
udpapi: Don't keep UDP API key in ecbState

Also add test to check if ECB is indeed correctly implemented.

10 years agoudpapi: Handle encryption correctly
Diogo Franco (Kovensky) [Sun, 14 Jul 2013 17:34:21 +0000 (14:34 -0300)]
udpapi: Handle encryption correctly

Previously, the very first packet to be received after the ENCRYPT call
was not properly decrypted; the getPacket function was using the old
encryption state.

10 years agoudpapi: Avoid out-of-bounds access on malformed packets
Diogo Franco (Kovensky) [Sun, 14 Jul 2013 17:32:50 +0000 (14:32 -0300)]
udpapi: Avoid out-of-bounds access on malformed packets

Also reports the strconv.ParseInt error if it's not possible to decode
the reply's code.

10 years agohttpapi: Better support for Resources
Diogo Franco (Kovensky) [Sun, 14 Jul 2013 17:30:22 +0000 (14:30 -0300)]
httpapi: Better support for Resources

10 years agoudpapi: Register types with encoding/gob
Diogo Franco (Kovensky) [Sat, 13 Jul 2013 02:22:02 +0000 (23:22 -0300)]
udpapi: Register types with encoding/gob

10 years agoudpapi: Finish(?) partially-done refactor, fixes compilation
Diogo Franco (Kovensky) [Sat, 13 Jul 2013 02:12:55 +0000 (23:12 -0300)]
udpapi: Finish(?) partially-done refactor, fixes compilation

I didn't break the API with the previous commit :(

10 years agoudpapi: Server-side timeouts are unrelated to UDP timeouts
Diogo Franco (Kovensky) [Sat, 13 Jul 2013 02:03:50 +0000 (23:03 -0300)]
udpapi: Server-side timeouts are unrelated to UDP timeouts

Yay, first API breakage.

10 years agoudpapi: escape & as &amp; and \n as <br/>
Diogo Franco (Kovensky) [Sat, 13 Jul 2013 01:57:20 +0000 (22:57 -0300)]
udpapi: escape & as &amp; and \n as <br/>

10 years agomisc: refactor, add tests, add list simplification method
Diogo Franco (Kovensky) [Sat, 13 Jul 2013 01:56:39 +0000 (22:56 -0300)]
misc: refactor, add tests, add list simplification method

10 years agomisc: New module with common / useful code
Diogo Franco (Kovensky) [Fri, 12 Jul 2013 15:39:24 +0000 (12:39 -0300)]
misc: New module with common / useful code

10 years agotitles: Specify how the search string is split
Diogo Franco (Kovensky) [Fri, 12 Jul 2013 21:44:59 +0000 (18:44 -0300)]
titles: Specify how the search string is split

10 years agoudp: rename to udpapi, reformat AniDBUDP documentation
Diogo Franco (Kovensky) [Fri, 12 Jul 2013 21:20:00 +0000 (18:20 -0300)]
udp: rename to udpapi, reformat AniDBUDP documentation

10 years agotitles: Document
Diogo Franco (Kovensky) [Fri, 12 Jul 2013 21:15:44 +0000 (18:15 -0300)]
titles: Document

10 years agoInitial commit
Diogo Franco (Kovensky) [Fri, 12 Jul 2013 20:22:58 +0000 (17:22 -0300)]
Initial commit

For now, only includes low-level wrappers for AniDB's various APIs. The
current API is in no way frozen and may break at any time.

These are not intended for being used in third party code, but as building
blocks for a unified API library.

The HTTP wrapper does simple encoding/xml wrapping of the anime and categorylist
HTTP API calls. No caching is implemented.

The UDP wrapper does rate control internally and implements the essential
session-keeping API calls, but does no caching.