Add a new filter and fix missing Bilibili chapters in MD. (#10253)
This commit is contained in:
parent
190e1410e3
commit
aa98af8907
|
@ -6,7 +6,7 @@ ext {
|
|||
extName = 'MangaDex'
|
||||
pkgNameSuffix = 'all.mangadex'
|
||||
extClass = '.MangaDexFactory'
|
||||
extVersionCode = 148
|
||||
extVersionCode = 149
|
||||
isNsfw = true
|
||||
}
|
||||
|
||||
|
|
|
@ -241,7 +241,7 @@ abstract class MangaDex(override val lang: String, val dexLang: String) :
|
|||
}
|
||||
}
|
||||
|
||||
val finalUrl = helper.mdFilters.addFiltersToUrl(tempUrl, filters)
|
||||
val finalUrl = helper.mdFilters.addFiltersToUrl(tempUrl, filters, dexLang)
|
||||
|
||||
return GET(finalUrl, headers, CacheControl.FORCE_NETWORK)
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ class MangaDexFilters {
|
|||
TagList(getTags()),
|
||||
TagInclusionMode(),
|
||||
TagExclusionMode(),
|
||||
HasAvailableChaptersFilter(),
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -200,7 +201,9 @@ class MangaDexFilters {
|
|||
|
||||
class SortFilter(sortables: Array<String>) : Filter.Sort("Sort", sortables, Selection(2, false))
|
||||
|
||||
internal fun addFiltersToUrl(url: HttpUrl.Builder, filters: FilterList): String {
|
||||
private class HasAvailableChaptersFilter : Filter.CheckBox("Has available chapters")
|
||||
|
||||
internal fun addFiltersToUrl(url: HttpUrl.Builder, filters: FilterList, dexLang: String): String {
|
||||
url.apply {
|
||||
// add filters
|
||||
filters.forEach { filter ->
|
||||
|
@ -287,6 +290,12 @@ class MangaDexFilters {
|
|||
filter.values[filter.state].toUpperCase(Locale.US)
|
||||
)
|
||||
}
|
||||
is HasAvailableChaptersFilter -> {
|
||||
if (filter.state) {
|
||||
addQueryParameter("hasAvailableChapters", "true")
|
||||
addQueryParameter("availableTranslatedLanguage[]", dexLang)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -112,6 +112,8 @@ class MangaDexHelper() {
|
|||
val USE_CACHE = CacheControl.Builder()
|
||||
.maxStale(Integer.MAX_VALUE, TimeUnit.SECONDS)
|
||||
.build()
|
||||
|
||||
private const val BILIBILI_URL = "bilibilicomics.com"
|
||||
}
|
||||
|
||||
// Check the token map to see if the md@home host is still valid
|
||||
|
@ -326,7 +328,17 @@ class MangaDexHelper() {
|
|||
}
|
||||
}
|
||||
|
||||
if (attr.externalUrl != null) {
|
||||
if (!attr.externalUrl.isNullOrEmpty() && !attr.externalUrl.contains(BILIBILI_URL)) {
|
||||
return null
|
||||
}
|
||||
|
||||
// Bilibili special check. If it's a Bilibili chapter and the
|
||||
// publishAt date is < now, it can be read on MD.
|
||||
if (
|
||||
!attr.externalUrl.isNullOrEmpty() &&
|
||||
attr.externalUrl.contains(BILIBILI_URL) &&
|
||||
parseDate(attr.publishAt) >= Date().time
|
||||
) {
|
||||
return null
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue