MMRCMS - enhancements (#3203)

This commit is contained in:
Mike 2020-05-17 06:33:49 -04:00 committed by GitHub
parent d890768fe6
commit a1857f5f35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 63 additions and 16 deletions

View File

@ -5,7 +5,7 @@ ext {
appName = 'Tachiyomi: My Manga Reader CMS (Many sources)'
pkgNameSuffix = 'all.mmrcms'
extClass = '.MyMangaReaderCMSSources'
extVersionCode = 38
extVersionCode = 39
libVersion = '1.2'
}

File diff suppressed because one or more lines are too long

View File

@ -229,8 +229,8 @@ class Generator {
Triple("fr", "Scan OP", "https://scan-op.com"),
Triple("id", "Komikid", "https://www.komikid.com"),
Triple("pl", "ToraScans", "http://torascans.pl"),
Triple("pt", "Comic Space", "https://www.comicspace.com.br"),
Triple("pt", "Mangás Yuri", "https://mangasyuri.net"),
Triple("pt-BR", "Comic Space", "https://www.comicspace.com.br"),
Triple("pt-BR", "Mangás Yuri", "https://mangasyuri.net"),
Triple("pl", "Dracaena", "https://dracaena.webd.pl/czytnik"),
Triple("pl", "Nikushima", "http://azbivo.webd.pro"),
Triple("tr", "MangaHanta", "http://mangahanta.com"),

View File

@ -8,6 +8,7 @@ import com.github.salomonbrys.kotson.get
import com.github.salomonbrys.kotson.string
import com.google.gson.JsonParser
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.FilterList
import eu.kanade.tachiyomi.source.model.MangasPage
@ -24,6 +25,7 @@ import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.Response
import org.jsoup.nodes.Element
import rx.Observable
class MyMangaReaderCMSSource(
override val lang: String,
@ -38,6 +40,15 @@ class MyMangaReaderCMSSource(
private val itemUrlPath = Uri.parse(itemUrl).pathSegments.firstOrNull()
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()
.connectTimeout(1, TimeUnit.MINUTES)
.readTimeout(1, TimeUnit.MINUTES)
@ -50,6 +61,18 @@ class MyMangaReaderCMSSource(
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 {
// Query overrides everything
val url: Uri.Builder
@ -64,6 +87,26 @@ class MyMangaReaderCMSSource(
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 popularMangaParse(response: Response) = internalMangaParse(response)
@ -335,15 +378,19 @@ class MyMangaReaderCMSSource(
/**
* Returns the list of filters for the source.
*/
override fun getFilterList() = FilterList(
if (tagMappings != null)
(getInitialFilterList() + UriSelectFilter("Tag",
"tag",
arrayOf("" to "Any",
*tagMappings.toTypedArray()
)))
else getInitialFilterList()
)
override fun getFilterList(): FilterList {
return when {
name == "Mangas.pw" -> FilterList()
tagMappings != null -> {
FilterList(getInitialFilterList() + UriSelectFilter("Tag",
"tag",
arrayOf("" to "Any",
*tagMappings.toTypedArray()
)))
}
else -> FilterList(getInitialFilterList())
}
}
/**
* Class that creates a select filter. Each entry in the dropdown has a name and a display name.