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}
|
selected={!selectedSubtitle}
|
||||||
onSelect={() => setSubtitle(null)}
|
onSelect={() => setSubtitle(null)}
|
||||||
/>
|
/>
|
||||||
{subtitles.map((x, i) => (
|
{subtitles
|
||||||
<Menu.Item
|
.filter((x) => !!x.link)
|
||||||
key={x.index ?? i}
|
.map((x, i) => (
|
||||||
label={x.link ? getSubtitleName(x) : `${getSubtitleName(x)} (${x.codec})`}
|
<Menu.Item
|
||||||
selected={selectedSubtitle === x}
|
key={x.index ?? i}
|
||||||
disabled={!x.link}
|
label={x.link ? getSubtitleName(x) : `${getSubtitleName(x)} (${x.codec})`}
|
||||||
onSelect={() => setSubtitle(x)}
|
selected={selectedSubtitle === x}
|
||||||
/>
|
disabled={!x.link}
|
||||||
))}
|
onSelect={() => setSubtitle(x)}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
</Menu>
|
</Menu>
|
||||||
)}
|
)}
|
||||||
<AudiosMenu
|
<AudiosMenu
|
||||||
|
@ -109,12 +109,14 @@ const Video = forwardRef<VideoRef, VideoProps>(function Video(
|
|||||||
}
|
}
|
||||||
// when video file is invalid, audio is undefined
|
// when video file is invalid, audio is undefined
|
||||||
selectedAudioTrack={{ type: SelectedTrackType.INDEX, value: audio?.index ?? 0 }}
|
selectedAudioTrack={{ type: SelectedTrackType.INDEX, value: audio?.index ?? 0 }}
|
||||||
textTracks={subtitles?.map((x) => ({
|
textTracks={subtitles
|
||||||
type: MimeTypes.get(x.codec) as any,
|
?.filter((x) => !!x.link)
|
||||||
uri: x.link!,
|
.map((x) => ({
|
||||||
title: x.title ?? "Unknown",
|
type: MimeTypes.get(x.codec) as any,
|
||||||
language: x.language ?? ("Unknown" as any),
|
uri: x.link!,
|
||||||
}))}
|
title: x.title ?? "Unknown",
|
||||||
|
language: x.language ?? ("Unknown" as any),
|
||||||
|
}))}
|
||||||
selectedTextTrack={
|
selectedTextTrack={
|
||||||
subtitle
|
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) {
|
func (s *MetadataService) extractSubs(ctx context.Context, info *MediaInfo) (err error) {
|
||||||
defer utils.PrintExecTime("extraction of %s", info.Path)()
|
defer utils.PrintExecTime("extraction of %s", info.Path)()
|
||||||
|
|
||||||
// If there is no subtitles, there is nothing to extract (also fonts would be useless).
|
// If there are no supported, embedded subtitles, there is nothing to extract.
|
||||||
if len(info.Subtitles) == 0 {
|
hasSupportedSubtitle := false
|
||||||
|
for _, sub := range info.Subtitles {
|
||||||
|
if !sub.IsExternal && sub.Extension != nil {
|
||||||
|
hasSupportedSubtitle = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !hasSupportedSubtitle {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user