parent
0be4e0a4b4
commit
bce190416f
|
@ -5,8 +5,14 @@ ext {
|
|||
appName = 'Tachiyomi: LectorManga'
|
||||
pkgNameSuffix = 'es.lectormanga'
|
||||
extClass = '.LectorManga'
|
||||
extVersionCode = 1
|
||||
extVersionCode = 2
|
||||
libVersion = '1.2'
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation project(':lib-ratelimit')
|
||||
compileOnly project(':preference-stub')
|
||||
compileOnly 'com.github.inorichi.injekt:injekt-core:65b0440'
|
||||
}
|
||||
|
||||
apply from: "$rootDir/common.gradle"
|
||||
|
|
0
src/es/lectormanga/web_hi_res_512.png → src/es/lectormanga/res/web_hi_res_512.png
Executable file → Normal file
0
src/es/lectormanga/web_hi_res_512.png → src/es/lectormanga/res/web_hi_res_512.png
Executable file → Normal file
Before Width: | Height: | Size: 78 KiB After Width: | Height: | Size: 78 KiB |
|
@ -1,11 +1,13 @@
|
|||
package eu.kanade.tachiyomi.extension.es.lectormanga
|
||||
|
||||
import android.app.Application
|
||||
import android.content.SharedPreferences
|
||||
import android.support.v7.preference.ListPreference
|
||||
import android.support.v7.preference.PreferenceScreen
|
||||
import eu.kanade.tachiyomi.lib.ratelimit.RateLimitInterceptor
|
||||
import eu.kanade.tachiyomi.network.GET
|
||||
import eu.kanade.tachiyomi.source.model.Filter
|
||||
import eu.kanade.tachiyomi.source.model.FilterList
|
||||
import eu.kanade.tachiyomi.source.model.Page
|
||||
import eu.kanade.tachiyomi.source.model.SChapter
|
||||
import eu.kanade.tachiyomi.source.model.SManga
|
||||
import eu.kanade.tachiyomi.source.ConfigurableSource
|
||||
import eu.kanade.tachiyomi.source.model.*
|
||||
import eu.kanade.tachiyomi.source.online.ParsedHttpSource
|
||||
import eu.kanade.tachiyomi.util.asJsoup
|
||||
import okhttp3.Headers
|
||||
|
@ -15,6 +17,8 @@ import okhttp3.Request
|
|||
import okhttp3.Response
|
||||
import org.jsoup.nodes.Document
|
||||
import org.jsoup.nodes.Element
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Locale
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
@ -22,7 +26,7 @@ import java.util.concurrent.TimeUnit
|
|||
/**
|
||||
* Note: this source is similar to TuMangaOnline.
|
||||
*/
|
||||
class LectorManga : ParsedHttpSource() {
|
||||
class LectorManga : ConfigurableSource, ParsedHttpSource() {
|
||||
|
||||
override val name = "LectorManga"
|
||||
|
||||
|
@ -30,15 +34,17 @@ class LectorManga : ParsedHttpSource() {
|
|||
|
||||
override val lang = "es"
|
||||
|
||||
// TODO: the latest page returns a 500 right now
|
||||
override val supportsLatest = false
|
||||
override val supportsLatest = true
|
||||
|
||||
private val rateLimitInterceptor = RateLimitInterceptor(2)
|
||||
|
||||
override val client: OkHttpClient = network.cloudflareClient.newBuilder()
|
||||
.connectTimeout(1, TimeUnit.MINUTES)
|
||||
.readTimeout(1, TimeUnit.MINUTES)
|
||||
.retryOnConnectionFailure(true)
|
||||
.followRedirects(true)
|
||||
.build()!!
|
||||
.addNetworkInterceptor(rateLimitInterceptor)
|
||||
.connectTimeout(1, TimeUnit.MINUTES)
|
||||
.readTimeout(1, TimeUnit.MINUTES)
|
||||
.retryOnConnectionFailure(true)
|
||||
.followRedirects(true)
|
||||
.build()!!
|
||||
|
||||
override fun headersBuilder(): Headers.Builder {
|
||||
return Headers.Builder()
|
||||
|
@ -61,13 +67,17 @@ class LectorManga : ParsedHttpSource() {
|
|||
.toString()
|
||||
}
|
||||
|
||||
private val preferences: SharedPreferences by lazy {
|
||||
Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)
|
||||
}
|
||||
|
||||
override fun popularMangaSelector() = ".col-6 .card"
|
||||
|
||||
override fun latestUpdatesSelector() = popularMangaSelector()
|
||||
override fun latestUpdatesSelector() = "div.table-responsive:first-child td[scope=row]:nth-child(5n-3)"
|
||||
|
||||
override fun popularMangaRequest(page: Int) = GET("$baseUrl/library?order_item=likes_count&order_dir=desc&type=&filter_by=title&page=$page", headers)
|
||||
|
||||
override fun latestUpdatesRequest(page: Int) = GET("$baseUrl/library?order_item=creation&order_dir=desc&type=&filter_by=title&page=$page", headers)
|
||||
override fun latestUpdatesRequest(page: Int) = GET(baseUrl, headers)
|
||||
|
||||
override fun popularMangaFromElement(element: Element) = SManga.create().apply {
|
||||
setUrlWithoutDomain(element.select("a").attr("href"))
|
||||
|
@ -75,7 +85,22 @@ class LectorManga : ParsedHttpSource() {
|
|||
thumbnail_url = element.select("img").attr("src")
|
||||
}
|
||||
|
||||
override fun latestUpdatesFromElement(element: Element) = popularMangaFromElement(element)
|
||||
override fun latestUpdatesParse(response: Response): MangasPage {
|
||||
val document = response.asJsoup()
|
||||
val mangas = document.select(latestUpdatesSelector())
|
||||
.distinctBy { it.select("td").text().trim() }
|
||||
.map { latestUpdatesFromElement(it) }
|
||||
val hasNextPage = false
|
||||
return MangasPage(mangas, hasNextPage)
|
||||
}
|
||||
|
||||
override fun latestUpdatesFromElement(element: Element): SManga {
|
||||
|
||||
val manga = SManga.create()
|
||||
manga.setUrlWithoutDomain(element.select("a").first().attr("href"))
|
||||
manga.title = element.select("td").text().trim()
|
||||
return manga
|
||||
}
|
||||
|
||||
override fun mangaDetailsParse(document: Document) = SManga.create().apply {
|
||||
genre = document.select("a.py-2").joinToString(", ") {
|
||||
|
@ -95,7 +120,7 @@ class LectorManga : ParsedHttpSource() {
|
|||
|
||||
override fun popularMangaNextPageSelector() = ".pagination .page-item:not(.disabled) a[rel='next']"
|
||||
|
||||
override fun latestUpdatesNextPageSelector() = popularMangaNextPageSelector()
|
||||
override fun latestUpdatesNextPageSelector() = "none"
|
||||
|
||||
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
|
||||
val url = HttpUrl.parse("$baseUrl/library")!!.newBuilder()
|
||||
|
@ -174,11 +199,19 @@ class LectorManga : ParsedHttpSource() {
|
|||
}
|
||||
|
||||
// Regular list of chapters
|
||||
val chapters = mutableListOf<SChapter>()
|
||||
val dupselect = getduppref()!!
|
||||
val chapterNames = document.select("#chapters h4.text-truncate")
|
||||
val chapterInfos = document.select("#chapters .chapter-list")
|
||||
return (0 until chapterNames.size).map { regularChapterFromElement(
|
||||
chapterNames[it].text(),
|
||||
chapterInfos[it]) }
|
||||
chapterNames.forEachIndexed { index, _ ->
|
||||
val scanlator = chapterInfos[index].select("li")
|
||||
if (dupselect=="one") {
|
||||
scanlator.last { chapters.add(regularChapterFromElement(chapterNames[index].text(), it)) }
|
||||
} else {
|
||||
scanlator.forEach { chapters.add(regularChapterFromElement(chapterNames[index].text(), it)) }
|
||||
}
|
||||
}
|
||||
return chapters
|
||||
}
|
||||
|
||||
override fun chapterListSelector() = throw UnsupportedOperationException("Not used")
|
||||
|
@ -193,11 +226,15 @@ class LectorManga : ParsedHttpSource() {
|
|||
date_upload = element.select("span.badge.badge-primary.p-2").first()?.text()?.let { parseChapterDate(it) } ?: 0
|
||||
}
|
||||
|
||||
private fun regularChapterFromElement(chapterName: String, info: Element) = SChapter.create().apply {
|
||||
setUrlWithoutDomain(info.select("div.row > .text-right > a").attr("href"))
|
||||
name = chapterName
|
||||
scanlator = info.select("div.col-md-6.text-truncate")?.text()
|
||||
date_upload = info.select("span.badge.badge-primary.p-2").first()?.text()?.let { parseChapterDate(it) } ?: 0
|
||||
private fun regularChapterFromElement(chapterName: String, info: Element): SChapter {
|
||||
//val number = name.substringBefore("|").substringAfter("Capítulo").trim().toFloat()
|
||||
val chapter = SChapter.create()
|
||||
chapter.setUrlWithoutDomain(info.select("div.row > .text-right > a").attr("href"))
|
||||
chapter.name = chapterName
|
||||
chapter.scanlator = info.select("div.col-md-6.text-truncate")?.text()
|
||||
chapter.date_upload = info.select("span.badge.badge-primary.p-2").first()?.text()?.let { parseChapterDate(it) } ?: 0
|
||||
//chapter.chapter_number = number
|
||||
return chapter
|
||||
}
|
||||
|
||||
private fun parseChapterDate(date: String): Long = SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()).parse(date).time
|
||||
|
@ -337,4 +374,30 @@ class LectorManga : ParsedHttpSource() {
|
|||
fun toUriPart() = vals[state].second
|
||||
}
|
||||
|
||||
// Preferences Code
|
||||
override fun setupPreferenceScreen(screen: PreferenceScreen) {
|
||||
val deduppref = ListPreference(screen.context).apply {
|
||||
key = DEDUP_PREF_Title
|
||||
title = DEDUP_PREF_Title
|
||||
entries = arrayOf("All scanlators", "One scanlator per chapter")
|
||||
entryValues = arrayOf("all", "one")
|
||||
summary = "%s"
|
||||
|
||||
setOnPreferenceChangeListener { _, newValue ->
|
||||
val selected = newValue as String
|
||||
val index = this.findIndexOfValue(selected)
|
||||
val entry = entryValues.get(index) as String
|
||||
preferences.edit().putString(DEDUP_PREF, entry).commit()
|
||||
}
|
||||
}
|
||||
screen.addPreference(deduppref)
|
||||
}
|
||||
|
||||
private fun getduppref() = preferences.getString(DEDUP_PREF, "all")
|
||||
|
||||
companion object {
|
||||
private const val DEDUP_PREF_Title = "Chapter List Scanlator Preference"
|
||||
private const val DEDUP_PREF = "deduppref"
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue