Bilibili Manga: Read unlocked chapters (#11913)
* Bilibili Manga: Read unlocked chapters * Bilibili: Update Chinese strings
This commit is contained in:
parent
cb9a898787
commit
e3f0168d75
|
@ -2,10 +2,14 @@ package eu.kanade.tachiyomi.extension.zh.bilibilimanga
|
|||
|
||||
import eu.kanade.tachiyomi.lib.ratelimit.SpecificHostRateLimitInterceptor
|
||||
import eu.kanade.tachiyomi.multisrc.bilibili.Bilibili
|
||||
import eu.kanade.tachiyomi.multisrc.bilibili.BilibiliComicDto
|
||||
import eu.kanade.tachiyomi.multisrc.bilibili.BilibiliIntl
|
||||
import eu.kanade.tachiyomi.multisrc.bilibili.BilibiliTag
|
||||
import eu.kanade.tachiyomi.source.model.SChapter
|
||||
import okhttp3.Headers
|
||||
import okhttp3.HttpUrl.Companion.toHttpUrl
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.Response
|
||||
|
||||
class BilibiliManga : Bilibili(
|
||||
"哔哩哔哩漫画",
|
||||
|
@ -22,6 +26,22 @@ class BilibiliManga : Bilibili(
|
|||
.addInterceptor(SpecificHostRateLimitInterceptor(COVER_CDN_URL.toHttpUrl(), 2))
|
||||
.build()
|
||||
|
||||
override fun headersBuilder() = Headers.Builder().apply {
|
||||
add("User-Agent", DEFAULT_USER_AGENT)
|
||||
}
|
||||
|
||||
override fun chapterListParse(response: Response): List<SChapter> {
|
||||
val result = response.parseAs<BilibiliComicDto>()
|
||||
|
||||
if (result.code != 0) {
|
||||
return emptyList()
|
||||
}
|
||||
|
||||
return result.data!!.episodeList
|
||||
.filter { episode -> episode.isInFree || !episode.isLocked }
|
||||
.map { ep -> chapterFromObject(ep, result.data.id) }
|
||||
}
|
||||
|
||||
override val defaultPopularSort: Int = 0
|
||||
|
||||
override val defaultLatestSort: Int = 1
|
||||
|
@ -62,4 +82,8 @@ class BilibiliManga : Bilibili(
|
|||
BilibiliTag("韩国", 6),
|
||||
BilibiliTag("其他", 5),
|
||||
)
|
||||
|
||||
companion object {
|
||||
const val DEFAULT_USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36 Edg/88.0.705.63"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,6 +38,8 @@ data class BilibiliComicDto(
|
|||
@Serializable
|
||||
data class BilibiliEpisodeDto(
|
||||
val id: Int,
|
||||
@SerialName("is_in_free") val isInFree: Boolean,
|
||||
@SerialName("is_locked") val isLocked: Boolean,
|
||||
@SerialName("pay_gold") val payGold: Int,
|
||||
@SerialName("pay_mode") val payMode: Int,
|
||||
@SerialName("pub_time") val publicationTime: String,
|
||||
|
|
|
@ -14,7 +14,7 @@ class BilibiliGenerator : ThemeSourceGenerator {
|
|||
|
||||
override val sources = listOf(
|
||||
MultiLang("BILIBILI COMICS", "https://www.bilibilicomics.com", listOf("en", "zh-Hans", "id"), className = "BilibiliComicsFactory"),
|
||||
SingleLang("BILIBILI MANGA", "https://manga.bilibili.com", "zh-Hans", className = "BilibiliManga", sourceName = "哔哩哔哩漫画", overrideVersionCode = 1)
|
||||
SingleLang("BILIBILI MANGA", "https://manga.bilibili.com", "zh-Hans", className = "BilibiliManga", sourceName = "哔哩哔哩漫画", overrideVersionCode = 2)
|
||||
)
|
||||
|
||||
companion object {
|
||||
|
|
|
@ -36,7 +36,8 @@ class BilibiliIntl(lang: String) {
|
|||
|
||||
val hasPaidChaptersWarning: String = when (lang) {
|
||||
CHINESE, SIMPLIFIED_CHINESE ->
|
||||
"${Bilibili.EMOJI_WARNING} 此漫画的付费章节已从章节列表中过滤,暂时请用网页端或官方app阅读。"
|
||||
"${Bilibili.EMOJI_WARNING} 此漫画的付费章节已从章节列表中过滤。如果您已购买章节,请在 WebView " +
|
||||
"登录并刷新章节列表以阅读已购章节。"
|
||||
else ->
|
||||
"${Bilibili.EMOJI_WARNING} WARNING: This series has paid chapters that were filtered " +
|
||||
"out from the chapter list. If you have already bought and have any in your " +
|
||||
|
@ -129,11 +130,15 @@ class BilibiliIntl(lang: String) {
|
|||
else -> "Wait for free"
|
||||
}
|
||||
|
||||
// TODO: Add Chinese translation.
|
||||
val failedToRefreshToken: String = "Failed to refresh the token. Open the WebView to fix this error."
|
||||
val failedToRefreshToken: String = when (lang) {
|
||||
CHINESE, SIMPLIFIED_CHINESE -> "无法刷新令牌。请打开 WebView 修正错误。"
|
||||
else -> "Failed to refresh the token. Open the WebView to fix this error."
|
||||
}
|
||||
|
||||
// TODO: Add Chinese translation.
|
||||
val failedToGetCredential: String = "Failed to get the credential to read the chapter."
|
||||
val failedToGetCredential: String = when (lang) {
|
||||
CHINESE, SIMPLIFIED_CHINESE -> "无法获取阅读章节所需的凭证。"
|
||||
else -> "Failed to get the credential to read the chapter."
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val CHINESE = "zh"
|
||||
|
|
Loading…
Reference in New Issue