leanghok

anigarden devblog

i recently just hit 200 followers on x/twitter and i decided to code something to celebrate it. i settled on a tui anime viewer and called it anigarden. (chatgpt helped me decided)

what actually is anigarden?

anigarden is an open source tui hianime wrapper. you can use it to browse anime, add them to a minimal builtin watchlist, and watch anime. :O

little demo:

home page

watchlist page

the tech stack

i decided to build anigarden with go using the bubbletea framework with lipgloss. i got the anime data and episode streaming links from aniwatch api and hianime api. for the streaming functionality, i use mpv and megaplay.buzz. i also added a sqlite db for the watchlist feature.

why 2 apis?

you might be wondering why i need to use 2 anime apis, well, the first one is the primary api used for getting the anime listing, anime info, episodes, search results and the second api is used to get the episode streaming link to plug it into mpv.

but why not just use the first api to get the episode streaming link? well at first i did that but turns out the first api provides links and referer headers that when plugged into mpv returns a 403 error (forbidden). this happens because the streaming link provided by the first api is from a cdn that blocks all non-browser traffic.

stoopid bugs i encountered

the tui is actually pretty simple since it's just a wrapper on top of existing software and apis. the only bad part about coding it is that those apis are a pain to work with.

by now i should mention that the aniwatch api and the hianime api are both unofficial apis. they are just community made scrapers.

at first i was using only 1 anime api (aniwatch-api) and it was working well until one day, when i plug the episode streaming link provided by the api into mpv, it returned a 403 error. i tried to fix this by adding the Referer header to mpv but it still returned the 403 error. i spent like 2 days on this bug and decided to bring in another api (hianime-api) for the episode streaming link.

future plans

there are still stuff that i want to add to anigarden like using sakura to render the anime straight in the terminal without relying on the browser or mpv.

anigarden is still in a very early stage so there are some bugs but overall i'd say that it's usable.