Skip to content

Commit

Permalink
[media] 优先选择在线数据源, 默认只启用 Nyafun, Mikan CN 与动漫花园. close #371
Browse files Browse the repository at this point in the history
  • Loading branch information
Him188 committed Jun 3, 2024
1 parent f652a95 commit 5b5efaa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
7 changes: 3 additions & 4 deletions app/shared/data/common/data/media/selector/MediaSelector.kt
Original file line number Diff line number Diff line change
Expand Up @@ -415,11 +415,10 @@ class DefaultMediaSelector(
return@sequence
}
val fallback = mergedPreference.fallbackMediaSourceIds
if (fallback == null) {
yield(null)
} else {
yieldAll(fallback)
if (fallback != null) {
yieldAll(fallback) // 如果有设置, 那就优先使用设置的
}
yield(null) // 最后 (未匹配到时) 总是任意选一个
}

// For rules discussion, see #174
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import me.him188.ani.app.platform.Platform
import me.him188.ani.app.platform.isDesktop
import me.him188.ani.datasources.api.topic.Resolution
import me.him188.ani.datasources.api.topic.SubtitleLanguage
import me.him188.ani.datasources.dmhy.DmhyMediaSource
import me.him188.ani.datasources.mikan.MikanCNMediaSource
import me.him188.ani.datasources.nyafun.NyafunMediaSource

/**
Expand Down Expand Up @@ -59,7 +61,7 @@ data class MediaPreference private constructor(
/**
* @see fallbackSubtitleLanguageIds
*/
val fallbackMediaSourceIds: List<String>? = null
val fallbackMediaSourceIds: List<String>? = null,
) {
companion object {
/**
Expand All @@ -70,7 +72,11 @@ data class MediaPreference private constructor(
fallbackMediaSourceIds =
if (Platform.currentPlatform.isDesktop())
listOf(NyafunMediaSource.ID) // PC 默认不启用 BT 源
else null,
else listOf(
NyafunMediaSource.ID,
MikanCNMediaSource.ID,
DmhyMediaSource.ID,
), // TODO(3.1.0): 需要重写下数据源优先级与默认设置, 更新注释
)

/**
Expand Down

0 comments on commit 5b5efaa

Please sign in to comment.