-
Notifications
You must be signed in to change notification settings - Fork 465
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Keyoapp: Update cdn of sources and add paid chapters preference (#5666)
* update cdn and move preference to theme * lint
- Loading branch information
Showing
11 changed files
with
87 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
pref_show_paid_chapter_title=Display paid chapters | ||
pref_show_paid_chapter_summary_on=Paid chapters will appear. | ||
pref_show_paid_chapter_summary_off=Only free chapters will be displayed. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,8 @@ plugins { | |
id("lib-multisrc") | ||
} | ||
|
||
baseVersionCode = 7 | ||
baseVersionCode = 8 | ||
|
||
dependencies { | ||
api(project(":lib:i18n")) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 5 additions & 65 deletions
70
src/en/suryascans/src/eu/kanade/tachiyomi/extension/en/suryascans/GenzToons.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,79 +1,19 @@ | ||
package eu.kanade.tachiyomi.extension.en.suryascans | ||
|
||
import android.app.Application | ||
import android.content.SharedPreferences | ||
import androidx.preference.PreferenceScreen | ||
import androidx.preference.SwitchPreferenceCompat | ||
import eu.kanade.tachiyomi.multisrc.keyoapp.Keyoapp | ||
import eu.kanade.tachiyomi.network.interceptor.rateLimit | ||
import eu.kanade.tachiyomi.source.ConfigurableSource | ||
import eu.kanade.tachiyomi.source.model.Page | ||
import eu.kanade.tachiyomi.source.model.SChapter | ||
import org.jsoup.nodes.Document | ||
import org.jsoup.nodes.Element | ||
import uy.kohesive.injekt.Injekt | ||
import uy.kohesive.injekt.api.get | ||
import java.util.concurrent.TimeUnit | ||
|
||
class GenzToons : | ||
Keyoapp( | ||
"Genz Toons", | ||
"https://genzupdates.com", | ||
"en", | ||
), | ||
ConfigurableSource { | ||
|
||
private val preferences: SharedPreferences = | ||
Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000) | ||
class GenzToons : Keyoapp( | ||
"Genz Toons", | ||
"https://genzupdates.com", | ||
"en", | ||
) { | ||
|
||
override val client = super.client.newBuilder() | ||
.rateLimit(3) | ||
.connectTimeout(90, TimeUnit.SECONDS) | ||
.writeTimeout(90, TimeUnit.SECONDS) | ||
.readTimeout(90, TimeUnit.SECONDS) | ||
.build() | ||
|
||
override fun chapterListSelector(): String { | ||
if (!preferences.showPaidChapters) { | ||
return "#chapters > a:not(:has(.text-sm span:matches(Upcoming))):not(:has(img[src*=Coin.svg]))" | ||
} | ||
return "#chapters > a:not(:has(.text-sm span:matches(Upcoming)))" | ||
} | ||
|
||
override fun chapterFromElement(element: Element): SChapter { | ||
return super.chapterFromElement(element).apply { | ||
if (element.select("img[src*=Coin.svg]").isNotEmpty()) { | ||
name = "🔒 $name" | ||
} | ||
} | ||
} | ||
|
||
override fun pageListParse(document: Document): List<Page> { | ||
val script = document.select("#pages > script").joinToString("\n") { it.data() } | ||
val realCdnUrl = CDN_URL_REGEX.find(script)?.groupValues?.get(1)?.takeIf { it.startsWith("http") } | ||
?: "$baseUrl/uploads/" | ||
return document.select("#pages > img") | ||
.mapIndexed { index, img -> | ||
Page(index, document.location(), realCdnUrl + img.attr("uid")) | ||
} | ||
} | ||
|
||
override fun setupPreferenceScreen(screen: PreferenceScreen) { | ||
SwitchPreferenceCompat(screen.context).apply { | ||
key = SHOW_PAID_CHAPTERS_PREF | ||
title = "Display paid chapters" | ||
summaryOn = "Paid chapters will appear." | ||
summaryOff = "Only free chapters will be displayed." | ||
setDefaultValue(SHOW_PAID_CHAPTERS_DEFAULT) | ||
}.also(screen::addPreference) | ||
} | ||
|
||
private val SharedPreferences.showPaidChapters: Boolean | ||
get() = getBoolean(SHOW_PAID_CHAPTERS_PREF, SHOW_PAID_CHAPTERS_DEFAULT) | ||
|
||
companion object { | ||
private const val SHOW_PAID_CHAPTERS_PREF = "pref_show_paid_chap" | ||
private const val SHOW_PAID_CHAPTERS_DEFAULT = false | ||
private val CDN_URL_REGEX = """realUrl\s*=\s*`([^`]+?)\$""".toRegex() | ||
} | ||
} |