-
Notifications
You must be signed in to change notification settings - Fork 3
Docs
Sakurajima is a python wrapper around the aniwatch.me API. Apart from providing access to the aniwatch API, Sakurajima has additional functionality like the ability to download episode in your selected quality.
Sakurajima requires you to have an aniwatch.me account beforehand. It needs your username, user ID and your authorization token to work. Checkout this wiki page for instructions on how to get these details.
Got the above details? Lets jump in. Start by importing Sakurajima into your file and passing in the required details.
Example:
from Sakurajima import Sakurajima
username = [YOUR_USERNAME]
userID = [YOUR_USERID]
authToken = [YOUR_AUTH_TOKEN]
client = Sakurajima(username, userID, authToken)
Every anime on aniwatch.me has an associated anime ID, this can be found by visiting the anime page and noticing the URL of the page. The number after the anime/
is the ID of the anime. The URLs follow the pattern https://aniwatch.me/anime/[ANIME_ID]
. Similarly. every episode on aniwatch also has an ID that can be used to uniquely identify that particular episode. Unfortunately, unlike anime ID, there is no way other than to dig into the network requests to find the episode ID.
Sakurajima has various methods to fetch data from the Aniwatch backend. For example you can get any particular anime by its ID by calling the get_anime()
method and passing in the anime ID.
Example:
my_anime = client.get_anime(54) # Here 54 is the ID for the anime 'Hunter x Hunter'
The get_anime()
method returns an Anime
object. An Anime
object has all the relevant data regarding a particular anime like its title, description, total number of episodes etc. Apart from these details, the Anime
object also has methods like get_episodes()
to get a list of available episodes for the anime.
You can also search for a specific anime using the search()
method and passing in a string as a query. The search()
method returns a list of Anime
objects that match your search query. Note that this method returns a list of animes whose titles match the string you passed in. The results of this search are identical to what you will get if you search the aniwatch website using their search option.
episodes = my_anime.get_episodes()
The get_episodes()
method returns an EpisodeList
object which is similar to a normal list except it is read only and has some convenience methods like get_episode_by_number()
episode = episodes.get_episode_by_number(3)
The above code will get the third episode from the list of episodes. Note that this will not get the third episode in the list, to do that you can just do episodes[2]
but rather this gets the third episode of the series regardless of what the order inside the list is.
The variable episode
is of type Episode
. An Episode
object has all the information regarding an episode like title, description, link to the thumbnail, whether it is a filler episode or not etc. Apart from these properties, an Episode
object also has the download()
method. As the name suggests, the download()
method will download a given episode. You need to specify the quality you want to download using the quality
argument. You can get the list of available qualities using the get_available_qualities()
method. You can also define the name of the downloaded file or the complete path to it using the file_name
argument.
print(episode.get_available_qualities())
Output : ['ld', 'sd', 'hd', 'fullhd']
The ld
, sd
, hd
and fullhd
stand for 360p
, 480p
, 720p
and 1080p
respectively.
episode.download("hd", file_name = "Hunter_ep_3")
The above code will download the third episode of "Hunter x Hunter" to a file called "Hunter_ep_3.ts".