The ctx.manga API provides methods to interact with the manga system in Seanime.
Core Methods
getProviders
Gets all provider extensions
const providers = ctx.manga.getProviders()
for (const providerId in providers) {
console.log("ID:", providerId, "Name:", providers[providerId])
}
getChapterContainer
Gets a chapter container for a specific manga, using the cache if available.
Parameters:
opts: Object containing:
mediaId: Number - The AniList media ID
provider: String - The manga provider identifier
titles: String[] (Optional) - Alternative titles to help find the manga
year: Number (Optional) - Release year to help with identification
Example:
// Get chapter container for a manga from MangaDex
const mangaContainer = await ctx.manga.getChapterContainer({
mediaId: 000000,
provider: "mangadex",
titles: ["Kimetsu no Yaiba", "Demon Slayer"],
year: 2016
})
if (mangaContainer) {
console.log(`Found ${mangaContainer.chapters.length} chapters from ${mangaContainer.provider}`)
// Process chapters
for (const chapter of mangaContainer.chapters) {
console.log(`Chapter ${chapter.chapter}: ${chapter.title}`)
}
}
getDownloadedChapters
Retrieves all downloaded manga chapters grouped by provider and manga ID.
Example:
// Get all downloaded chapters
const downloadedChapters = await ctx.manga.getDownloadedChapters()
// Count chapters per manga
const chaptersByManga = {}
for (const container of downloadedChapters) {
if (!chaptersByManga[container.mediaId]) {
chaptersByManga[container.mediaId] = 0
}
chaptersByManga[container.mediaId] += container.chapters.length
}
console.log("Downloaded chapters by manga:", chaptersByManga)
getCollection
Retrieves the user's manga collection with all media list data.
Example:
// Get the user's manga collection
const mangaCollection = await ctx.manga.getCollection()
// Process each list in the collection
for (const list of mangaCollection.lists) {
console.log(`List ${list.status}: ${list.entries.length} entries`)
// Process each manga in the list
for (const entry of list.entries) {
const manga = entry.media
const progress = entry.listData?.progress || 0
console.log(`${manga.title.userPreferred}: ${progress}/${manga.chapters || '?'} chapters read`)
}
}
refreshChapters
Deletes all cached chapters and refetches them based on the selected provider for each manga.
Parameters:
selectedProviderMap: Record<number, string> - A map of manga IDs to provider IDs
Example:
// Refresh chapters for specific manga using selected providers
const providerSelections = {
30013: "mangadex",
21: "mangasee",
31706: "manganato"
}
// Refresh all chapters based on these provider preferences
await ctx.manga.refreshChapters(providerSelections)
console.log("Chapter data refreshed for selected manga")
emptyCache
Empties cached chapters for a specific manga.
Parameters:
mediaId: Number - The AniList media ID
Example:
// Clear cached chapters for a manga (e.g., after a major update)
await ctx.manga.emptyCache(30013)
console.log("Cache cleared for Demon Slayer")
// Refetch immediately to get fresh data
const freshData = await ctx.manga.getChapterContainer({
mediaId: 30013,
provider: "mangadex"
})