fix japanread source (#15361)
* Creation/modification of the japanread source which became bentomanga I left the name and the image because it's the same source with a new interface and name (people know japanread) * rename and udpate lib of the japanread source which became bentomanga + update of build.gradle * add old id of japanread * Update src/fr/japanread/build.gradle Co-authored-by: Alessandro Jean <14254807+alessandrojean@users.noreply.github.com> * Update src/fr/japanread/build.gradle Co-authored-by: Alessandro Jean <14254807+alessandrojean@users.noreply.github.com> * Update src/fr/japanread/src/eu/kanade/tachiyomi/extension/fr/japanread/bentomanga.kt Co-authored-by: Alessandro Jean <14254807+alessandrojean@users.noreply.github.com> * Update src/fr/japanread/src/eu/kanade/tachiyomi/extension/fr/japanread/bentomanga.kt Co-authored-by: Alessandro Jean <14254807+alessandrojean@users.noreply.github.com> * renaming file to BentoManga --------- Co-authored-by: Alessandro Jean <14254807+alessandrojean@users.noreply.github.com>
This commit is contained in:
parent
8eac6fbfec
commit
d72a9eedf4
|
@ -3,10 +3,10 @@ apply plugin: 'kotlin-android'
|
||||||
apply plugin: 'kotlinx-serialization'
|
apply plugin: 'kotlinx-serialization'
|
||||||
|
|
||||||
ext {
|
ext {
|
||||||
extName = 'Japanread'
|
extName = 'Bento Manga'
|
||||||
pkgNameSuffix = 'fr.japanread'
|
pkgNameSuffix = 'fr.japanread'
|
||||||
extClass = '.Japanread'
|
extClass = '.BentoManga'
|
||||||
extVersionCode = 10
|
extVersionCode = 11
|
||||||
isNsfw = true
|
isNsfw = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,11 +24,13 @@ import rx.Observable
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
import java.util.Calendar
|
import java.util.Calendar
|
||||||
|
|
||||||
class Japanread : ParsedHttpSource() {
|
class BentoManga : ParsedHttpSource() {
|
||||||
|
|
||||||
override val name = "Japanread"
|
override val name = "Bento Manga"
|
||||||
|
|
||||||
override val baseUrl = "https://www.japanread.cc"
|
override val id: Long = 4697148576707003393
|
||||||
|
|
||||||
|
override val baseUrl = "https://www.bentomanga.com"
|
||||||
|
|
||||||
override val lang = "fr"
|
override val lang = "fr"
|
||||||
|
|
||||||
|
@ -44,18 +46,20 @@ class Japanread : ParsedHttpSource() {
|
||||||
// Generic (used by popular/latest/search)
|
// Generic (used by popular/latest/search)
|
||||||
private fun mangaListFromElement(element: Element): SManga {
|
private fun mangaListFromElement(element: Element): SManga {
|
||||||
return SManga.create().apply {
|
return SManga.create().apply {
|
||||||
title = element.select("img").attr("alt")
|
title = element.select("a.component-manga-cover span.div-manga_cover-title")
|
||||||
setUrlWithoutDomain(element.select("a").attr("abs:href"))
|
.text()
|
||||||
thumbnail_url = element.select("img").attr("src").replace("manga_medium", "manga_large")
|
setUrlWithoutDomain(element.select("a").attr("href"))
|
||||||
|
thumbnail_url = element.select("a.component-manga-cover img ")
|
||||||
|
.attr("src")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun mangaListSelector() = "div#manga-container div.col-lg-6"
|
private fun mangaListSelector() = "div#mangas_content div.div-manga div.div-manga_cover"
|
||||||
private fun mangaListNextPageSelector() = "a[rel=next]"
|
private fun mangaListNextPageSelector() = ".paginator button:contains(>)"
|
||||||
|
|
||||||
// Popular
|
// Popular
|
||||||
override fun popularMangaRequest(page: Int): Request {
|
override fun popularMangaRequest(page: Int): Request {
|
||||||
return GET("$baseUrl/manga-list?sortType=9&page=$page", headers)
|
return GET("$baseUrl/manga_list?withoutTypes=5&order_by=views&limit=" + (page - 1), headers)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun popularMangaSelector() = mangaListSelector()
|
override fun popularMangaSelector() = mangaListSelector()
|
||||||
|
@ -64,7 +68,7 @@ class Japanread : ParsedHttpSource() {
|
||||||
|
|
||||||
// Latest
|
// Latest
|
||||||
override fun latestUpdatesRequest(page: Int): Request {
|
override fun latestUpdatesRequest(page: Int): Request {
|
||||||
return GET("$baseUrl/manga-list?sortType=0&page=$page", headers)
|
return GET("$baseUrl/manga_list?withoutTypes=5&limit=" + (page - 1), headers)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun latestUpdatesSelector() = mangaListSelector()
|
override fun latestUpdatesSelector() = mangaListSelector()
|
||||||
|
@ -75,11 +79,11 @@ class Japanread : ParsedHttpSource() {
|
||||||
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
|
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
|
||||||
// If there is any search text, use text search, otherwise use filter search
|
// If there is any search text, use text search, otherwise use filter search
|
||||||
val uri = if (query.isNotBlank()) {
|
val uri = if (query.isNotBlank()) {
|
||||||
Uri.parse("$baseUrl/search")
|
Uri.parse("$baseUrl/manga_list?withoutTypes=5")
|
||||||
.buildUpon()
|
.buildUpon()
|
||||||
.appendQueryParameter("q", query)
|
.appendQueryParameter("search", query)
|
||||||
} else {
|
} else {
|
||||||
val uri = Uri.parse("$baseUrl/manga-list").buildUpon()
|
val uri = Uri.parse("$baseUrl/manga_list?withoutTypes=5").buildUpon()
|
||||||
// Append uri filters
|
// Append uri filters
|
||||||
filters.forEach {
|
filters.forEach {
|
||||||
if (it is UriFilter) {
|
if (it is UriFilter) {
|
||||||
|
@ -89,7 +93,7 @@ class Japanread : ParsedHttpSource() {
|
||||||
uri
|
uri
|
||||||
}
|
}
|
||||||
// Append page number
|
// Append page number
|
||||||
uri.appendQueryParameter("page", page.toString())
|
uri.appendQueryParameter("limit", (page - 1).toString())
|
||||||
return GET(uri.toString())
|
return GET(uri.toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,20 +102,27 @@ class Japanread : ParsedHttpSource() {
|
||||||
override fun searchMangaNextPageSelector() = mangaListNextPageSelector()
|
override fun searchMangaNextPageSelector() = mangaListNextPageSelector()
|
||||||
|
|
||||||
// Details
|
// Details
|
||||||
|
|
||||||
override fun mangaDetailsParse(document: Document): SManga {
|
override fun mangaDetailsParse(document: Document): SManga {
|
||||||
return SManga.create().apply {
|
return SManga.create().apply {
|
||||||
title = document.select("h1.card-header").text()
|
title = document.select("div.manga div.manga-infos div.component-manga-title div.component-manga-title_main h1 ")
|
||||||
artist = document.select("div.col-lg-3:contains(Artiste) + div").text()
|
.text()
|
||||||
author = document.select("div.col-lg-3:contains(Auteur) + div").text()
|
artist = document.select("div.datas div.datas_more-artists div.datas_more-artists-people a").text()
|
||||||
description = document.select("div.col-lg-3:contains(Description) + div").text()
|
author = document.select("div.datas div.datas_more-authors div.datas_more-authors-peoples div a").text()
|
||||||
genre = document.select("div.col-lg-3:contains(Type - Catégories) + div .badge").joinToString { it.text() }
|
description = document.select("div.datas div.datas_synopsis").text()
|
||||||
status = document.select("div.col-lg-3:contains(Statut) + div").text().let {
|
genre = document.select("div.manga div.manga-infos div.component-manga-categories a")
|
||||||
|
.joinToString(" , ") { it.text() }
|
||||||
|
status = document.select("div.datas div.datas_more div.datas_more-status div.datas_more-status-data")?.first()?.text()?.let {
|
||||||
when {
|
when {
|
||||||
it.contains("En cours") -> SManga.ONGOING
|
it.contains("En cours") -> SManga.ONGOING
|
||||||
it.contains("Terminé") -> SManga.COMPLETED
|
it.contains("Terminé") -> SManga.COMPLETED
|
||||||
|
it.contains("En pause") -> SManga.ON_HIATUS
|
||||||
|
it.contains("Licencié") -> SManga.LICENSED
|
||||||
|
it.contains("Abandonné") -> SManga.CANCELLED
|
||||||
else -> SManga.UNKNOWN
|
else -> SManga.UNKNOWN
|
||||||
}
|
}
|
||||||
}
|
} ?: SManga.UNKNOWN
|
||||||
|
|
||||||
thumbnail_url = document.select("img[alt=couverture manga]").attr("src")
|
thumbnail_url = document.select("img[alt=couverture manga]").attr("src")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -144,22 +155,22 @@ class Japanread : ParsedHttpSource() {
|
||||||
return calendar.timeInMillis
|
return calendar.timeInMillis
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun chapterListSelector() = "#chapters div[data-row=chapter]"
|
override fun chapterListSelector() = "div.page_content div.chapters_content div.div-item"
|
||||||
|
|
||||||
override fun chapterFromElement(element: Element): SChapter {
|
override fun chapterFromElement(element: Element): SChapter {
|
||||||
return SChapter.create().apply {
|
return SChapter.create().apply {
|
||||||
name = element.select("div.col-lg-5 a").text()
|
name = element.select("div.component-chapter-title a span.chapter_volume").text()
|
||||||
setUrlWithoutDomain(element.select("div.col-lg-5 a").attr("href"))
|
setUrlWithoutDomain(element.select("div.component-chapter-title a").attr("href"))
|
||||||
date_upload = parseRelativeDate(element.select("div.order-lg-8").text())
|
date_upload = parseRelativeDate(element.select("div.component-chapter-date").text())
|
||||||
scanlator = element.select(".chapter-list-group a").joinToString { it.text() }
|
scanlator = element.select("div.component-chapter-teams a span").joinToString(" + ") { it.text() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun fetchChapterList(manga: SManga): Observable<List<SChapter>> {
|
override fun fetchChapterList(manga: SManga): Observable<List<SChapter>> {
|
||||||
val requestUrl = if (manga.url.startsWith("http")) {
|
val requestUrl = if (manga.url.startsWith("http")) {
|
||||||
"${manga.url}?page="
|
"${manga.url}"
|
||||||
} else {
|
} else {
|
||||||
"$baseUrl${manga.url}?page="
|
"$baseUrl${manga.url}"
|
||||||
}
|
}
|
||||||
return client.newCall(GET(requestUrl, headers))
|
return client.newCall(GET(requestUrl, headers))
|
||||||
.asObservableSuccess()
|
.asObservableSuccess()
|
||||||
|
@ -167,18 +178,19 @@ class Japanread : ParsedHttpSource() {
|
||||||
chapterListParse(response, requestUrl)
|
chapterListParse(response, requestUrl)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun chapterListParse(response: Response, requestUrl: String): List<SChapter> {
|
private fun chapterListParse(response: Response, requestUrl: String): List<SChapter> {
|
||||||
val chapters = mutableListOf<SChapter>()
|
val chapters = mutableListOf<SChapter>()
|
||||||
var document = response.asJsoup()
|
var document = response.asJsoup()
|
||||||
var moreChapters = true
|
var moreChapters = true
|
||||||
var nextPage = 2
|
var nextPage = 1
|
||||||
|
val pagemax = if (!document.select(".paginator button:contains(>>)").isNullOrEmpty()) {
|
||||||
|
document.select(".paginator button:contains(>>)")?.first()?.attr("data-limit")?.toInt()?.plus(1) ?: 1
|
||||||
|
} else { 1 }
|
||||||
// chapters are paginated
|
// chapters are paginated
|
||||||
while (moreChapters) {
|
while (moreChapters && nextPage <= pagemax) {
|
||||||
document.select(chapterListSelector()).map { chapters.add(chapterFromElement(it)) }
|
document.select(chapterListSelector()).map { chapters.add(chapterFromElement(it)) }
|
||||||
if (!document.select("a[rel=next]").isNullOrEmpty()) {
|
if (nextPage < pagemax) {
|
||||||
document = client.newCall(GET(requestUrl + nextPage, headers)).execute().asJsoup()
|
document = client.newCall(GET("$requestUrl?limit=$nextPage", headers)).execute().asJsoup()
|
||||||
nextPage++
|
nextPage++
|
||||||
} else {
|
} else {
|
||||||
moreChapters = false
|
moreChapters = false
|
||||||
|
@ -272,13 +284,14 @@ class Japanread : ParsedHttpSource() {
|
||||||
|
|
||||||
private class SortFilter : UriSelectFilter(
|
private class SortFilter : UriSelectFilter(
|
||||||
"Tri",
|
"Tri",
|
||||||
"sortType",
|
"order_by",
|
||||||
arrayOf(
|
arrayOf(
|
||||||
Pair("9", "Les + vus"),
|
Pair("views", "Les + vus"),
|
||||||
Pair("7", "Les mieux notés"),
|
Pair("top", "Les mieux notés"),
|
||||||
Pair("2", "A - Z"),
|
Pair("name", "A - Z"),
|
||||||
Pair("5", "Les + commentés"),
|
Pair("comment", "Les + commentés"),
|
||||||
Pair("0", "Les + récents"),
|
Pair("update", "Les + récents"),
|
||||||
|
Pair("create", "Par date de sortie"),
|
||||||
),
|
),
|
||||||
firstIsUnspecified = false,
|
firstIsUnspecified = false,
|
||||||
)
|
)
|
||||||
|
@ -303,6 +316,9 @@ class Japanread : ParsedHttpSource() {
|
||||||
Pair("0", "Tous"),
|
Pair("0", "Tous"),
|
||||||
Pair("1", "En cours"),
|
Pair("1", "En cours"),
|
||||||
Pair("2", "Terminé"),
|
Pair("2", "Terminé"),
|
||||||
|
Pair("3", "En pause"),
|
||||||
|
Pair("4", "Licencié"),
|
||||||
|
Pair("5", "Abandonné"),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue