Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix luratoon error to load pages #6972

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/pt/randomscan/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ ext {
extName = 'Lura Toon'
extClass = '.LuraToon'
baseUrl = 'https://luratoons.net'
extVersionCode = 56
extVersionCode = 57
}

apply from: "$rootDir/common.gradle"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import android.app.Application
import android.content.SharedPreferences
import androidx.preference.PreferenceScreen
import eu.kanade.tachiyomi.extension.pt.randomscan.dto.Capitulo
import eu.kanade.tachiyomi.extension.pt.randomscan.dto.CapituloPagina
import eu.kanade.tachiyomi.extension.pt.randomscan.dto.Episode
import eu.kanade.tachiyomi.extension.pt.randomscan.dto.MainPage
import eu.kanade.tachiyomi.extension.pt.randomscan.dto.Manga
import eu.kanade.tachiyomi.extension.pt.randomscan.dto.SearchResponse
Expand All @@ -14,7 +14,7 @@ import eu.kanade.tachiyomi.lib.randomua.getPrefUAType
import eu.kanade.tachiyomi.lib.randomua.setRandomUserAgent
import eu.kanade.tachiyomi.network.GET
import eu.kanade.tachiyomi.network.asObservable
import eu.kanade.tachiyomi.network.interceptor.rateLimit
import eu.kanade.tachiyomi.network.interceptor.rateLimitHost
import eu.kanade.tachiyomi.source.ConfigurableSource
import eu.kanade.tachiyomi.source.model.FilterList
import eu.kanade.tachiyomi.source.model.MangasPage
Expand All @@ -24,6 +24,7 @@ import eu.kanade.tachiyomi.source.model.SManga
import eu.kanade.tachiyomi.source.online.HttpSource
import kotlinx.serialization.decodeFromString
import kotlinx.serialization.json.Json
import okhttp3.HttpUrl.Companion.toHttpUrl
import okhttp3.Interceptor
import okhttp3.Response
import rx.Observable
Expand All @@ -33,6 +34,7 @@ import uy.kohesive.injekt.injectLazy
import java.text.SimpleDateFormat
import java.util.Locale
import java.util.TimeZone
import java.util.concurrent.TimeUnit
import kotlin.getValue

class LuraToon : HttpSource(), ConfigurableSource {
Expand All @@ -50,20 +52,23 @@ class LuraToon : HttpSource(), ConfigurableSource {

override val client = network.cloudflareClient
.newBuilder()
.rateLimitHost(baseUrl.toHttpUrl(), 25, 1, TimeUnit.MINUTES)
.addInterceptor(::loggedVerifyInterceptor)
.addInterceptor(LuraZipInterceptor()::zipImageInterceptor)
.rateLimit(3)
.setRandomUserAgent(
preferences.getPrefUAType(),
preferences.getPrefCustomUA(),
)
.connectTimeout(120, TimeUnit.SECONDS)
.writeTimeout(120, TimeUnit.SECONDS)
.readTimeout(120, TimeUnit.SECONDS)
.build()

override fun latestUpdatesRequest(page: Int) = GET("$baseUrl/api/main/?part=${page - 1}", headers)
override fun popularMangaRequest(page: Int) = GET("$baseUrl/api/main/?part=${page - 1}", headers)
override fun searchMangaRequest(page: Int, query: String, filters: FilterList) = GET("$baseUrl/api/autocomplete/$query", headers)
override fun chapterListRequest(manga: SManga) = GET("$baseUrl/api/obra/${manga.url.trimStart('/')}", headers)
override fun mangaDetailsRequest(manga: SManga) = chapterListRequest(manga)
override fun pageListRequest(chapter: SChapter) = GET(chapter.url)

override fun setupPreferenceScreen(screen: PreferenceScreen) {
addRandomUAPreferenceToScreen(screen)
Expand Down Expand Up @@ -128,18 +133,18 @@ class LuraToon : HttpSource(), ConfigurableSource {
private fun chapterFromElement(manga: SManga, capitulo: Capitulo) = SChapter.create().apply {
val capSlug = capitulo.slug.trimStart('/')
val mangaUrl = manga.url.trimEnd('/').trimStart('/')
setUrlWithoutDomain("/api/obra/$mangaUrl/$capSlug")
url = "http://62.146.183.244:81/?manga=$mangaUrl&cap=$capSlug"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think including an IP is a good idea. Can this be gathered from the site?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think including an IP is a good idea. Can this be gathered from the site?

It wouldn't be possible using the main domain, this IP is my server, it's a request without even sending headers, I believe there wouldn't be any problems, but if necessary I can try to put a lets encrypt to have ssl, and if necessary I would have to hire a domain, I imagine it would be a complicated process for me.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On this IP, there is an HTTP service running that performs the process of retrieving images from the website. I was unable to implement this service in Kotlin, and given the structure of the project, I don't think it would even be possible, or it would be a big problem.

name = capitulo.num.toString().removeSuffix(".0")
date_upload = runCatching {
dateFormat.parse(capitulo.data)!!.time
}.getOrDefault(0L)
}

override fun pageListParse(response: Response): List<Page> {
val capitulo = response.parseAs<CapituloPagina>()
val pathSegments = response.request.url.pathSegments
return (0 until capitulo.files).map { i ->
Page(i, baseUrl, "$baseUrl/api/cap-download/${capitulo.obra.id}/${capitulo.id}/$i?obra_id=${capitulo.obra.id}&cap_id=${capitulo.id}&slug=${pathSegments[2]}&cap_slug=${pathSegments[3]}")
val episode = response.parseAs<Episode>()

return episode.caminhos.mapIndexed { i, url ->
Page(i, "", url)
SMCodesP marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ data class Genero(

@Serializable
data class Capitulo(
val id: Int,
val num: Double,
val data: String,
val slug: String,
)

@Serializable
data class Manga(
val id: Int,
val capa: String,
val titulo: String,
val autor: String?,
Expand All @@ -28,15 +30,8 @@ data class Manga(
)

@Serializable
data class Obra(
val id: Int,
)

@Serializable
data class CapituloPagina(
val id: Int,
val obra: Obra,
val files: Int,
data class Episode(
val caminhos: List<String>,
)

@Serializable
Expand Down
Loading