|
|
|
@ -1,15 +1,19 @@
|
|
|
|
package org.koitharu.kotatsu.parsers.site.madara.pt
|
|
|
|
package org.koitharu.kotatsu.parsers.site.madara.pt
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import org.jsoup.nodes.Document
|
|
|
|
import org.koitharu.kotatsu.parsers.MangaLoaderContext
|
|
|
|
import org.koitharu.kotatsu.parsers.MangaLoaderContext
|
|
|
|
import org.koitharu.kotatsu.parsers.MangaSourceParser
|
|
|
|
import org.koitharu.kotatsu.parsers.MangaSourceParser
|
|
|
|
|
|
|
|
import org.koitharu.kotatsu.parsers.model.Manga
|
|
|
|
import org.koitharu.kotatsu.parsers.model.MangaChapter
|
|
|
|
import org.koitharu.kotatsu.parsers.model.MangaChapter
|
|
|
|
import org.koitharu.kotatsu.parsers.model.MangaPage
|
|
|
|
import org.koitharu.kotatsu.parsers.model.MangaPage
|
|
|
|
import org.koitharu.kotatsu.parsers.model.MangaParserSource
|
|
|
|
import org.koitharu.kotatsu.parsers.model.MangaParserSource
|
|
|
|
import org.koitharu.kotatsu.parsers.site.madara.MadaraParser
|
|
|
|
import org.koitharu.kotatsu.parsers.site.madara.MadaraParser
|
|
|
|
import org.koitharu.kotatsu.parsers.util.generateUid
|
|
|
|
import org.koitharu.kotatsu.parsers.util.generateUid
|
|
|
|
|
|
|
|
import org.koitharu.kotatsu.parsers.util.mapChapters
|
|
|
|
import org.koitharu.kotatsu.parsers.util.parseHtml
|
|
|
|
import org.koitharu.kotatsu.parsers.util.parseHtml
|
|
|
|
import org.koitharu.kotatsu.parsers.util.selectFirstOrThrow
|
|
|
|
import org.koitharu.kotatsu.parsers.util.selectFirstOrThrow
|
|
|
|
import org.koitharu.kotatsu.parsers.util.toAbsoluteUrl
|
|
|
|
import org.koitharu.kotatsu.parsers.util.toAbsoluteUrl
|
|
|
|
|
|
|
|
import org.koitharu.kotatsu.parsers.util.toRelativeUrl
|
|
|
|
|
|
|
|
|
|
|
|
@MangaSourceParser("MANHASTRO", "Manhastro", "pt")
|
|
|
|
@MangaSourceParser("MANHASTRO", "Manhastro", "pt")
|
|
|
|
internal class Manhastro(context: MangaLoaderContext) :
|
|
|
|
internal class Manhastro(context: MangaLoaderContext) :
|
|
|
|
@ -35,4 +39,42 @@ internal class Manhastro(context: MangaLoaderContext) :
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override suspend fun getChapters(manga: Manga, doc: Document): List<MangaChapter> {
|
|
|
|
|
|
|
|
val initialChapters = super.getChapters(manga, doc)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (initialChapters.isEmpty()) {
|
|
|
|
|
|
|
|
return initialChapters
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Use the URL of the first (latest) chapter to fetch the chapter page.
|
|
|
|
|
|
|
|
val firstChapterUrl = initialChapters.first().url.toAbsoluteUrl(domain)
|
|
|
|
|
|
|
|
val chapterPageDoc = webClient.httpGet(firstChapterUrl).parseHtml()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Select all <option> elements from the chapter selection dropdown.
|
|
|
|
|
|
|
|
val options = chapterPageDoc.select("select.single-chapter-select option")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (options.isNotEmpty()) {
|
|
|
|
|
|
|
|
// The dropdown list is newest-to-oldest
|
|
|
|
|
|
|
|
return options.mapChapters(reversed = true) { i, option ->
|
|
|
|
|
|
|
|
val href = option.attr("data-redirect").toRelativeUrl(domain)
|
|
|
|
|
|
|
|
val name = option.text().trim()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MangaChapter(
|
|
|
|
|
|
|
|
id = generateUid(href),
|
|
|
|
|
|
|
|
url = href,
|
|
|
|
|
|
|
|
title = name,
|
|
|
|
|
|
|
|
number = i + 1f,
|
|
|
|
|
|
|
|
volume = 0,
|
|
|
|
|
|
|
|
uploadDate = 0L, // Date is not available in the dropdown
|
|
|
|
|
|
|
|
source = source,
|
|
|
|
|
|
|
|
scanlator = null,
|
|
|
|
|
|
|
|
branch = null,
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// If the dropdown wasn't found for some reason, return the initial (short) list as a fallback.
|
|
|
|
|
|
|
|
return initialChapters
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|