parent
9fc03a5357
commit
6433c41cb7
@ -1,7 +1,7 @@
|
|||||||
ext {
|
ext {
|
||||||
extName = 'AnimeSama'
|
extName = 'AnimeSama'
|
||||||
extClass = '.AnimeSama'
|
extClass = '.AnimeSama'
|
||||||
extVersionCode = 4
|
extVersionCode = 5
|
||||||
}
|
}
|
||||||
|
|
||||||
apply from: "$rootDir/common.gradle"
|
apply from: "$rootDir/common.gradle"
|
||||||
|
@ -114,12 +114,10 @@ class AnimeSama : ParsedHttpSource() {
|
|||||||
val javascriptFileContent = javascriptFile.body.string()
|
val javascriptFileContent = javascriptFile.body.string()
|
||||||
|
|
||||||
val parsedJavascriptFileToJson = javascriptFileContent
|
val parsedJavascriptFileToJson = javascriptFileContent
|
||||||
.split(" ", ",")
|
.let { Regex("""eps(\d+)""").findAll(it) }
|
||||||
.filter { it.contains("eps") && !it.contains("drive.google.com") }
|
.map { it.groupValues[1].toInt() }
|
||||||
.mapNotNull { it.replace("=", "").replace("eps", "").toIntOrNull() }
|
.distinct() // Remove duplicate episodes
|
||||||
.sorted()
|
.sortedDescending().toList()
|
||||||
.asReversed()
|
|
||||||
.toSet() // Remove duplicate episodes
|
|
||||||
val parsedChapterList: MutableList<SChapter> = ArrayList()
|
val parsedChapterList: MutableList<SChapter> = ArrayList()
|
||||||
var chapterDelay = 0
|
var chapterDelay = 0
|
||||||
|
|
||||||
@ -214,19 +212,28 @@ class AnimeSama : ParsedHttpSource() {
|
|||||||
val title = url.queryParameter("title")
|
val title = url.queryParameter("title")
|
||||||
val chapter = url.queryParameter("id")
|
val chapter = url.queryParameter("id")
|
||||||
|
|
||||||
val allChapters = document.body().toString().split("var")
|
val documentString = document.body().toString()
|
||||||
|
|
||||||
val chapterImageListString = allChapters.firstOrNull { it.contains("eps$chapter=") }
|
val allChapters: Map<Int, Int> = Regex("""eps(\d+)\s*(?:=\s*\[(.*?)\]|\.length\s*=\s*(\d+))""")
|
||||||
?: return emptyList()
|
.findAll(documentString)
|
||||||
|
.associate { match ->
|
||||||
|
val episode = match.groupValues[1].toInt()
|
||||||
|
val arrayContent = match.groupValues[2]
|
||||||
|
val explicitLength = match.groupValues[3]
|
||||||
|
|
||||||
val chapterImageListParsed = chapterImageListString
|
val length = when {
|
||||||
.substringAfter("[")
|
explicitLength.isNotEmpty() -> explicitLength.toInt()
|
||||||
.substringBefore("]")
|
arrayContent.isNotEmpty() -> arrayContent.split(Regex(",\\s*")).count { it.isNotBlank() }
|
||||||
.split(",")
|
else -> 0
|
||||||
|
}
|
||||||
|
|
||||||
|
episode to length
|
||||||
|
}
|
||||||
|
|
||||||
|
val chapterSize = allChapters.get(chapter?.toInt()) ?: 1
|
||||||
|
|
||||||
val image_list = mutableListOf<Page>()
|
val image_list = mutableListOf<Page>()
|
||||||
|
for (index in 1 until chapterSize + 1) {
|
||||||
for (index in 1 until chapterImageListParsed.size) {
|
|
||||||
image_list.add(
|
image_list.add(
|
||||||
Page(index, imageUrl = "$cdn$title/$chapter/$index.jpg"),
|
Page(index, imageUrl = "$cdn$title/$chapter/$index.jpg"),
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user