Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import kotlin.time.Duration
import kotlin.time.Duration.Companion.seconds

/**
* 数据源选择器 (播放页面点击 "数据源" 按钮弹出的) 的设置
* 数据源选择器 (播放页面点击 "數據源" 按钮弹出的) 的设置
* @see MediaPreference
*/
@Serializable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ private val nameCnMap by lazy(LazyThreadSafetyMode.PUBLICATION) {
put(PersonPosition.CastingDirector.id, "演員監督")
put(PersonPosition.ChiefProducer.id, "總製片")
put(PersonPosition.CoProducer.id, "聯合製片人")
put(PersonPosition.DialogueEditing.id, "台詞編輯")
put(PersonPosition.DialogueEditing.id, "臺詞編輯")
put(PersonPosition.PostProductionAssistant.id, "後期製片協調")
put(PersonPosition.ProductionAssistant.id, "製作助手")
put(PersonPosition.ProductionCoordination.id, "製作協調")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ class RelatedSubjectInfo(

enum class SubjectRelation {
/**
* 对应 Bangumi "续集", 包括第二季, 外传
* 对应 Bangumi "續集", 包括第二季, 外传
*/
SEQUEL,

/**
* 对应 Bangumi "前传"
* 对应 Bangumi "前傳"
*/
PREQUEL,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ fun createTestSubjectCollection(
): SubjectCollectionInfo {
val subjectInfo = SubjectInfo.Empty.copy(
subjectId = id,
nameCn = "中文条目名称",
nameCn = "中文條目名稱",
name = "Subject Name",
nsfw = Random.nextBoolean(),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ sealed class CanonicalTagKind(val values: List<String>) {
*/
@Immutable
data object Category : CanonicalTagKind(
listOf("短片", "剧场版", "TV", "OVA", "MV", "CM", "WEB", "PV", "动态漫画"),
listOf("短片", "劇場版", "TV", "OVA", "MV", "CM", "WEB", "PV", "動態漫畫"),
)

/**
* 来源
*/
@Immutable
data object Source : CanonicalTagKind(
listOf("原创", "漫画改", "游戏改", "小说改"),
listOf("原創", "漫畫改", "遊戲改", "小說改"),
)

/**
Expand All @@ -69,9 +69,9 @@ sealed class CanonicalTagKind(val values: List<String>) {
@Immutable
data object Genre : CanonicalTagKind(
listOf(
"科幻", "喜剧", "百合", "校园", "惊悚", "后宫", "机战", "悬疑", "恋爱", "奇幻",
"推理", "运动", "耽美", "音乐", "战斗", "冒险", "萌系", "穿越", "玄幻", "乙女",
"恐怖", "历史", "日常", "剧情", "武侠", "美食", "职场",
"科幻", "喜劇", "百合", "校園", "驚悚", "後宮", "機戰", "懸疑", "戀愛", "奇幻",
"推理", "運動", "耽美", "音樂", "戰鬥", "冒險", "萌系", "穿越", "玄幻", "乙女",
"恐怖", "歷史", "日常", "劇情", "武俠", "美食", "職場",
),
)

Expand All @@ -81,8 +81,8 @@ sealed class CanonicalTagKind(val values: List<String>) {
@Immutable
data object Region : CanonicalTagKind(
listOf(
"欧美", "日本", "美国", "中国", "法国", "韩国", "俄罗斯", "英国",
"苏联", "香港", "捷克", "台湾",
"歐美", "日本", "美國", "中國", "法國", "韓國", "俄羅斯", "英國",
"蘇聯", "香港", "捷克", "臺灣",
),
)

Expand All @@ -108,8 +108,8 @@ sealed class CanonicalTagKind(val values: List<String>) {
@Immutable
data object Setting : CanonicalTagKind(
listOf(
"魔法少女", "超能力", "偶像", "网游", "末世", "乐队",
"赛博朋克", "宫廷", "都市", "异世界", "性转", "龙傲天", "凤傲天",
"魔法少女", "超能力", "偶像", "網遊", "末世", "樂隊",
"賽博朋克", "宮廷", "都市", "異世界", "性轉", "龍傲天", "鳳傲天",
),
)

Expand All @@ -119,8 +119,8 @@ sealed class CanonicalTagKind(val values: List<String>) {
@Immutable
data object Character : CanonicalTagKind(
listOf(
"制服", "兽耳", "伪娘", "吸血鬼", "妹控", "萝莉", "傲娇", "女仆", "巨乳", "电波",
"动物", "正太", "兄控", "僵尸", "群像", "美少女", "美少年",
"制服", "獸耳", "僞娘", "吸血鬼", "妹控", "蘿莉", "傲嬌", "女僕", "巨乳", "電波",
"動物", "正太", "兄控", "殭屍", "羣像", "美少女", "美少年",
),
)

Expand All @@ -129,15 +129,15 @@ sealed class CanonicalTagKind(val values: List<String>) {
*/
@Immutable
data object Emotion : CanonicalTagKind(
listOf("热血", "治愈", "温情", "催泪", "纯爱", "友情", "致郁"),
listOf("熱血", "治癒", "溫情", "催淚", "純愛", "友情", "致鬱"),
)

/**
* 技术
*/
@Immutable
data object Technology : CanonicalTagKind(
listOf("黑白", "3D", "水墨", "定格", "粘土", "剪纸", "转描", "三渲二"),
listOf("黑白", "3D", "水墨", "定格", "粘土", "剪紙", "轉描", "三渲二"),
)

/**
Expand All @@ -146,8 +146,8 @@ sealed class CanonicalTagKind(val values: List<String>) {
@Immutable
data object Series : CanonicalTagKind(
listOf(
"高达", "东方", "Fate", "空之境界", "柯南", "光之美少女", "哆啦A梦",
"物语系列", "刀剑神域", "进击的巨人",
"高達", "東方", "Fate", "空之境界", "柯南", "光之美少女", "哆啦A夢",
"物語系列", "刀劍神域", "進擊的巨人",
),
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ object BangumiSubjectGraphQLParser {
character = CharacterInfo(
id = characterId,
name = character.getStringOrFail("name"),
nameCn = character.infobox("简体中文名").firstOrNull() ?: "",
nameCn = character.infobox("簡體中文名").firstOrNull() ?: "",
actors = getActors(characterId),
imageMedium = character.getOrFail("images").jsonObjectOrNull?.getStringOrFail("medium") ?: "",
imageLarge = character.getOrFail("images").jsonObjectOrNull?.getStringOrFail("large") ?: "",
Expand Down Expand Up @@ -126,7 +126,7 @@ object BangumiSubjectGraphQLParser {
}

private fun JsonObject.toBatchSubjectDetails(): BatchSubjectDetails {
val completionDate = (this.infobox("播放结束") + this.infobox("放送结束"))
val completionDate = (this.infobox("播放結束") + this.infobox("放送結束"))
.firstOrNull()
?.let {
PackedDate.parseFromDate(
Expand Down Expand Up @@ -155,7 +155,7 @@ object BangumiSubjectGraphQLParser {
LightRelatedCharacterInfo(
id = characterId,
name = character.getStringOrFail("name"),
nameCn = character.infobox("简体中文名").firstOrNull() ?: "",
nameCn = character.infobox("簡體中文名").firstOrNull() ?: "",
role = role,
)
}
Expand Down Expand Up @@ -190,7 +190,7 @@ object BangumiSubjectGraphQLParser {
obj.getIntOrFail("count"),
)
},
aliases = infobox("别名").filter { it.isNotEmpty() }.toList(),
aliases = infobox("別名").filter { it.isNotEmpty() }.toList(),
ratingInfo = getOrFail("rating").jsonObject.let { rating ->
RatingInfo(
rank = rating.getIntOrFail("rank"),
Expand Down Expand Up @@ -253,13 +253,13 @@ object BangumiSubjectGraphQLParser {
id = person.getIntOrFail("id"),
name = person.getStringOrFail("name"),
type = PersonType.fromId(person.getIntOrFail("type")),
// careers = person.infobox("职业").map { PersonCareer.valueOf(it) }.toList(),
// careers = person.infobox("職業").map { PersonCareer.valueOf(it) }.toList(),
careers = emptyList(),
imageLarge = person["images"]?.jsonObjectOrNull?.getStringOrFail("large") ?: "",
imageMedium = person["images"]?.jsonObjectOrNull?.getStringOrFail("medium") ?: "",
summary = person.getString("summary") ?: "",
locked = person.getIntOrFail("lock") == 1,
nameCn = person.infobox("简体中文名").firstOrNull() ?: "",
nameCn = person.infobox("簡體中文名").firstOrNull() ?: "",
)

inline fun forEachCharacter(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import me.him188.ani.utils.platform.collections.mapToIntList
import kotlin.coroutines.CoroutineContext

data class BangumiSearchFilters(
val tags: List<String>? = null, // "童年", "原创"
val tags: List<String>? = null, // "童年", "原創"
val airDates: List<String>? = null, // YYYY-MM-DD
val ratings: List<String>? = null, // ">=6", "<8"
val ranks: List<String>? = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class FollowedSubjectsRepository(
else -> e
}

logger.error(displayE) { """Failed to update recently updated subject collections due to ${e}, ignoring. 这只会导致探索页的继续观看栏目可能显示旧结果. """ }
logger.error(displayE) { """Failed to update recently updated subject collections due to ${e}, ignoring. 這隻會導致探索頁的繼續觀看欄目可能顯示舊結果. """ }
}

// 先查询完成 (插入数据库) 再返回 flow 去查数据库. 前端会展示 placeholder 所以延迟没问题.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ class SubjectCollectionRepositoryImpl(
try {
withContext(defaultDispatcher) {
// 只允许同时一个请求. 防止多个请求浪费带宽.
// 一般来说不会有多个请求. 最常见的并行请求可能是用户刚刚打开 APP 进入探索页自动刷新"继续观看"栏目, 在刷新还在进行时切换到收藏页触发自动刷新.
// 一般来说不会有多个请求. 最常见的并行请求可能是用户刚刚打开 APP 进入探索页自动刷新"繼續觀看"栏目, 在刷新还在进行时切换到收藏页触发自动刷新.
updateRecentlyUpdatedSubjectCollectionsMutex.withLock {
fetchAndSaveSubjectCollectionsWithEpisodes(type, limit, offset)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ class SubjectSearchRepository(
// }
//
// /*
// (findInfoboxValue("播放结束") ?: findInfoboxValue("放送结束"))
// (findInfoboxValue("播放結束") ?: findInfoboxValue("放送結束"))
// ?.let {
// PackedDate.parseFromDate(
// it.replace('年', '-')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class CreateMediaFetchSelectBundleFlowUseCaseImpl(
val fetchRequestFlow: Flow<MediaFetchSession?> = bundleDistinct
// 为什么要 `filterNotNull`:
// 如果本地有缓存, 我们会优先读取缓存, bundle 会不是 null. 如果缓存有过期, 此时会同时发起网络查询.
// 如果加载发生网络错误, 然后用户点击 "重试", bundle 会变为 `null`.
// 如果加载发生网络错误, 然后用户点击 "重試", bundle 会变为 `null`.
// 然而即使进行了网络查询, 新的数据很有可能跟旧的数据是一样的, 就没有必要重新查询.
// 所以我们总是等待一个 not null SubjectEpisodeInfoBundle 比较.
.filterNotNull()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ class HttpMediaCacheEngine(
if (allowedAbsolute.none {
myPath.startsWith(it)
}) {
logger.warn { "本地 WEB 缓存文件未找到匹配的 MediaCache, 已释放 ${save.inSystem.actualSize().bytes}: ${save.inSystem.absolutePath}" }
logger.warn { "本地 WEB 緩存文件未找到匹配的 MediaCache, 已釋放 ${save.inSystem.actualSize().bytes}: ${save.inSystem.absolutePath}" }
SystemFileSystem.deleteRecursively(save)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ interface MediaCacheEngine {
fun supports(media: Media): Boolean

/**
* "挂载" 到 composable 中, 以便进行需要虚拟 UI 的操作, 例如 WebView
* "掛載" 到 composable 中, 以便进行需要虚拟 UI 的操作, 例如 WebView
*/
@Composable
fun ComposeContent() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,21 +95,21 @@ object AlwaysUseTorrentEngineAccess : TorrentEngineAccess {
}

@RequiresOptIn(
message = "若在 block 中调用了需要 TorrentEngine 长期可用的方法, " +
"请确保在此函数返回后 TorrentEngine 一定可用 " +
"(例如在其中一个实现 TorrentServiceConnectionManager 中, " +
"使 checkIfAllTorrentMediaCacheCompleted false, 也就是创建了 BT 媒体缓存), " +
"否则会导致错误的 useEngine 状态被 emit. " +
"调用此函数需要有明确的注释来说明必须调用此函数的原因和合理性, 方便后人理解这里的逻辑",
message = "若在 block 中調用了需要 TorrentEngine 長期可用的方法, " +
"請確保在此函數返回後 TorrentEngine 一定可用 " +
"(例如在其中一個實現 TorrentServiceConnectionManager 中, " +
"使 checkIfAllTorrentMediaCacheCompleted false, 也就是創建了 BT 媒體緩存), " +
"否則會導致錯誤的 useEngine 狀態被 emit. " +
"調用此函數需要有明確的註釋來說明必須調用此函數的原因和合理性, 方便後人理解這裏的邏輯",
level = RequiresOptIn.Level.ERROR,
)
annotation class EnsureTorrentEngineIsAccessible


@RequiresOptIn(
message = "请总是使用 TorrentEngineAccess.withEngineAccessible 来使 TorrentEngine 可用, " +
"除非你能确保请求 TorrentEngine 可用后有对应的 `requestUseEngine(false)` 来释放 TorrentEngine 可用状态. " +
"调用此函数需要有明确的注释来说明必须调用此函数的原因和合理性, 方便后人理解这里的逻辑",
message = "請總是使用 TorrentEngineAccess.withEngineAccessible 來使 TorrentEngine 可用, " +
"除非你能確保請求 TorrentEngine 可用後有對應的 `requestUseEngine(false)` 來釋放 TorrentEngine 可用狀態. " +
"調用此函數需要有明確的註釋來說明必須調用此函數的原因和合理性, 方便後人理解這裏的邏輯",
level = RequiresOptIn.Level.ERROR,
)
annotation class UnsafeTorrentEngineAccessApi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ class TorrentMediaCacheEngine(
val saves = downloader.listSaves()
for (save in saves) {
if (save.absolutePath !in allowedAbsolute) {
logger.warn { "本地种子缓存文件未找到匹配的 MediaCache, 已释放 ${save.actualSize().bytes}: ${save.absolutePath}" }
logger.warn { "本地種子緩存文件未找到匹配的 MediaCache, 已釋放 ${save.actualSize().bytes}: ${save.absolutePath}" }
save.deleteRecursively()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ interface MediaResolver {
fun supports(media: Media): Boolean

/**
* "挂载" 到 composable 中, 以便进行需要虚拟 UI 的操作, 例如 WebView
* "掛載" 到 composable 中, 以便进行需要虚拟 UI 的操作, 例如 WebView
*/
@Composable
fun ComposeContent() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,26 +90,26 @@ import kotlin.coroutines.CoroutineContext
* suspend fun usageExample(mediaSelector: MediaSelector) {
* // 观察过滤后但包含排除原因的候选
* mediaSelector.filteredCandidates.collect { allCandidates ->
* println("所有候选资源(含排除原因): $allCandidates")
* println("所有候選資源(含排除原因): $allCandidates")
* }
*
* // 观察过滤后可用的字幕组选项
* mediaSelector.alliance.available.collect { alliances ->
* println("可选的字幕组列表: $alliances")
* println("可選的字幕組列表: $alliances")
* }
*
* // 如果尚未选择任何资源,尝试自动选择一个符合当前偏好的资源
* val autoSelected = mediaSelector.trySelectDefault()
* if (autoSelected != null) {
* println("已自动选择: ${autoSelected.mediaId}")
* println("已自動選擇: ${autoSelected.mediaId}")
* }
*
* // 用户在 UI 中手动指定某个资源
* val userChosenMedia: Media = /* 由用户在界面中选取 */
* mediaSelector.select(userChosenMedia)
*
* // 最终获取当前选中的资源
* println("当前选中的资源: ${mediaSelector.selected.value}")
* println("當前選中的資源: ${mediaSelector.selected.value}")
* }
* ```
*
Expand Down Expand Up @@ -258,7 +258,7 @@ interface MediaPreferenceItem<T : Any> {
/**
* [userSelected] 与 [defaultSelected] 合并考虑的选择. 不必是 [available] 里面的选项.
*/
val finalSelected: Flow<T?> // 注意, autoEnableLastSelected 依赖 "不必是 [available] 里面的选项" 这个性质.
val finalSelected: Flow<T?> // 注意, autoEnableLastSelected 依赖 "不必是 [available] 裏面的選項" 这个性质.

/**
* 用户选择
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ inline val MediaSelector.autoSelect get() = MediaSelectorAutoSelect(this)
/**
* [MediaSelector] 自动选择功能.
*
* 有关数据源选择算法, 参阅 [MediaSelector], 尤其是 "快速选择的情况" 部分.
* 有关数据源选择算法, 参阅 [MediaSelector], 尤其是 "快速選擇的情況" 部分.
*/
class MediaSelectorAutoSelect(
private val mediaSelector: MediaSelector,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ object MediaListFilters {
* 我们定义几类特殊字符(串):
*
* 1. 无条件保留的特殊字符. [keepWords] 中的词总是会被保留.
* 2. 无条件删除的特殊字符. 例如 "电影", "剧场版" 等, 这些字符总是会被删除.
* 2. 无条件删除的特殊字符. 例如 "電影", "劇場版" 等, 这些字符总是会被删除.
*
* 基于经过上面两类处理后的字符串, 我们会进一步处理:
* 1. 条件删除 ([charsToDelete]) 和替换为空格 ([charsToReplaceWithWhitespace]).
Expand All @@ -141,7 +141,7 @@ object MediaListFilters {
*
* @param removeWhitespace 如果为 true, 则会删除所有空格(包括通过 replaceWithWhitespace 替换出来的空格)
* @param replaceNumbers 如果为 true, 则会将中文数字替换成阿拉伯数字 (例如 “三” -> “3”)
* @param removeMarkers 如果为 true, 则会删除 "电影", "剧场版", "OVA" 等仅有标记作用的词. 注意, 不能在搜索到之后做匹配的时候使用. 详见 #1794
* @param removeMarkers 如果为 true, 则会删除 "電影", "劇場版", "OVA" 等仅有标记作用的词. 注意, 不能在搜索到之后做匹配的时候使用. 详见 #1794
*/
fun removeSpecials(
string: String,
Expand All @@ -154,17 +154,17 @@ object MediaListFilters {
acc.replace(keepWord.originalWord, keepWord.mask)
}

// 2. 无条件删除 "电影", "剧场版", "OVA" 等
// 2. 无条件删除 "電影", "劇場版", "OVA" 等
val sb = StringBuilder(result).apply {
if (removeMarkers) {
deletePrefix("电影")
deleteInfix("电影")
deletePrefix("剧场版")
deleteInfix("剧场版")
deletePrefix("電影")
deleteInfix("電影")
deletePrefix("劇場版")
deleteInfix("劇場版")
deletePrefix("OVA")
deleteInfix("OVA")
deleteInfix("OAD")
deleteInfix("总集篇")
deleteInfix("總集篇")
}
}

Expand Down
Loading
Loading