* feat(AnimeSama): Support multiple version of scan (Color and colorless for exemple) * update(AnimeSama) * fix(AnimeSama): Use Scanlators not multiple entries * fix(AnimeSama): No more requests in chapterListRequest only in chapterListParse
This commit is contained in:
parent
5824d4adfa
commit
7e3d185dab
|
@ -1,7 +1,7 @@
|
||||||
ext {
|
ext {
|
||||||
extName = 'AnimeSama'
|
extName = 'AnimeSama'
|
||||||
extClass = '.AnimeSama'
|
extClass = '.AnimeSama'
|
||||||
extVersionCode = 2
|
extVersionCode = 3
|
||||||
}
|
}
|
||||||
|
|
||||||
apply from: "$rootDir/common.gradle"
|
apply from: "$rootDir/common.gradle"
|
||||||
|
|
|
@ -11,6 +11,7 @@ import eu.kanade.tachiyomi.util.asJsoup
|
||||||
import okhttp3.FormBody
|
import okhttp3.FormBody
|
||||||
import okhttp3.Headers
|
import okhttp3.Headers
|
||||||
import okhttp3.HttpUrl.Companion.toHttpUrl
|
import okhttp3.HttpUrl.Companion.toHttpUrl
|
||||||
|
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
|
||||||
import okhttp3.OkHttpClient
|
import okhttp3.OkHttpClient
|
||||||
import okhttp3.Request
|
import okhttp3.Request
|
||||||
import okhttp3.Response
|
import okhttp3.Response
|
||||||
|
@ -62,19 +63,20 @@ class AnimeSama : ParsedHttpSource() {
|
||||||
|
|
||||||
// Search
|
// Search
|
||||||
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
|
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
|
||||||
val url = "$baseUrl/template-php/defaut/fetch.php"
|
val url = "$baseUrl/catalogue/searchbar.php"
|
||||||
val formBody = FormBody.Builder()
|
val formBody = FormBody.Builder()
|
||||||
.add("query", query)
|
.add("query", query)
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
return POST(url, headers, formBody)
|
return POST(url, headers, formBody)
|
||||||
}
|
}
|
||||||
override fun searchMangaSelector() = "a[href*='catalogue']"
|
|
||||||
|
override fun searchMangaSelector() = ".cardListAnime.Scans"
|
||||||
override fun searchMangaNextPageSelector(): String? = null
|
override fun searchMangaNextPageSelector(): String? = null
|
||||||
override fun searchMangaFromElement(element: Element): SManga {
|
override fun searchMangaFromElement(element: Element): SManga {
|
||||||
return SManga.create().apply {
|
return SManga.create().apply {
|
||||||
title = element.select("h3").text()
|
title = element.select("h1").text()
|
||||||
setUrlWithoutDomain(element.attr("href"))
|
setUrlWithoutDomain(element.select("a").attr("href"))
|
||||||
thumbnail_url = element.select("img").attr("src")
|
thumbnail_url = element.select("img").attr("src")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -99,57 +101,59 @@ class AnimeSama : ParsedHttpSource() {
|
||||||
return count > 1
|
return count > 1
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun chapterListRequest(manga: SManga): Request {
|
private fun parseChapterFromResponse(response: Response, translation_name: String): List<SChapter> {
|
||||||
val url = "$baseUrl${manga.url}/scan/vf"
|
val document = response.asJsoup()
|
||||||
return GET(url, headers)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun chapterListParse(response: Response): List<SChapter> {
|
val chapterUrl = document.baseUri().toHttpUrl()
|
||||||
var document = response.asJsoup()
|
.newBuilder()
|
||||||
|
.query(null)
|
||||||
|
.addPathSegment("episodes.js")
|
||||||
|
.addQueryParameter("title", document.select("#titreOeuvre").text())
|
||||||
|
.build()
|
||||||
|
|
||||||
val baseChapterUrl = "episodes.js?title=" + document.select("#titreOeuvre").text()
|
val requestToFetchChapters = GET(chapterUrl, headers)
|
||||||
|
|
||||||
val requestToFetchChapters = GET("${document.baseUri()}/$baseChapterUrl", headers)
|
|
||||||
val javascriptFile = client.newCall(requestToFetchChapters).execute()
|
val javascriptFile = client.newCall(requestToFetchChapters).execute()
|
||||||
var javascriptFileContent = javascriptFile.body.string()
|
val javascriptFileContent = javascriptFile.body.string()
|
||||||
|
|
||||||
val parsedJavascriptFileToJson = javascriptFileContent
|
val parsedJavascriptFileToJson = javascriptFileContent
|
||||||
.split(" ", ",")
|
.split(" ", ",")
|
||||||
.filter { it.contains("eps") && !it.contains("drive.google.com") }
|
.filter { it.contains("eps") && !it.contains("drive.google.com") }
|
||||||
.mapNotNull { it.replace("=", "").replace("eps", "").toIntOrNull() }
|
.mapNotNull { it.replace("=", "").replace("eps", "").toIntOrNull() }
|
||||||
.sorted()
|
.sorted()
|
||||||
.map { chapter ->
|
.asReversed()
|
||||||
}.asReversed()
|
.toSet() // Remove duplicate episodes
|
||||||
var parsedChapterList: MutableList<SChapter> = ArrayList()
|
val parsedChapterList: MutableList<SChapter> = ArrayList()
|
||||||
var chapterDelay = 0
|
var chapterDelay = 0
|
||||||
|
|
||||||
var scriptContent = document.select("script:containsData(resetListe\\(\\))").toString()
|
val scriptContent = document.select("script:containsData(resetListe\\(\\))").toString()
|
||||||
if (scriptContent.containsMultipleTimes("resetListe()")) {
|
if (scriptContent.containsMultipleTimes("resetListe()")) {
|
||||||
var scriptCommandList = document.html().split(";")
|
val scriptCommandList = document.html().split(";")
|
||||||
var createListRegex = Regex("""creerListe\((\d+,\s*\d+)\)""")
|
val createListRegex = Regex("""creerListe\((\d+,\s*\d+)\)""")
|
||||||
var specialRegex = Regex("""newSP\((\d+(\.\d+)?)\)""")
|
val specialRegex = Regex("""newSP\((\d+(\.\d+)?|"(.*?)")\)""")
|
||||||
scriptCommandList.forEach { command ->
|
scriptCommandList.forEach { command ->
|
||||||
when {
|
when {
|
||||||
createListRegex.find(command) != null -> {
|
createListRegex.find(command) != null -> {
|
||||||
var data = createListRegex.find(command)!!.groupValues[1].split(",")
|
val data = createListRegex.find(command)!!.groupValues[1].split(",")
|
||||||
var start = data[0].replace(" ", "").toInt()
|
val start = data[0].replace(" ", "").toInt()
|
||||||
var end = data[1].replace(" ", "").toInt()
|
val end = data[1].replace(" ", "").toInt()
|
||||||
|
|
||||||
for (i in start..end) {
|
for (i in start..end) {
|
||||||
parsedChapterList.add(
|
parsedChapterList.add(
|
||||||
SChapter.create().apply {
|
SChapter.create().apply {
|
||||||
name = "Chapitre " + i
|
name = "Chapitre $i"
|
||||||
setUrlWithoutDomain(document.baseUri() + "/" + baseChapterUrl + "&id=${parsedChapterList.size + 1}")
|
setUrlWithoutDomain(chapterUrl.newBuilder().addQueryParameter("id", (parsedChapterList.size + 1).toString()).build().toString())
|
||||||
|
scanlator = translation_name
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
specialRegex.find(command) != null -> {
|
specialRegex.find(command) != null -> {
|
||||||
var title = specialRegex.find(command)!!.groupValues[1]
|
val title = specialRegex.find(command)!!.groupValues[1]
|
||||||
parsedChapterList.add(
|
parsedChapterList.add(
|
||||||
SChapter.create().apply {
|
SChapter.create().apply {
|
||||||
name = "Chapitre " + title
|
name = "Chapitre $title"
|
||||||
setUrlWithoutDomain(document.baseUri() + "/" + baseChapterUrl + "&id=${parsedChapterList.size + 1}")
|
setUrlWithoutDomain(chapterUrl.newBuilder().addQueryParameter("id", (parsedChapterList.size + 1).toString()).build().toString())
|
||||||
|
scanlator = translation_name
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
chapterDelay++
|
chapterDelay++
|
||||||
|
@ -162,10 +166,46 @@ class AnimeSama : ParsedHttpSource() {
|
||||||
parsedChapterList.add(
|
parsedChapterList.add(
|
||||||
SChapter.create().apply {
|
SChapter.create().apply {
|
||||||
name = "Chapitre " + (parsedChapterList.size + 1 - chapterDelay)
|
name = "Chapitre " + (parsedChapterList.size + 1 - chapterDelay)
|
||||||
setUrlWithoutDomain(document.baseUri() + "/" + baseChapterUrl + "&id=${parsedChapterList.size + 1}")
|
setUrlWithoutDomain(chapterUrl.newBuilder().addQueryParameter("id", (parsedChapterList.size + 1).toString()).build().toString())
|
||||||
|
scanlator = translation_name
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
return parsedChapterList
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun chapterListParse(response: Response): List<SChapter> {
|
||||||
|
val url = response.request.url.toUrl().toHttpUrlOrNull()!!
|
||||||
|
val document = response.asJsoup()
|
||||||
|
val scriptContent = document.select("script:containsData(panneauScan(\"nom\", \"url\"))").toString()
|
||||||
|
val splitedContent = scriptContent.split(";").toMutableList()
|
||||||
|
// Remove exemple
|
||||||
|
splitedContent.removeAt(0)
|
||||||
|
|
||||||
|
val parsedChapterList: MutableList<SChapter> = mutableListOf()
|
||||||
|
|
||||||
|
splitedContent.forEach { line ->
|
||||||
|
val pattern = """panneauScan\("(.+?)", "(.+?)"\)""".toRegex()
|
||||||
|
val matchResult = pattern.find(line)
|
||||||
|
if (matchResult != null) {
|
||||||
|
val (scanTitle, scanUrl) = matchResult.destructured
|
||||||
|
if (!scanUrl.contains("va")) {
|
||||||
|
val scanlatorGroup = scanTitle.replace(Regex("""(Scans|\(|\))"""), "").trim()
|
||||||
|
val fetchExistentSubMangas = GET(
|
||||||
|
url.newBuilder()
|
||||||
|
.addPathSegments(
|
||||||
|
scanUrl,
|
||||||
|
).build(),
|
||||||
|
headers,
|
||||||
|
)
|
||||||
|
val res = client.newCall(fetchExistentSubMangas).execute()
|
||||||
|
parsedChapterList.addAll(parseChapterFromResponse(res, scanlatorGroup))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
parsedChapterList.sortBy { chapter -> ("$baseUrl${chapter.url}").toHttpUrl().queryParameter("id")?.toIntOrNull() }
|
||||||
|
|
||||||
return parsedChapterList.asReversed()
|
return parsedChapterList.asReversed()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue