AnimeHttpSource

A simple implementation for sources from a website. Usually requires the usage of json serialization or similar techniques.

Inheritors

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard
abstract val baseUrl: String

Base url of the website without the trailing slash, like: http://mysite.com

Link copied to clipboard

Default network client for doing requests. Implementations can override this property for custom OkHttpClient instances.

Link copied to clipboard

Headers used for requests. Result of headersBuilder

Link copied to clipboard
open override val id: Long

ID of the source. By default it uses a generated id using the first 16 characters (64 bits) of the MD5 of the string "${name.lowercase()}/$lang/$versionId".

Link copied to clipboard
abstract val lang: String

An ISO 639-1 compliant language code (two letters in lower case).

Link copied to clipboard
abstract val name: String

Name of the source.

Link copied to clipboard
protected val network: NetworkHelper

Network service.

Link copied to clipboard
abstract val supportsLatest: Boolean

Whether the source has support for latest updates.

Link copied to clipboard
open val versionId: Int

Version id used to generate the source id. If the site completely changes and urls are incompatible, you may increase this value and it'll be considered as a new source.

Functions

Link copied to clipboard
protected abstract fun animeDetailsParse(response: Response): SAnime

Parses the response from the site and returns the details of a anime.

Link copied to clipboard

Returns the request for the details of a anime. Override only if it's needed to change the url, send different headers or request method like POST.

Link copied to clipboard
protected abstract fun episodeListParse(response: Response): List<SEpisode>

Parses the response from the site and returns a list of episodes.

Link copied to clipboard
protected open fun episodeListRequest(anime: SAnime): Request

Returns the request for updating the episode list. Override only if it's needed to override the url, send different headers or request method like POST.

Link copied to clipboard
open override fun fetchAnimeDetails(anime: SAnime): Observable<SAnime>
Link copied to clipboard
open override fun fetchEpisodeList(anime: SAnime): Observable<List<SEpisode>>
Link copied to clipboard
open override fun fetchLatestUpdates(page: Int): Observable<AnimesPage>

Returns an observable containing a page with a list of latest anime updates.

Link copied to clipboard
open override fun fetchPopularAnime(page: Int): Observable<AnimesPage>

Returns an observable containing a page with a list of anime. Normally it's not needed to override this method.

Link copied to clipboard
open override fun fetchSearchAnime(page: Int, query: String, filters: AnimeFilterList): Observable<AnimesPage>

Returns an observable containing a page with a list of anime. Normally it's not needed to override this method, but can be useful to change the usual workflow and use functions with different signatures from searchAnimeRequest or searchAnimeParse.

Link copied to clipboard
open override fun fetchVideoList(episode: SEpisode): Observable<List<Video>>
Link copied to clipboard
Link copied to clipboard
protected fun generateId(name: String, lang: String, versionId: Int): Long

Generates a unique ID for the source based on the provided name, lang and versionId. It will use the first 16 characters (64 bits) of the MD5 of the string "${name.lowercase()}/$lang/$versionId".

Link copied to clipboard
open suspend override fun getAnimeDetails(anime: SAnime): SAnime

Get the updated details for a anime. Normally it's not needed to override this method.

Link copied to clipboard
open fun getAnimeUrl(anime: SAnime): String

Returns the url of the provided anime. Useful to fix "open in webview" without overriding getAnimeDetails.

Link copied to clipboard
open suspend override fun getEpisodeList(anime: SAnime): List<SEpisode>

Get all the available episodes for an anime. Normally it's not needed to override this method.

Link copied to clipboard
open fun getEpisodeUrl(episode: SEpisode): String

Returns the url of the provided episode.

Link copied to clipboard
open override fun getFilterList(): AnimeFilterList

Returns the list of filters for the source.

Link copied to clipboard
open suspend fun getLatestUpdates(page: Int): AnimesPage

Get a page with a list of latest anime updates.

Link copied to clipboard
open suspend fun getPopularAnime(page: Int): AnimesPage

Get a page with a list of anime.

Link copied to clipboard
open suspend fun getSearchAnime(page: Int, query: String, filters: AnimeFilterList): AnimesPage

Get a page with a list of anime.

Link copied to clipboard
open suspend override fun getVideoList(episode: SEpisode): List<Video>

Get the list of videos a episode has. Videos should be returned in the expected order; the index is ignored.

Link copied to clipboard
protected open fun headersBuilder(): Headers.Builder

Headers builder for requests. Implementations can override this method for custom headers.

Link copied to clipboard
protected abstract fun latestUpdatesParse(response: Response): AnimesPage

Parses the response from the site and returns a AnimesPage object.

Link copied to clipboard
protected abstract fun latestUpdatesRequest(page: Int): Request

Returns the request for latest anime given the page.

Link copied to clipboard
protected abstract fun popularAnimeParse(response: Response): AnimesPage

Parses the response from the site and returns a AnimesPage object.

Link copied to clipboard
protected abstract fun popularAnimeRequest(page: Int): Request

Returns the request for the popular anime given the page.

Link copied to clipboard
open fun prepareNewEpisode(episode: SEpisode, anime: SAnime)

Called before inserting a new episode into database. Use it if you need to override episode fields, like the title or the episode number. Do not change anything to anime.

Link copied to clipboard
protected abstract fun searchAnimeParse(response: Response): AnimesPage

Parses the response from the site and returns a AnimesPage object.

Link copied to clipboard
protected abstract fun searchAnimeRequest(page: Int, query: String, filters: AnimeFilterList): Request

Returns the request for the search anime given the page and filters.

Link copied to clipboard

Assigns the url of the anime without the scheme and domain. It saves some redundancy from database and the urls could still work after a domain change.

Assigns the url of the episode without the scheme and domain. It saves some redundancy from database and the urls could still work after a domain change.

Link copied to clipboard
protected open fun List<Video>.sort(): List<Video>

Sorts the video list. Override this according to the user's preference.

Link copied to clipboard
open override fun toString(): String

Visible name of the source.

Link copied to clipboard
protected open fun videoListParse(response: Response): List<Video>

Parses the response from the site and returns a list of videos.

Link copied to clipboard
protected open fun videoListRequest(episode: SEpisode): Request

Returns the request for getting the video list. Override only if it's needed to override the url, send different headers or request method like POST.

Link copied to clipboard
protected open fun videoUrlParse(response: Response): String
Link copied to clipboard
protected open fun videoUrlRequest(video: Video): Request

Returns the request for getting the url to the source video. Override only if it's needed to override the url, send different headers or request method like POST.