Jellyfin: Add support for external subs (#1622)

This commit is contained in:
Secozzi 2023-05-19 16:22:03 +02:00 committed by GitHub
parent c55f7c62ef
commit d38be0cf35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 12 deletions

View File

@ -6,7 +6,7 @@ ext {
extName = 'Jellyfin' extName = 'Jellyfin'
pkgNameSuffix = 'all.jellyfin' pkgNameSuffix = 'all.jellyfin'
extClass = '.Jellyfin' extClass = '.Jellyfin'
extVersionCode = 6 extVersionCode = 7
libVersion = '13' libVersion = '13'
} }

View File

@ -44,6 +44,7 @@ data class SessionResponse(
val Index: Int, val Index: Int,
val Type: String, val Type: String,
val SupportsExternalStream: Boolean, val SupportsExternalStream: Boolean,
val IsExternal: Boolean,
val Language: String? = null, val Language: String? = null,
val DisplayTitle: String? = null, val DisplayTitle: String? = null,
val Height: Int? = null, val Height: Int? = null,

View File

@ -351,19 +351,21 @@ class Jellyfin : ConfigurableAnimeSource, AnimeHttpSource() {
if (media.Language != null) { if (media.Language != null) {
if (media.Language == prefSub) { if (media.Language == prefSub) {
try { try {
subtitleList.add(0, Track(subUrl, media.DisplayTitle!!)) if (media.IsExternal) {
subtitleList.add(0, Track(subUrl, media.DisplayTitle!!))
}
} catch (e: Error) { } catch (e: Error) {
subIndex = media.Index subIndex = media.Index
} }
} else { } else {
try { if (media.IsExternal) {
subtitleList.add(Track(subUrl, media.DisplayTitle!!)) subtitleList.add(Track(subUrl, media.DisplayTitle!!))
} catch (_: Error) {} }
} }
} else { } else {
try { if (media.IsExternal) {
subtitleList.add(Track(subUrl, media.DisplayTitle!!)) subtitleList.add(Track(subUrl, media.DisplayTitle!!))
} catch (_: Error) {} }
} }
} else { } else {
if (media.Language != null && media.Language == prefSub) { if (media.Language != null && media.Language == prefSub) {
@ -387,7 +389,7 @@ class Jellyfin : ConfigurableAnimeSource, AnimeHttpSource() {
JFConstants.QUALITIES_LIST.forEach { quality -> JFConstants.QUALITIES_LIST.forEach { quality ->
if (width < quality.width && height < quality.height) { if (width < quality.width && height < quality.height) {
val url = "$baseUrl/Videos/$id/stream?static=True&api_key=$apiKey" val url = "$baseUrl/Videos/$id/stream?static=True&api_key=$apiKey"
videoList.add(Video(url, "Best", url)) videoList.add(Video(url, "Best", url, subtitleTracks = subtitleList))
return videoList.reversed() return videoList.reversed()
} else { } else {
@ -419,11 +421,7 @@ class Jellyfin : ConfigurableAnimeSource, AnimeHttpSource() {
url.addQueryParameter("h264-deinterlace", "true") url.addQueryParameter("h264-deinterlace", "true")
url.addQueryParameter("TranscodeReasons", "VideoCodecNotSupported,AudioCodecNotSupported,ContainerBitrateExceedsLimit") url.addQueryParameter("TranscodeReasons", "VideoCodecNotSupported,AudioCodecNotSupported,ContainerBitrateExceedsLimit")
try { videoList.add(Video(url.toString(), quality.description, url.toString(), subtitleTracks = subtitleList))
videoList.add(Video(url.toString(), quality.description, url.toString(), subtitleTracks = subtitleList))
} catch (_: Error) {
videoList.add(Video(url.toString(), quality.description, url.toString()))
}
} }
} }