mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-24 02:02:36 -04:00
Cleanly handle unsupported subtitles (#944)
This commit is contained in:
parent
27a4fc328e
commit
4a0e1aa72c
@ -71,15 +71,17 @@ export const RightButtons = ({
|
||||
selected={!selectedSubtitle}
|
||||
onSelect={() => setSubtitle(null)}
|
||||
/>
|
||||
{subtitles.map((x, i) => (
|
||||
<Menu.Item
|
||||
key={x.index ?? i}
|
||||
label={x.link ? getSubtitleName(x) : `${getSubtitleName(x)} (${x.codec})`}
|
||||
selected={selectedSubtitle === x}
|
||||
disabled={!x.link}
|
||||
onSelect={() => setSubtitle(x)}
|
||||
/>
|
||||
))}
|
||||
{subtitles
|
||||
.filter((x) => !!x.link)
|
||||
.map((x, i) => (
|
||||
<Menu.Item
|
||||
key={x.index ?? i}
|
||||
label={x.link ? getSubtitleName(x) : `${getSubtitleName(x)} (${x.codec})`}
|
||||
selected={selectedSubtitle === x}
|
||||
disabled={!x.link}
|
||||
onSelect={() => setSubtitle(x)}
|
||||
/>
|
||||
))}
|
||||
</Menu>
|
||||
)}
|
||||
<AudiosMenu
|
||||
|
@ -109,12 +109,14 @@ 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) => ({
|
||||
type: MimeTypes.get(x.codec) as any,
|
||||
uri: x.link!,
|
||||
title: x.title ?? "Unknown",
|
||||
language: x.language ?? ("Unknown" as any),
|
||||
}))}
|
||||
textTracks={subtitles
|
||||
?.filter((x) => !!x.link)
|
||||
.map((x) => ({
|
||||
type: MimeTypes.get(x.codec) as any,
|
||||
uri: x.link!,
|
||||
title: x.title ?? "Unknown",
|
||||
language: x.language ?? ("Unknown" as any),
|
||||
}))}
|
||||
selectedTextTrack={
|
||||
subtitle
|
||||
? {
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user