MMRCMS - enhancements (#3203)
This commit is contained in:
parent
d890768fe6
commit
a1857f5f35
|
@ -5,7 +5,7 @@ ext {
|
||||||
appName = 'Tachiyomi: My Manga Reader CMS (Many sources)'
|
appName = 'Tachiyomi: My Manga Reader CMS (Many sources)'
|
||||||
pkgNameSuffix = 'all.mmrcms'
|
pkgNameSuffix = 'all.mmrcms'
|
||||||
extClass = '.MyMangaReaderCMSSources'
|
extClass = '.MyMangaReaderCMSSources'
|
||||||
extVersionCode = 38
|
extVersionCode = 39
|
||||||
libVersion = '1.2'
|
libVersion = '1.2'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -229,8 +229,8 @@ class Generator {
|
||||||
Triple("fr", "Scan OP", "https://scan-op.com"),
|
Triple("fr", "Scan OP", "https://scan-op.com"),
|
||||||
Triple("id", "Komikid", "https://www.komikid.com"),
|
Triple("id", "Komikid", "https://www.komikid.com"),
|
||||||
Triple("pl", "ToraScans", "http://torascans.pl"),
|
Triple("pl", "ToraScans", "http://torascans.pl"),
|
||||||
Triple("pt", "Comic Space", "https://www.comicspace.com.br"),
|
Triple("pt-BR", "Comic Space", "https://www.comicspace.com.br"),
|
||||||
Triple("pt", "Mangás Yuri", "https://mangasyuri.net"),
|
Triple("pt-BR", "Mangás Yuri", "https://mangasyuri.net"),
|
||||||
Triple("pl", "Dracaena", "https://dracaena.webd.pl/czytnik"),
|
Triple("pl", "Dracaena", "https://dracaena.webd.pl/czytnik"),
|
||||||
Triple("pl", "Nikushima", "http://azbivo.webd.pro"),
|
Triple("pl", "Nikushima", "http://azbivo.webd.pro"),
|
||||||
Triple("tr", "MangaHanta", "http://mangahanta.com"),
|
Triple("tr", "MangaHanta", "http://mangahanta.com"),
|
||||||
|
|
|
@ -8,6 +8,7 @@ import com.github.salomonbrys.kotson.get
|
||||||
import com.github.salomonbrys.kotson.string
|
import com.github.salomonbrys.kotson.string
|
||||||
import com.google.gson.JsonParser
|
import com.google.gson.JsonParser
|
||||||
import eu.kanade.tachiyomi.network.GET
|
import eu.kanade.tachiyomi.network.GET
|
||||||
|
import eu.kanade.tachiyomi.network.asObservableSuccess
|
||||||
import eu.kanade.tachiyomi.source.model.Filter
|
import eu.kanade.tachiyomi.source.model.Filter
|
||||||
import eu.kanade.tachiyomi.source.model.FilterList
|
import eu.kanade.tachiyomi.source.model.FilterList
|
||||||
import eu.kanade.tachiyomi.source.model.MangasPage
|
import eu.kanade.tachiyomi.source.model.MangasPage
|
||||||
|
@ -24,6 +25,7 @@ import okhttp3.OkHttpClient
|
||||||
import okhttp3.Request
|
import okhttp3.Request
|
||||||
import okhttp3.Response
|
import okhttp3.Response
|
||||||
import org.jsoup.nodes.Element
|
import org.jsoup.nodes.Element
|
||||||
|
import rx.Observable
|
||||||
|
|
||||||
class MyMangaReaderCMSSource(
|
class MyMangaReaderCMSSource(
|
||||||
override val lang: String,
|
override val lang: String,
|
||||||
|
@ -38,6 +40,15 @@ class MyMangaReaderCMSSource(
|
||||||
private val itemUrlPath = Uri.parse(itemUrl).pathSegments.firstOrNull()
|
private val itemUrlPath = Uri.parse(itemUrl).pathSegments.firstOrNull()
|
||||||
private val parsedBaseUrl = Uri.parse(baseUrl)
|
private val parsedBaseUrl = Uri.parse(baseUrl)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hardcode IDs for sources for which we altered name or lang
|
||||||
|
*/
|
||||||
|
override val id: Long = when (name) {
|
||||||
|
"Comic Space" -> 1847392744200215680
|
||||||
|
"Mangás Yuri" -> 6456162511058446409
|
||||||
|
else -> super.id
|
||||||
|
}
|
||||||
|
|
||||||
override val client: OkHttpClient = network.cloudflareClient.newBuilder()
|
override val client: OkHttpClient = network.cloudflareClient.newBuilder()
|
||||||
.connectTimeout(1, TimeUnit.MINUTES)
|
.connectTimeout(1, TimeUnit.MINUTES)
|
||||||
.readTimeout(1, TimeUnit.MINUTES)
|
.readTimeout(1, TimeUnit.MINUTES)
|
||||||
|
@ -50,6 +61,18 @@ class MyMangaReaderCMSSource(
|
||||||
else -> GET("$baseUrl/filterList?page=$page&sortBy=views&asc=false", headers)
|
else -> GET("$baseUrl/filterList?page=$page&sortBy=views&asc=false", headers)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Search through a list of titles client-side or let the server do it
|
||||||
|
*/
|
||||||
|
override fun fetchSearchManga(page: Int, query: String, filters: FilterList): Observable<MangasPage> {
|
||||||
|
return if (name == "Mangas.pw") {
|
||||||
|
selfSearch(query)
|
||||||
|
} else {
|
||||||
|
super.fetchSearchManga(page, query, filters)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
|
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
|
||||||
// Query overrides everything
|
// Query overrides everything
|
||||||
val url: Uri.Builder
|
val url: Uri.Builder
|
||||||
|
@ -64,6 +87,26 @@ class MyMangaReaderCMSSource(
|
||||||
return GET(url.toString(), headers)
|
return GET(url.toString(), headers)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If the usual search engine isn't available, search through the list of titles with this
|
||||||
|
*/
|
||||||
|
private fun selfSearch(query: String): Observable<MangasPage> {
|
||||||
|
return client.newCall(GET("$baseUrl/changeMangaList?type=text", headers))
|
||||||
|
.asObservableSuccess()
|
||||||
|
.map { response ->
|
||||||
|
val mangas = response.asJsoup().select("ul.manga-list a")
|
||||||
|
.filter { it.text().contains(query, ignoreCase = true) }
|
||||||
|
.map {
|
||||||
|
SManga.create().apply {
|
||||||
|
title = it.text()
|
||||||
|
setUrlWithoutDomain(it.attr("abs:href"))
|
||||||
|
thumbnail_url = coverGuess(null, it.attr("abs:href"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
MangasPage(mangas, false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun latestUpdatesRequest(page: Int) = GET("$baseUrl/latest-release?page=$page", headers)
|
override fun latestUpdatesRequest(page: Int) = GET("$baseUrl/latest-release?page=$page", headers)
|
||||||
|
|
||||||
override fun popularMangaParse(response: Response) = internalMangaParse(response)
|
override fun popularMangaParse(response: Response) = internalMangaParse(response)
|
||||||
|
@ -335,15 +378,19 @@ class MyMangaReaderCMSSource(
|
||||||
/**
|
/**
|
||||||
* Returns the list of filters for the source.
|
* Returns the list of filters for the source.
|
||||||
*/
|
*/
|
||||||
override fun getFilterList() = FilterList(
|
override fun getFilterList(): FilterList {
|
||||||
if (tagMappings != null)
|
return when {
|
||||||
(getInitialFilterList() + UriSelectFilter("Tag",
|
name == "Mangas.pw" -> FilterList()
|
||||||
"tag",
|
tagMappings != null -> {
|
||||||
arrayOf("" to "Any",
|
FilterList(getInitialFilterList() + UriSelectFilter("Tag",
|
||||||
*tagMappings.toTypedArray()
|
"tag",
|
||||||
)))
|
arrayOf("" to "Any",
|
||||||
else getInitialFilterList()
|
*tagMappings.toTypedArray()
|
||||||
)
|
)))
|
||||||
|
}
|
||||||
|
else -> FilterList(getInitialFilterList())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class that creates a select filter. Each entry in the dropdown has a name and a display name.
|
* Class that creates a select filter. Each entry in the dropdown has a name and a display name.
|
||||||
|
|
Loading…
Reference in New Issue