Skip to content

Commit

Permalink
仅从 jellyfin 获取外挂字幕并给字幕添加 label (#1460)
Browse files Browse the repository at this point in the history
  • Loading branch information
he0119 authored Jan 7, 2025
1 parent 40950c9 commit be485d4
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions datasource/jellyfin/src/BaseJellyfinMediaSource.kt
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,16 @@ abstract class BaseJellyfinMediaSource(config: MediaSourceConfig) : HttpMediaSou

private fun getSubtitles(itemId: String, mediaStreams: List<MediaStream>): List<Subtitle> {
return mediaStreams
.filter { it.Type == "Subtitle" && it.IsTextSubtitleStream }
.filter { it.Type == "Subtitle" && it.IsTextSubtitleStream && it.IsExternal }
.map { stream ->
Subtitle(
uri = getSubtitleUri(itemId, stream.Index, stream.Codec),
language = stream.Title,
language = stream.Language,
mimeType = when (stream.Codec.lowercase()) {
"ass" -> "text/x-ass"
else -> "application/octet-stream" // 默认二进制流
},
label = stream.Title,
)
}
}
Expand Down Expand Up @@ -188,9 +189,11 @@ private class SearchResponse(
@Suppress("PropertyName")
private data class MediaStream(
val Title: String? = null, // 除了字幕以外其他可能没有
val Language: String? = null, // 字幕语言代码,如 chs
val Type: String,
val Codec: String,
val Index: Int,
val IsExternal: Boolean, // 是否为外挂字幕
val IsTextSubtitleStream: Boolean,
)

Expand Down

0 comments on commit be485d4

Please sign in to comment.