TMO / LectorManga: Move to factory (fix http 530) (#4393)

* damn

* shouldn't newBuilder() create a new instance?

* 1 second is enough

* remove lazy

Co-authored-by: AwkwardPeak7 <48650614+AwkwardPeak7@users.noreply.github.com>

* imports

---------

Co-authored-by: AwkwardPeak7 <48650614+AwkwardPeak7@users.noreply.github.com>
This commit is contained in:
bapeey 2024-08-05 08:59:49 -05:00 committed by GitHub
parent d9df458993
commit ce55da1870
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
20 changed files with 46 additions and 47 deletions

View File

@ -1,5 +0,0 @@
plugins {
id("lib-multisrc")
}
baseVersionCode = 6

View File

@ -1,10 +0,0 @@
ext {
extName = 'LectorManga'
extClass = '.LectorManga'
themePkg = 'lectortmo'
baseUrl = 'https://lectormanga.com'
overrideVersionCode = 34
isNsfw = true
}
apply from: "$rootDir/common.gradle"

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

View File

@ -3,7 +3,7 @@
<application>
<activity
android:name="eu.kanade.tachiyomi.multisrc.lectortmo.LectorTmoUrlActivity"
android:name="eu.kanade.tachiyomi.extension.es.lectortmo.LectorTmoUrlActivity"
android:excludeFromRecents="true"
android:exported="true"
android:theme="@android:style/Theme.NoDisplay">
@ -12,10 +12,10 @@
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="${SOURCEHOST}"
android:pathPattern="/library/..*/..*/..*"
android:scheme="${SOURCESCHEME}" />
<data android:scheme="https"/>
<data android:host="lectormanga.com"/>
<data android:host="visortmo.com"/>
<data android:pathPattern="/library/..*/..*/..*"/>
</intent-filter>
</activity>
</application>

View File

@ -0,0 +1,8 @@
ext {
extName = 'TuMangaOnline / LectorManga'
extClass = '.LectorTmoFactory'
extVersionCode = 1
isNsfw = true
}
apply from: "$rootDir/common.gradle"

View File

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

View File

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 5.4 KiB

View File

Before

Width:  |  Height:  |  Size: 9.4 KiB

After

Width:  |  Height:  |  Size: 9.4 KiB

View File

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.multisrc.lectortmo
package eu.kanade.tachiyomi.extension.es.lectortmo
import android.annotation.SuppressLint
import android.app.Application
@ -42,6 +42,7 @@ abstract class LectorTmo(
override val name: String,
override val baseUrl: String,
override val lang: String,
private val rateLimitClient: OkHttpClient,
) : ParsedHttpSource(), ConfigurableSource {
private val preferences: SharedPreferences by lazy {
@ -91,7 +92,7 @@ abstract class LectorTmo(
}
private val ignoreSslClient: OkHttpClient by lazy {
network.cloudflareClient.newBuilder()
rateLimitClient.newBuilder()
.ignoreAllSSLErrors()
.followRedirects(false)
.rateLimit(
@ -103,7 +104,7 @@ abstract class LectorTmo(
private var lastCFDomain: String = ""
override val client: OkHttpClient by lazy {
network.cloudflareClient.newBuilder()
rateLimitClient.newBuilder()
.addInterceptor { chain ->
val request = chain.request()
val url = request.url
@ -244,6 +245,8 @@ abstract class LectorTmo(
return super.getMangaUrl(manga)
}
override fun mangaDetailsRequest(manga: SManga) = GET(baseUrl + manga.url, tmoHeaders)
override fun mangaDetailsParse(document: Document) = SManga.create().apply {
title = document.select("h2.element-subtitle").text()
document.select("h5.card-title").let {
@ -271,6 +274,8 @@ abstract class LectorTmo(
return super.getChapterUrl(chapter)
}
override fun chapterListRequest(manga: SManga) = mangaDetailsRequest(manga)
override fun chapterListParse(response: Response): List<SChapter> {
val document = response.asJsoup()

View File

@ -1,7 +1,9 @@
package eu.kanade.tachiyomi.extension.es.lectormanga
package eu.kanade.tachiyomi.extension.es.lectortmo
import eu.kanade.tachiyomi.multisrc.lectortmo.LectorTmo
import eu.kanade.tachiyomi.network.GET
import eu.kanade.tachiyomi.network.NetworkHelper
import eu.kanade.tachiyomi.network.interceptor.rateLimit
import eu.kanade.tachiyomi.source.SourceFactory
import eu.kanade.tachiyomi.source.model.Page
import eu.kanade.tachiyomi.source.model.SChapter
import eu.kanade.tachiyomi.source.model.SManga
@ -9,9 +11,26 @@ import eu.kanade.tachiyomi.util.asJsoup
import okhttp3.Response
import org.jsoup.nodes.Document
import org.jsoup.nodes.Element
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
class LectorManga : LectorTmo("LectorManga", "https://lectormanga.com", "es") {
class LectorTmoFactory : SourceFactory {
override fun createSources() = listOf(
LectorManga(),
TuMangaOnline(),
)
}
val rateLimitClient = Injekt.get<NetworkHelper>().cloudflareClient.newBuilder()
.rateLimit(1, 1)
.build()
class TuMangaOnline : LectorTmo("TuMangaOnline", "https://visortmo.com", "es", rateLimitClient) {
override val id = 4146344224513899730
}
class LectorManga : LectorTmo("LectorManga", "https://lectormanga.com", "es", rateLimitClient) {
override val id = 7925520943983324764
override fun popularMangaSelector() = ".col-6 .card"

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.multisrc.lectortmo
package eu.kanade.tachiyomi.extension.es.lectortmo
import eu.kanade.tachiyomi.source.model.Filter

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.multisrc.lectortmo
package eu.kanade.tachiyomi.extension.es.lectortmo
import android.app.Activity
import android.content.ActivityNotFoundException
@ -19,7 +19,7 @@ class LectorTmoUrlActivity : Activity() {
val mainIntent = Intent().apply {
action = "eu.kanade.tachiyomi.SEARCH"
putExtra("query", "${LectorTmo.PREFIX_SLUG_SEARCH}$type/$id/$slug")
putExtra("query", "slug:$type/$id/$slug")
putExtra("filter", packageName)
}

View File

@ -1,10 +0,0 @@
ext {
extName = 'TuMangaOnline'
extClass = '.TuMangaOnline'
themePkg = 'lectortmo'
baseUrl = 'https://visortmo.com'
overrideVersionCode = 49
isNsfw = true
}
apply from: "$rootDir/common.gradle"

View File

@ -1,8 +0,0 @@
package eu.kanade.tachiyomi.extension.es.tumangaonline
import eu.kanade.tachiyomi.multisrc.lectortmo.LectorTmo
class TuMangaOnline : LectorTmo("TuMangaOnline", "https://visortmo.com", "es") {
override val id = 4146344224513899730
}