Skip to content

Commit

Permalink
NetTruyen/NhatTruyen: avoid return un-relevant searching results (#1338)
Browse files Browse the repository at this point in the history
* NetTruyen/NhatTruyen: avoid return catalog page when searching return empty

They redirect back to catalog page if searching query is not found.
That makes both sites always return un-relevant results when searching should have returned empty.

* fix overrideVersion
  • Loading branch information
cuong-tran authored Feb 17, 2024
1 parent edd5eec commit 19ae010
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ abstract class WPComics(
// Search

protected open val searchPath = "tim-truyen"
protected open val queryParam = "keyword"

protected open fun String.replaceSearchPath() = this

Expand All @@ -91,7 +92,7 @@ abstract class WPComics(
}

url.apply {
addQueryParameter("keyword", query)
addQueryParameter(queryParam, query)
addQueryParameter("page", page.toString())
addQueryParameter("sort", "0")
}
Expand Down
2 changes: 1 addition & 1 deletion src/vi/nettruyen/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ext {
extClass = '.NetTruyen'
themePkg = 'wpcomics'
baseUrl = 'https://www.nettruyenss.com'
overrideVersionCode = 22
overrideVersionCode = 23
}

apply from: "$rootDir/common.gradle"
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
package eu.kanade.tachiyomi.extension.vi.nettruyen

import eu.kanade.tachiyomi.multisrc.wpcomics.WPComics
import eu.kanade.tachiyomi.source.model.MangasPage
import okhttp3.Response
import java.text.SimpleDateFormat
import java.util.Locale

class NetTruyen : WPComics("NetTruyen", "https://www.nettruyenss.com", "vi", SimpleDateFormat("dd/MM/yy", Locale.getDefault()), null) {
override fun String.replaceSearchPath() = replace("/$searchPath?status=2&", "/truyen-full?")

/**
* NetTruyen/NhatTruyen redirect back to catalog page if searching query is not found.
* That makes both sites always return un-relevant results when searching should return empty.
*/
override fun searchMangaParse(response: Response): MangasPage {
if (response.request.url.queryParameter(name = queryParam) == null) {
return MangasPage(mangas = listOf(), hasNextPage = false)
}
return super.searchMangaParse(response)
}

override fun getGenreList(): Array<Pair<String?, String>> = arrayOf(
null to "Tất cả",
"action-95" to "Action",
Expand Down
2 changes: 1 addition & 1 deletion src/vi/nhattruyen/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ext {
extClass = '.NhatTruyen'
themePkg = 'wpcomics'
baseUrl = 'https://nhattruyento.com'
overrideVersionCode = 14
overrideVersionCode = 15
}

apply from: "$rootDir/common.gradle"
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
package eu.kanade.tachiyomi.extension.vi.nhattruyen

import eu.kanade.tachiyomi.multisrc.wpcomics.WPComics
import eu.kanade.tachiyomi.source.model.MangasPage
import okhttp3.Response
import java.text.SimpleDateFormat
import java.util.Locale

class NhatTruyen : WPComics("NhatTruyen", "https://nhattruyento.com", "vi", SimpleDateFormat("dd/MM/yy", Locale.getDefault()), null) {
override val searchPath = "the-loai"

/**
* NetTruyen/NhatTruyen redirect back to catalog page if searching query is not found.
* That makes both sites always return un-relevant results when searching should return empty.
*/
override fun searchMangaParse(response: Response): MangasPage {
if (response.request.url.queryParameter(name = queryParam) == null) {
return MangasPage(mangas = listOf(), hasNextPage = false)
}
return super.searchMangaParse(response)
}

override fun getGenreList(): Array<Pair<String?, String>> = arrayOf(
null to "Tất cả",
"action" to "Action",
Expand Down

0 comments on commit 19ae010

Please sign in to comment.