tsumino half fixed. mostly usable
This commit is contained in:
parent
93c8773e91
commit
7ac188709b
@ -34,6 +34,7 @@ import rx.schedulers.Schedulers
|
|||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
import java.io.IOException
|
||||||
|
|
||||||
class Tsumino(private val context: Context): ParsedHttpSource(),
|
class Tsumino(private val context: Context): ParsedHttpSource(),
|
||||||
LewdSource<TsuminoSearchMetadata, Document>,
|
LewdSource<TsuminoSearchMetadata, Document>,
|
||||||
@ -129,7 +130,7 @@ class Tsumino(private val context: Context): ParsedHttpSource(),
|
|||||||
SManga.create().apply {
|
SManga.create().apply {
|
||||||
val id = obj["id"].long
|
val id = obj["id"].long
|
||||||
url = TsuminoSearchMetadata.mangaUrlFromId(id.toString())
|
url = TsuminoSearchMetadata.mangaUrlFromId(id.toString())
|
||||||
thumbnail_url = BASE_URL.replace("www", "content") + TsuminoSearchMetadata.thumbUrlFromId(id.toString())
|
thumbnail_url = obj["thumbnailUrl"].asString
|
||||||
|
|
||||||
title = obj["title"].string
|
title = obj["title"].string
|
||||||
}
|
}
|
||||||
@ -259,11 +260,10 @@ class Tsumino(private val context: Context): ParsedHttpSource(),
|
|||||||
.map { it.asJsoup() }
|
.map { it.asJsoup() }
|
||||||
.toSingle()
|
.toSingle()
|
||||||
}.map {
|
}.map {
|
||||||
trickTsumino(it.tmId)
|
|
||||||
|
|
||||||
listOf(
|
listOf(
|
||||||
SChapter.create().apply {
|
SChapter.create().apply {
|
||||||
url = "/Read/View/${it.tmId}"
|
url = "/entry/${it.tmId}"
|
||||||
name = "Chapter"
|
name = "Chapter"
|
||||||
|
|
||||||
it.uploadDate?.let { date_upload = it }
|
it.uploadDate?.let { date_upload = it }
|
||||||
@ -273,27 +273,6 @@ class Tsumino(private val context: Context): ParsedHttpSource(),
|
|||||||
)
|
)
|
||||||
}.toObservable()
|
}.toObservable()
|
||||||
|
|
||||||
fun trickTsumino(id: Int?) {
|
|
||||||
if(id == null) return
|
|
||||||
|
|
||||||
//Make one call to /Read/View (ASP session cookie)
|
|
||||||
val rvReq = GET("$BASE_URL/Read/View/$id")
|
|
||||||
val resp = client.newCall(rvReq).execute()
|
|
||||||
|
|
||||||
// Make 5 requests to the first 5 pages of the book in reader process
|
|
||||||
var chain: Observable<Any> = Observable.just(0)
|
|
||||||
for(i in 1 .. 5) {
|
|
||||||
chain = chain.flatMap {
|
|
||||||
val req = GET("$BASE_URL/Read/Process/$id/$i")
|
|
||||||
client.newCall(req).asObservableSuccess()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
chain.observeOn(Schedulers.io())
|
|
||||||
.subscribeOn(Schedulers.io())
|
|
||||||
.subscribe({}, {})
|
|
||||||
}
|
|
||||||
|
|
||||||
override val client: OkHttpClient
|
override val client: OkHttpClient
|
||||||
// Do not call super here as we don't want auto-captcha detection here
|
// Do not call super here as we don't want auto-captcha detection here
|
||||||
get() = network.client.newBuilder()
|
get() = network.client.newBuilder()
|
||||||
@ -327,17 +306,28 @@ class Tsumino(private val context: Context): ParsedHttpSource(),
|
|||||||
response
|
response
|
||||||
}.build()
|
}.build()
|
||||||
|
|
||||||
|
|
||||||
override fun fetchPageList(chapter: SChapter): Observable<List<Page>> {
|
override fun fetchPageList(chapter: SChapter): Observable<List<Page>> {
|
||||||
val id = chapter.url.substringAfterLast('/')
|
val id = chapter.url.substringAfterLast('/')
|
||||||
val call = POST("$BASE_URL/Read/Load", body = FormBody.Builder().add("q", id).build())
|
val call = POST("$BASE_URL/Read/Load", body = FormBody.Builder().add("q", id).build())
|
||||||
return client.newCall(call).asObservableSuccess().map {
|
return client.newCall(call).asObservableSuccess().map {
|
||||||
val parsed = jsonParser.parse(it.body()!!.string()).obj
|
val page = client.newCall(GET("$BASE_URL/Read/Index/$id?page=1")).execute().asJsoup()
|
||||||
val pageUrls = parsed["reader_page_urls"].array
|
val numPages = page.select("h1").text().split(" ").last()
|
||||||
|
|
||||||
val imageUrl = Uri.parse("$BASE_URL/Image/Object")
|
if (numPages.isNotEmpty()) {
|
||||||
pageUrls.mapIndexed { index, obj ->
|
val pageArr = Array(numPages.toInt()) {i -> (
|
||||||
val newImageUrl = imageUrl.buildUpon().appendQueryParameter("name", obj.string)
|
page.select("#image-container").attr("data-cdn")
|
||||||
Page(index, chapter.url + "#${index + 1}", newImageUrl.toString())
|
.replace("[PAGE]", (i+1).toString())
|
||||||
|
)}
|
||||||
|
|
||||||
|
val pageUrls = Array(numPages.toInt()) {i -> (
|
||||||
|
"$BASE_URL/Read/Index/$id?page="+(i+1).toString()
|
||||||
|
)}
|
||||||
|
pageUrls.mapIndexed {index, obj ->
|
||||||
|
Page(index, pageUrls[index], pageArr[index])
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw IOException("probably a captcha")
|
||||||
}
|
}
|
||||||
}.doOnError {
|
}.doOnError {
|
||||||
try {
|
try {
|
||||||
@ -361,6 +351,7 @@ class Tsumino(private val context: Context): ParsedHttpSource(),
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
override fun verifyComplete(url: String): Boolean {
|
override fun verifyComplete(url: String): Boolean {
|
||||||
return Uri.parse(url).pathSegments.getOrNull(1) == "View"
|
return Uri.parse(url).pathSegments.getOrNull(1) == "View"
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user