Installation and Usage
This document covers how to integrate the Kotatsu Parsers library into your project and the basic patterns for using it. For information about the core architecture and available parsers, see Core Architecture.
Library Overview
Kotatsu Parsers is a JVM library that provides a collection of manga parsers for accessing web-based manga content. It supports both standard JVM applications and Android projects.
Installation
Adding the Repository
First, add JitPack repository to your root build.gradle
file:
Adding the Dependency
For Java/Kotlin Projects
For Android Projects
For Android projects, exclude the org.json:json
module to avoid conflicts with Android's built-in JSON library:
dependencies {
implementation("com.github.KotatsuApp:kotatsu-parsers:$parsers_version") {
exclude group: 'org.json', module: 'json'
}
}
Note
When used in Android projects, core library desugaring with the NIO specification should be enabled to support Java 8+ features.
Dependencies
The library includes the following key dependencies:
Dependency | Version | Purpose |
---|---|---|
kotlinx-coroutines-core | 1.10.2 | Asynchronous programming |
okhttp3 | 4.12.0 | HTTP client |
jsoup | 1.19.1 | HTML parsing |
org.json | 20240303 | JSON parsing |
Basic Usage
Implementing MangaLoaderContext
Before using any parsers, you need to implement the MangaLoaderContext
interface, which provides the necessary context for parsers to function.
The implementation differs between Android and non-Android projects. Examples of implementations can be found in:
Creating a Parser Instance
Once you have implemented MangaLoaderContext
, you can create parser instances:
Where MangaParserSource
is an enumeration of all available manga sources.
Warning
MangaParserSource.DUMMY
parser cannot be instantiated.
Key Operations
The main operations available through parsers are:
- Getting manga list:
getList(query, offset, order, filter)
- Retrieves a list of manga with pagination - Getting manga details:
getDetails(manga)
- Fetches detailed information about a manga, including chapters - Getting chapter pages:
getPages(chapter)
- Retrieves a list of pages for a specific chapter - Getting page images:
getPageUrl(page)
- Gets the direct URL to an image
Projects Using the Library
Several projects are already using the Kotatsu Parsers library:
- Kotatsu - Android manga reader application
- kotatsu-dl - Command-line manga downloader
- Shirizu - Work in progress manga reader
- OtakuWorld - Manga and anime app
These projects can serve as examples of how to integrate and use the library in your own applications.