repochecker/videos: Use subtitle track language as grammar check lang
This commit is contained in:
parent
a7309b6a00
commit
1720906ec8
2 changed files with 6 additions and 4 deletions
|
@ -11,10 +11,9 @@ import (
|
||||||
ffmpeg "github.com/u2takey/ffmpeg-go"
|
ffmpeg "github.com/u2takey/ffmpeg-go"
|
||||||
|
|
||||||
"srs.epita.fr/fic-server/admin/sync"
|
"srs.epita.fr/fic-server/admin/sync"
|
||||||
"srs.epita.fr/fic-server/libfic"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func CheckGrammarSubtitleTrack(path string, index uint, exercice *fic.Exercice, exceptions *sync.CheckExceptions) (errs []error) {
|
func CheckGrammarSubtitleTrack(path string, index uint, lang string, exceptions *sync.CheckExceptions) (errs []error) {
|
||||||
tmpfile, err := ioutil.TempFile("", "resolution-*.srt")
|
tmpfile, err := ioutil.TempFile("", "resolution-*.srt")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errs = append(errs, fmt.Errorf("unable to create a temporary file: %w", err))
|
errs = append(errs, fmt.Errorf("unable to create a temporary file: %w", err))
|
||||||
|
@ -43,7 +42,7 @@ func CheckGrammarSubtitleTrack(path string, index uint, exercice *fic.Exercice,
|
||||||
for _, e := range hooks.CallCustomHook("CheckGrammar", struct {
|
for _, e := range hooks.CallCustomHook("CheckGrammar", struct {
|
||||||
Str string
|
Str string
|
||||||
Language string
|
Language string
|
||||||
}{Str: strings.Join(lines, "\n"), Language: exercice.Language}, exceptions) {
|
}{Str: strings.Join(lines, "\n"), Language: lang[:2]}, exceptions) {
|
||||||
errs = append(errs, fmt.Errorf("subtitle-track: %w", e))
|
errs = append(errs, fmt.Errorf("subtitle-track: %w", e))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -148,11 +148,14 @@ func checkResolutionVideo(e *fic.Exercice, exceptions *sync.CheckExceptions) (er
|
||||||
errs = append(errs, fmt.Errorf("no subtitles track found"))
|
errs = append(errs, fmt.Errorf("no subtitles track found"))
|
||||||
} else if len(subtitles_seen) > 0 {
|
} else if len(subtitles_seen) > 0 {
|
||||||
for _, idx := range subtitles_seen {
|
for _, idx := range subtitles_seen {
|
||||||
|
language := e.Language
|
||||||
if lang, ok := vInfo.Streams[idx].Tags["language"]; e.Language != "" && (!ok || lang == "" || lang == "und") {
|
if lang, ok := vInfo.Streams[idx].Tags["language"]; e.Language != "" && (!ok || lang == "" || lang == "und") {
|
||||||
errs = append(errs, fmt.Errorf("subtitles track %d with no language defined", vInfo.Streams[idx].Index))
|
errs = append(errs, fmt.Errorf("subtitles track %d with no language defined", vInfo.Streams[idx].Index))
|
||||||
|
} else {
|
||||||
|
language = lang
|
||||||
}
|
}
|
||||||
|
|
||||||
errs = append(errs, CheckGrammarSubtitleTrack(path, vInfo.Streams[idx].Index, e, exceptions)...)
|
errs = append(errs, CheckGrammarSubtitleTrack(path, vInfo.Streams[idx].Index, language, exceptions)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
if e.Language != "" && len(subtitles_seen) < 2 {
|
if e.Language != "" && len(subtitles_seen) < 2 {
|
||||||
|
|
Reference in a new issue