Cleanly handle unsupported subtitles (#944)

This commit is contained in:
solidDoWant 2025-05-07 15:51:43 -05:00 committed by GitHub
parent 27a4fc328e
commit 4a0e1aa72c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 28 additions and 17 deletions

View File

@ -71,7 +71,9 @@ export const RightButtons = ({
selected={!selectedSubtitle}
onSelect={() => setSubtitle(null)}
/>
{subtitles.map((x, i) => (
{subtitles
.filter((x) => !!x.link)
.map((x, i) => (
<Menu.Item
key={x.index ?? i}
label={x.link ? getSubtitleName(x) : `${getSubtitleName(x)} (${x.codec})`}

View File

@ -109,7 +109,9 @@ const Video = forwardRef<VideoRef, VideoProps>(function Video(
}
// when video file is invalid, audio is undefined
selectedAudioTrack={{ type: SelectedTrackType.INDEX, value: audio?.index ?? 0 }}
textTracks={subtitles?.map((x) => ({
textTracks={subtitles
?.filter((x) => !!x.link)
.map((x) => ({
type: MimeTypes.get(x.codec) as any,
uri: x.link!,
title: x.title ?? "Unknown",

View File

@ -63,8 +63,15 @@ func (s *MetadataService) GetSubtitle(ctx context.Context, sha string, name stri
func (s *MetadataService) extractSubs(ctx context.Context, info *MediaInfo) (err error) {
defer utils.PrintExecTime("extraction of %s", info.Path)()
// If there is no subtitles, there is nothing to extract (also fonts would be useless).
if len(info.Subtitles) == 0 {
// If there are no supported, embedded subtitles, there is nothing to extract.
hasSupportedSubtitle := false
for _, sub := range info.Subtitles {
if !sub.IsExternal && sub.Extension != nil {
hasSupportedSubtitle = true
break
}
}
if !hasSupportedSubtitle {
return nil
}