Bilibili: Show paid chapters in chapter list (#18437)
* Bilibili: Show paid chapters in chapter list * lint
This commit is contained in:
parent
7eb7c2567a
commit
8c8a015803
|
@ -123,12 +123,7 @@ abstract class BilibiliComics(lang: String) : Bilibili(
|
||||||
val userEpisodesResponse = client.newCall(userEpisodesRequest).execute()
|
val userEpisodesResponse = client.newCall(userEpisodesRequest).execute()
|
||||||
val unlockedEpisodes = userEpisodesParse(userEpisodesResponse)
|
val unlockedEpisodes = userEpisodesParse(userEpisodesResponse)
|
||||||
|
|
||||||
return comic.episodeList
|
return comic.episodeList.map { ep -> chapterFromObject(ep, comic.id, isUnlocked = ep.id in unlockedEpisodes) }
|
||||||
.filter { episode ->
|
|
||||||
(episode.payMode == 0 && episode.payGold == 0) ||
|
|
||||||
episode.id in unlockedEpisodes
|
|
||||||
}
|
|
||||||
.map { ep -> chapterFromObject(ep, comic.id) }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun userEpisodesRequest(comicId: Int): Request {
|
private fun userEpisodesRequest(comicId: Int): Request {
|
||||||
|
|
|
@ -204,7 +204,7 @@ abstract class Bilibili(
|
||||||
|
|
||||||
title = comic.title
|
title = comic.title
|
||||||
author = comic.authorName.joinToString()
|
author = comic.authorName.joinToString()
|
||||||
genre = comic.genres(intl.pricePaid, EMOJI_LOCKED).joinToString()
|
genre = comic.styles.joinToString()
|
||||||
status = when {
|
status = when {
|
||||||
comic.isFinish == 1 -> SManga.COMPLETED
|
comic.isFinish == 1 -> SManga.COMPLETED
|
||||||
comic.isOnHiatus -> SManga.ON_HIATUS
|
comic.isOnHiatus -> SManga.ON_HIATUS
|
||||||
|
@ -215,11 +215,10 @@ abstract class Bilibili(
|
||||||
append("${intl.hasPaidChaptersWarning(comic.paidChaptersCount)}\n\n")
|
append("${intl.hasPaidChaptersWarning(comic.paidChaptersCount)}\n\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
append("${comic.classicLines}\n\n")
|
append(comic.classicLines)
|
||||||
append("${intl.informationTitle}:")
|
|
||||||
append("\n• ${intl.totalChapterCount}: ${intl.localize(comic.episodeList.size)}")
|
|
||||||
|
|
||||||
if (comic.updateWeekdays.isNotEmpty() && status == SManga.ONGOING) {
|
if (comic.updateWeekdays.isNotEmpty() && status == SManga.ONGOING) {
|
||||||
|
append("\n\n${intl.informationTitle}:")
|
||||||
append("\n• ${intl.getUpdateDays(comic.updateWeekdays)}")
|
append("\n• ${intl.getUpdateDays(comic.updateWeekdays)}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -237,13 +236,21 @@ abstract class Bilibili(
|
||||||
return emptyList()
|
return emptyList()
|
||||||
}
|
}
|
||||||
|
|
||||||
return result.data!!.episodeList
|
return result.data!!.episodeList.map { ep -> chapterFromObject(ep, result.data.id) }
|
||||||
.filter { episode -> episode.payMode == 0 && episode.payGold == 0 }
|
|
||||||
.map { ep -> chapterFromObject(ep, result.data.id) }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected open fun chapterFromObject(episode: BilibiliEpisodeDto, comicId: Int): SChapter = SChapter.create().apply {
|
protected open fun chapterFromObject(episode: BilibiliEpisodeDto, comicId: Int, isUnlocked: Boolean = false): SChapter = SChapter.create().apply {
|
||||||
name = episode.shortTitle.plus(if (episode.title.isNotBlank()) " - ${episode.title}" else "")
|
name = buildString {
|
||||||
|
if (episode.isPaid && !isUnlocked) {
|
||||||
|
append("$EMOJI_LOCKED ")
|
||||||
|
}
|
||||||
|
|
||||||
|
append(episode.shortTitle)
|
||||||
|
|
||||||
|
if (episode.title.isNotBlank()) {
|
||||||
|
append(" - ${episode.title}")
|
||||||
|
}
|
||||||
|
}
|
||||||
date_upload = episode.publicationTime.toDate()
|
date_upload = episode.publicationTime.toDate()
|
||||||
url = "/mc$comicId/${episode.id}"
|
url = "/mc$comicId/${episode.id}"
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,10 +34,7 @@ data class BilibiliComicDto(
|
||||||
get() = paidChaptersCount > 0
|
get() = paidChaptersCount > 0
|
||||||
|
|
||||||
val paidChaptersCount: Int
|
val paidChaptersCount: Int
|
||||||
get() = episodeList.filter { episode -> episode.payMode == 1 && episode.payGold > 0 }.size
|
get() = episodeList.filter { it.isPaid }.size
|
||||||
|
|
||||||
fun genres(paidLabel: String, emoji: String): List<String> =
|
|
||||||
(if (hasPaidChapters) listOf("$emoji $paidLabel") else emptyList()) + styles
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
|
@ -50,7 +47,9 @@ data class BilibiliEpisodeDto(
|
||||||
@SerialName("pub_time") val publicationTime: String,
|
@SerialName("pub_time") val publicationTime: String,
|
||||||
@SerialName("short_title") val shortTitle: String,
|
@SerialName("short_title") val shortTitle: String,
|
||||||
val title: String,
|
val title: String,
|
||||||
)
|
) {
|
||||||
|
val isPaid = payMode == 1 && payGold > 0
|
||||||
|
}
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class BilibiliReader(
|
data class BilibiliReader(
|
||||||
|
|
|
@ -10,7 +10,7 @@ class BilibiliGenerator : ThemeSourceGenerator {
|
||||||
|
|
||||||
override val themeClass = "Bilibili"
|
override val themeClass = "Bilibili"
|
||||||
|
|
||||||
override val baseVersionCode: Int = 8
|
override val baseVersionCode: Int = 9
|
||||||
|
|
||||||
override val sources = listOf(
|
override val sources = listOf(
|
||||||
MultiLang(
|
MultiLang(
|
||||||
|
|
|
@ -54,9 +54,8 @@ class BilibiliIntl(private val lang: String) {
|
||||||
"actualice la lista de capítulos para leerlos."
|
"actualice la lista de capítulos para leerlos."
|
||||||
else ->
|
else ->
|
||||||
"${Bilibili.EMOJI_WARNING} WARNING: This series has ${chapterCount.localized} paid " +
|
"${Bilibili.EMOJI_WARNING} WARNING: This series has ${chapterCount.localized} paid " +
|
||||||
"chapters that were filtered out from the chapter list. If you have already " +
|
"chapters. If you have any unlocked in your account then sign in through WebView " +
|
||||||
"unlocked and have any in your account, sign in through WebView and refresh " +
|
"to be able to read them."
|
||||||
"the chapter list to read them."
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val imageQualityPrefTitle: String = when (lang) {
|
val imageQualityPrefTitle: String = when (lang) {
|
||||||
|
@ -85,6 +84,7 @@ class BilibiliIntl(private val lang: String) {
|
||||||
else -> "Interest"
|
else -> "Interest"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("UNUSED") // In BilibiliManga
|
||||||
val sortPopular: String = when (lang) {
|
val sortPopular: String = when (lang) {
|
||||||
CHINESE, SIMPLIFIED_CHINESE -> "人气推荐"
|
CHINESE, SIMPLIFIED_CHINESE -> "人气推荐"
|
||||||
INDONESIAN -> "Populer"
|
INDONESIAN -> "Populer"
|
||||||
|
@ -101,11 +101,13 @@ class BilibiliIntl(private val lang: String) {
|
||||||
else -> "Updated"
|
else -> "Updated"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("UNUSED") // In BilibiliManga
|
||||||
val sortAdded: String = when (lang) {
|
val sortAdded: String = when (lang) {
|
||||||
CHINESE, SIMPLIFIED_CHINESE -> "上架时间"
|
CHINESE, SIMPLIFIED_CHINESE -> "上架时间"
|
||||||
else -> "Added"
|
else -> "Added"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("UNUSED") // In BilibiliManga
|
||||||
val sortFollowers: String = when (lang) {
|
val sortFollowers: String = when (lang) {
|
||||||
CHINESE, SIMPLIFIED_CHINESE -> "追漫人数"
|
CHINESE, SIMPLIFIED_CHINESE -> "追漫人数"
|
||||||
else -> "Followers count"
|
else -> "Followers count"
|
||||||
|
@ -135,6 +137,7 @@ class BilibiliIntl(private val lang: String) {
|
||||||
else -> "Completed"
|
else -> "Completed"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("UNUSED") // In BilibiliManga
|
||||||
val priceAll: String = when (lang) {
|
val priceAll: String = when (lang) {
|
||||||
CHINESE, SIMPLIFIED_CHINESE -> "全部"
|
CHINESE, SIMPLIFIED_CHINESE -> "全部"
|
||||||
INDONESIAN -> "Semua"
|
INDONESIAN -> "Semua"
|
||||||
|
@ -142,6 +145,7 @@ class BilibiliIntl(private val lang: String) {
|
||||||
else -> "All"
|
else -> "All"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("UNUSED") // In BilibiliManga
|
||||||
val priceFree: String = when (lang) {
|
val priceFree: String = when (lang) {
|
||||||
CHINESE, SIMPLIFIED_CHINESE -> "免费"
|
CHINESE, SIMPLIFIED_CHINESE -> "免费"
|
||||||
INDONESIAN -> "Bebas"
|
INDONESIAN -> "Bebas"
|
||||||
|
@ -149,6 +153,7 @@ class BilibiliIntl(private val lang: String) {
|
||||||
else -> "Free"
|
else -> "Free"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("UNUSED") // In BilibiliManga
|
||||||
val pricePaid: String = when (lang) {
|
val pricePaid: String = when (lang) {
|
||||||
CHINESE, SIMPLIFIED_CHINESE -> "付费"
|
CHINESE, SIMPLIFIED_CHINESE -> "付费"
|
||||||
INDONESIAN -> "Dibayar"
|
INDONESIAN -> "Dibayar"
|
||||||
|
@ -156,17 +161,20 @@ class BilibiliIntl(private val lang: String) {
|
||||||
else -> "Paid"
|
else -> "Paid"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("UNUSED") // In BilibiliManga
|
||||||
val priceWaitForFree: String = when (lang) {
|
val priceWaitForFree: String = when (lang) {
|
||||||
CHINESE, SIMPLIFIED_CHINESE -> "等就免费"
|
CHINESE, SIMPLIFIED_CHINESE -> "等就免费"
|
||||||
else -> "Wait for free"
|
else -> "Wait for free"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("UNUSED") // In BilibiliComics
|
||||||
val failedToRefreshToken: String = when (lang) {
|
val failedToRefreshToken: String = when (lang) {
|
||||||
CHINESE, SIMPLIFIED_CHINESE -> "无法刷新令牌。请打开 WebView 修正错误。"
|
CHINESE, SIMPLIFIED_CHINESE -> "无法刷新令牌。请打开 WebView 修正错误。"
|
||||||
SPANISH -> "Error al actualizar el token. Abra el WebView para solucionar este error."
|
SPANISH -> "Error al actualizar el token. Abra el WebView para solucionar este error."
|
||||||
else -> "Failed to refresh the token. Open the WebView to fix this error."
|
else -> "Failed to refresh the token. Open the WebView to fix this error."
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("UNUSED") // In BilibiliComics
|
||||||
val failedToGetCredential: String = when (lang) {
|
val failedToGetCredential: String = when (lang) {
|
||||||
CHINESE, SIMPLIFIED_CHINESE -> "无法获取阅读章节所需的凭证。"
|
CHINESE, SIMPLIFIED_CHINESE -> "无法获取阅读章节所需的凭证。"
|
||||||
SPANISH -> "Erro al obtener la credencial para leer el capítulo."
|
SPANISH -> "Erro al obtener la credencial para leer el capítulo."
|
||||||
|
@ -179,12 +187,6 @@ class BilibiliIntl(private val lang: String) {
|
||||||
else -> "Information"
|
else -> "Information"
|
||||||
}
|
}
|
||||||
|
|
||||||
val totalChapterCount: String = when (lang) {
|
|
||||||
CHINESE, SIMPLIFIED_CHINESE -> "章节总数"
|
|
||||||
SPANISH -> "Número total de capítulos"
|
|
||||||
else -> "Total chapter count"
|
|
||||||
}
|
|
||||||
|
|
||||||
private val updatesDaily: String = when (lang) {
|
private val updatesDaily: String = when (lang) {
|
||||||
CHINESE, SIMPLIFIED_CHINESE -> "每日更新"
|
CHINESE, SIMPLIFIED_CHINESE -> "每日更新"
|
||||||
SPANISH -> "Actualizaciones diarias"
|
SPANISH -> "Actualizaciones diarias"
|
||||||
|
@ -208,17 +210,17 @@ class BilibiliIntl(private val lang: String) {
|
||||||
return updatesEvery(days)
|
return updatesEvery(days)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun localize(value: Int) = value.localized
|
|
||||||
|
|
||||||
private val Int.localized: String
|
private val Int.localized: String
|
||||||
get() = numberFormat.format(this)
|
get() = numberFormat.format(this)
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val CHINESE = "zh"
|
const val CHINESE = "zh"
|
||||||
const val ENGLISH = "en"
|
|
||||||
const val INDONESIAN = "id"
|
const val INDONESIAN = "id"
|
||||||
const val SIMPLIFIED_CHINESE = "zh-Hans"
|
const val SIMPLIFIED_CHINESE = "zh-Hans"
|
||||||
const val SPANISH = "es"
|
const val SPANISH = "es"
|
||||||
const val FRENCH = "fr"
|
const val FRENCH = "fr"
|
||||||
|
|
||||||
|
@Suppress("UNUSED") // In BilibiliComics
|
||||||
|
const val ENGLISH = "en"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue