mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-12-06 06:36:25 +00:00
wip: Add subtitles handling
This commit is contained in:
@@ -287,7 +287,7 @@ func RetriveMediaInfo(path string, sha string) (*MediaInfo, error) {
|
||||
extension := OrNull(SubtitleExtensions[stream.CodecName])
|
||||
var link string
|
||||
if extension != nil {
|
||||
link = fmt.Sprintf("video/%s/subtitle/%d.%s", base64.RawURLEncoding.EncodeToString([]byte(path)), i, *extension)
|
||||
link = fmt.Sprintf("/video/%s/subtitle/%d.%s", base64.RawURLEncoding.EncodeToString([]byte(path)), i, *extension)
|
||||
}
|
||||
lang, _ := language.Parse(stream.Tags.Language)
|
||||
idx := uint32(i)
|
||||
@@ -315,7 +315,7 @@ func RetriveMediaInfo(path string, sha string) (*MediaInfo, error) {
|
||||
}),
|
||||
Fonts: MapStream(mi.Streams, ffprobe.StreamAttachment, func(stream *ffprobe.Stream, i uint32) string {
|
||||
font, _ := stream.TagList.GetString("filename")
|
||||
return fmt.Sprintf("video/%s/attachment/%s", base64.RawURLEncoding.EncodeToString([]byte(path)), font)
|
||||
return fmt.Sprintf("/video/%s/attachment/%s", base64.RawURLEncoding.EncodeToString([]byte(path)), font)
|
||||
}),
|
||||
}
|
||||
var codecs []string
|
||||
|
||||
@@ -174,7 +174,7 @@ func (s *MetadataService) GetMetadata(ctx context.Context, path string, sha stri
|
||||
tx.Exec(`update info set ver_keyframes = 0 where sha = $1`, sha)
|
||||
err = tx.Commit()
|
||||
if err != nil {
|
||||
fmt.Printf("error deleteing old keyframes from database: %v", err)
|
||||
fmt.Printf("error deleting old keyframes from database: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -256,7 +256,7 @@ func (s *MetadataService) getMetadata(path string, sha string) (*MediaInfo, erro
|
||||
}
|
||||
if s.Extension != nil {
|
||||
link := fmt.Sprintf(
|
||||
"video/%s/subtitle/%d.%s",
|
||||
"/video/%s/subtitle/%d.%s",
|
||||
base64.RawURLEncoding.EncodeToString([]byte(ret.Path)),
|
||||
*s.Index,
|
||||
*s.Extension,
|
||||
@@ -391,5 +391,10 @@ func (s *MetadataService) storeFreshMetadata(path string, sha string) (*MediaInf
|
||||
return set(ret, err)
|
||||
}
|
||||
|
||||
err = ret.SearchExternalSubtitles()
|
||||
if err != nil {
|
||||
return set(ret, err)
|
||||
}
|
||||
|
||||
return set(ret, nil)
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ outer:
|
||||
for codec, ext := range SubtitleExtensions {
|
||||
if strings.HasSuffix(match, ext) {
|
||||
link := fmt.Sprintf(
|
||||
"video/%s/direct/%s",
|
||||
"/video/%s/direct/%s",
|
||||
base64.RawURLEncoding.EncodeToString([]byte(match)),
|
||||
filepath.Base(match),
|
||||
)
|
||||
|
||||
@@ -145,7 +145,7 @@ func (s *MetadataService) extractThumbnail(ctx context.Context, path string, sha
|
||||
timestamps := ts
|
||||
ts += interval
|
||||
vtt += fmt.Sprintf(
|
||||
"%s --> %s\nvideo/%s/thumbnails.png#xywh=%d,%d,%d,%d\n\n",
|
||||
"%s --> %s\n/video/%s/thumbnails.png#xywh=%d,%d,%d,%d\n\n",
|
||||
tsToVttTime(timestamps),
|
||||
tsToVttTime(ts),
|
||||
base64.RawURLEncoding.EncodeToString([]byte(path)),
|
||||
|
||||
Reference in New Issue
Block a user