Introducing a new way to review your PRs.

Read the announcement

keiyoushi / extensions-source

Source code of extensions in https://github.com/keiyoushi/extensions

View on GitHub

13 documents · Updated Nov 19, 2026

docs / multisrc-template-libraries

Multi-source template libraries

Overview

lib-multisrc/ contains reusable source implementations for families of site extensions. Each child directory is a Gradle multisrc library, with build.gradle.kts applying alias(kei.plugins.multisrc) and setting the template library's baseVersionCode, libVersion, and sometimes deeplink paths. Examples include lib-multisrc/…/build.gradle.kts, lib-multisrc/…/build.gradle.kts, lib-multisrc/…/build.gradle.kts, and lib-multisrc/…/build.gradle.kts.

The runtime entry points are abstract KeiSource subclasses under lib-multisrc/<template>/src/eu/kanade/tachiyomi/multisrc/<template>/. Concrete site extensions inherit these classes outside this library and customize behavior by overriding protected selectors, URL path pieces, request modes, filter options, parsing helpers, and feature flags. Template code performs the end-to-end Tachiyomi source operations: browse/popular/latest, search and filters, URL routing via getMangaByUrl, manga detail and chapter refresh via fetchMangaUpdate, page extraction via getPageList, and image request customization.

Most templates are single-CMS scrapers that talk directly to HTML pages, JSON APIs, GraphQL APIs, or browser-rendered surfaces. Shared state is stored in Tachiyomi models rather than repository-local storage: SManga.url, SChapter.url, and memo JSON are used to preserve IDs, paths, genre routes, or post IDs needed by later refreshes. Some templates also use source preferences through ConfigurableSource, such as adult-content toggles in lib-multisrc/…/FoolSlide.kt, premium chapter visibility in lib-multisrc/…/Pam.kt, dynamic URL mapping in lib-multisrc/…/MangaThemesiaAlt.kt, and ManhuaRM translation/font options in lib-multisrc/…/Manhuarm.kt.

How multisrc templates are structured

Each template directory follows the same broad shape:

Customization is intentionally override-oriented. The base class supplies default selectors and endpoints; a concrete source usually overrides only the mismatched pieces. Examples: lib-multisrc/…/MadaraBase.kt exposes chapterMode, mangaSubString, genreDirectory, selectors, status word lists, and processThumbnail; lib-multisrc/…/MangaThemesia.kt exposes mangaUrlDirectory, datePattern, search/detail selectors, filter options, project-page support, and sendViewCount; lib-multisrc/…/FMReader.kt exposes request paths, selectors, date parsing, image attributes, and genre lists.

Catalog of major templates and families

  • WordPress manga themes. lib-multisrc/madara/ is the largest Madara-family base. Madara.kt browses via wp-admin/admin-ajax.php action madara_load_more, builds WordPress tax/meta queries from filter state, and parses archive cards. MadaraBase.kt handles detail pages, post ID/path memoization, multiple chapter loading modes (MangaPage, AdminAjax, MangaAjax, MangaAjaxPaginated, MangaAjaxQuery), related manga, image extraction, view count posting, and #chapter-protector-data AES/CBC page decryption. lib-multisrc/mangathemesia/ covers MangaThemesia/WPMangaStream/WPMangaReader-style themes: MangaThemesia.kt maps /manga search filters into query parameters, parses details/chapters from theme selectors, posts dynamic view counts, and falls back from inline images to JavaScript image-list JSON; MangaThemesiaAlt.kt adds cached random-slug-to-permanent-slug mapping; MangaThemesiaPaidChapterHelper.kt filters locked chapters by selector. Other WordPress-derived families are split into their own smaller templates, including wpcomics, oceanwp, vinetheme, zeistmanga, yiimadara, zmanga, and manhuarm.
  • Reader/CMS HTML scrapers. lib-multisrc/fmreader/ targets Flat-Manga CMS sites. FMReader.kt sends Firefox-like headers, uses manga-list.html pagination, supports text/genre/status/sort URL parameters, parses details from .manga-info, handles multilingual status/date words, and can decode base64 image attributes. lib-multisrc/…/FoolSlide.kt targets FoolSlide: directory/latest/search pages, adult POST headers via an OkHttp interceptor, chapter dates with relative and ordinal formats, and page lists from var pages = .... lib-multisrc/…/MMRCMS.kt handles MMRCMS HTML flows with /filterList, optional /advanced-search POSTs, token extraction, detail/chapter parsing from the same page, and filter fetching. lib-multisrc/…/MangaReader.kt targets MangaReader-style sites: popular/latest are search requests with sort filters, details come from #ani_detail, chapters store reading IDs in URL fragments, and pages are loaded from /ajax/image/list/<id>?mode=vertical.
  • Chinese/mobile API CMS families. lib-multisrc/…/MCCMS.kt uses /api/data/comic, /api/data/chapter, and /api/comic/chapter endpoints; it keeps the API manga ID in the thumbnail URL fragment for later chapter requests and delegates page parsing to MCCMSConfig.kt. lib-multisrc/…/MCCMSWeb.kt is the web/mobile variant, using /category/..., /search/..., mobile URLs, captcha placeholder manga for #code-div, and the same config parser. lib-multisrc/mmlook/, mangak/, sinmh/, and dm5/ are related source-specific Chinese reader bases with DTOs, filters, and page decryption helpers under their own directories.
  • GraphQL/API-first families. lib-multisrc/…/MangaHub.kt authenticates GraphQL calls with an mhub_access key, refreshes that key from chapter pages on API errors, fetches search/detail/chapter/page data through query helpers, decrypts enc:v1 page payloads via AES/GCM after fetching /api/chapter-crypto, and writes a recently cookie to mirror browser behavior. lib-multisrc/…/Senkuro.kt posts GraphQL requests with fixed app headers, builds include/exclude filter variables, and has supportsLatest = false. lib-multisrc/…/MonochromeCMS.kt calls an api. host for manga, chapter, and media URLs using DTOs from MonochromeAPI.kt.
  • Browser-rendered or image-processing templates. lib-multisrc/…/Pam.kt drives a site view with bundled JavaScript assets to scrape library and series pages, taps/swipes through paged chapter lists, captures page and cover images into cache files, and serves those files through URL fragments handled by pageInterceptor. lib-multisrc/…/Manhuarm.kt is a WordPress/Madara-like reader with translation overlays: it configures translation and composed-image interceptors, fetches OCR dialogue data either from _0xvault credentials or a WebView-executed JavaScript challenge, stores dialogue JSON in page URL fragments, and exposes preferences for translator provider, fonts, scaling, and custom user agent.
  • Smaller site-family templates. Directories such as aurora, bakkin, catharsis, colorlibanime, comiciviewer, crunchyscanst, duckscans, ezmanhwa, fansubscat, goda, greenshit, grouple, guya, heancms, hwalumi, iken, imperiomanhwa, initmanga, inkstory, keyoapp, koi, komiko, libgroup, liliana, loneseal, manga18, mangabox, mangacatalog, mangadventure, mangak, mangataro, mangawork, mangaworld, manhwaz, masonry, natsuid, origines, oyst, pizzareader, scanreader, uzaymanga, vercomics, yiimanga, and others follow the same abstract-source pattern but are narrower families with fewer helper files.

Extension-generation and customization patterns

  • Treat build.gradle.kts versions as template-wide compatibility signals. Updating parsing behavior in lib-multisrc/…/MadaraBase.kt or lib-multisrc/…/MangaThemesia.kt affects every generated extension inheriting that library, so the corresponding baseVersionCode/libVersion in the template's build.gradle.kts is the release coordination point.
  • Preserve persisted identifier contracts. MadaraBase.kt may store SManga.url as a numeric post ID while placing the canonical path and genres in SManga.memo; MangaThemesia.kt stores postId in memo; MangaReader.kt appends chapter IDs after #; MCCMSDto.kt stores API IDs after thumbnail_url#; Pam.kt uses URL fragments pam-cover and pam-page-<index> to route generated images. Changing these contracts requires migration or refresh handling because existing library entries and chapters may have old URLs/memos.
  • Keep selector overrides local. If only one family member differs, override protected selectors/paths in the concrete extension rather than broadening the base selector in files like FMReader.kt, MMRCMS.kt, or MangaThemesia.kt; broad selectors can silently change parsing for every inheritor.
  • Match request type to endpoint behavior. Templates use Fetch.DOCUMENT, Fetch.XHR, referer headers, custom user agents, POST forms, cookies, and rate limits in base code. For example MangaHub.kt requires GraphQL XHR headers plus key refresh, FoolSlide.kt rewrites requests with an Adult marker header, MCCMS.kt strips image referers, and Manhuarm.kt forces network fetches for single-use OCR credentials.
  • Filter fetching is part of the template contract. Madara and MangaThemesia fetch genre/filter data from source pages (fetchFilterData), MangaHub and Senkuro fetch API filter data, and MMRCMS/MCCMS parse filter pages. If a filter DTO or parser changes, verify both fetchFilterData and getFilterList in the same template directory.

Path-routable coverage notes

  • lib-multisrc/…/build.gradle.kts: multisrc registration, template versioning, deeplink paths, and shared dependencies.
  • lib-multisrc/madara/**: Madara/WordPress manga source base, filters, i18n, post-ID/path memoization, chapter modes, related manga, page decryption, and view-count side effects.
  • lib-multisrc/mangathemesia/**: MangaThemesia/WPMangaStream/WPMangaReader base, dynamic URL helper, paid chapter helper, i18n, search/detail/chapter/page selectors, and view-count side effects.
  • lib-multisrc/fmreader/**, lib-multisrc/foolslide/**, lib-multisrc/mangareader/**, lib-multisrc/mmrcms/**: reusable HTML reader/CMS parsers with local filters, DTOs, date/image utilities, and AJAX/page extraction behavior.
  • lib-multisrc/mccms/**: MCCMS API and web variants, shared config/parser utilities, DTOs, filters, mobile URL handling, and page-list strategy.
  • lib-multisrc/mangahub/**, lib-multisrc/senkuro/**, lib-multisrc/monochrome/**: API/GraphQL-first templates, DTO/query files, authentication/key handling, and page URL/decryption logic.
  • lib-multisrc/pam/**: WebView-driven scraping and capture assets (assets/*.js), site-driving helpers, cached cover/page capture, filters, DTOs, and i18n.
  • lib-multisrc/manhuarm/**: translation overlay source, interceptors, translator engines, OCR dialogue DTOs, language settings, filters, and i18n.
  • Other lib-multisrc/<family>/** directories are routable to this doc as smaller multisrc templates; inspect the directory-local abstract source plus adjacent Filters.kt, Dto.kt, assets, and resources for that family.

Coupling

  • If any template changes how it stores SManga.url, SChapter.url, or memo, verify all methods in that same template that later consume the value. Examples: MadaraBase.kt couples parseDetails, archiveManga, fetchMangaUpdate, getMangaUrl, and getChapterUrl; MangaReader.kt couples chapterFromElement, getChapterId, getPageList, and getChapterUrl; MCCMS.kt couples MangaDto.toSManga() in MCCMSDto.kt with fetchChapterList() through the thumbnail URL fragment.
  • If bundled assets change under lib-multisrc/pam/assets/, verify the DTOs and drive loops in Pam.kt, SiteView.kt, ChapterCapture.kt, and Covers.kt; the Kotlin code parses the JavaScript result payloads directly and serves generated files through intercepted OkHttp image requests.
  • If i18n keys change under assets/i18n/messages_*.properties, verify every Intl[...] lookup in the same template source. Template code such as MadaraBase.kt, MangaThemesia.kt, Pam.kt, and Manhuarm.kt builds filter labels, descriptions, and preferences directly from those keys.
  • If request headers, cookies, rate limits, or interceptors change, verify page/image loading as well as metadata loading. MangaHub.kt key refresh affects GraphQL search, details, and page decryption; Manhuarm.kt interceptors affect both translated overlays and composed image responses; FoolSlide.kt adult request rewriting affects details, chapters, and pages.

Risks

  • lib-multisrc/…/MangaThemesiaPaidChapterHelper.kt builds a derived selector by splitting baseChapterListSelector on the exact string ", "; if a caller supplies comma-separated selectors without that spacing, paid chapter filtering can fail or filter the wrong elements.
  • lib-multisrc/…/Pam.kt serves pages and covers only through cache files created by WebView captures. If pageInterceptor misses the pam-cover or pam-page- fragments, image loading falls through to the network URL and the generated page images break.
  • lib-multisrc/…/Manhuarm.kt depends on single-use OCR credentials from chapter pages and intentionally uses CacheControl.FORCE_NETWORK; if chapter HTML is cached or a WebView challenge is retried incorrectly, translation overlays can silently disappear while base page images still load.
  • lib-multisrc/…/MangaHub.kt relies on mhub_access key refresh from chapter pages and AES/GCM page decryption. If the API error regex, cookie handling, or /api/chapter-crypto contract drifts, search/details may recover with a random key but encrypted chapters can still fail.