Detect theme and exercice language at runtime (not stored)
This commit is contained in:
parent
99cc79421f
commit
aa0e7406c1
17 changed files with 99 additions and 42 deletions
|
|
@ -11,9 +11,10 @@ import (
|
|||
ffmpeg "github.com/u2takey/ffmpeg-go"
|
||||
|
||||
"srs.epita.fr/fic-server/admin/sync"
|
||||
"srs.epita.fr/fic-server/libfic"
|
||||
)
|
||||
|
||||
func CheckGrammarSubtitleTrack(path string, exceptions *sync.CheckExceptions) (errs []error) {
|
||||
func CheckGrammarSubtitleTrack(path string, exercice *fic.Exercice, exceptions *sync.CheckExceptions) (errs []error) {
|
||||
tmpfile, err := ioutil.TempFile("", "resolution-*.srt")
|
||||
if err != nil {
|
||||
errs = append(errs, fmt.Errorf("unable to create a temporary file: %w", err))
|
||||
|
|
@ -39,7 +40,10 @@ func CheckGrammarSubtitleTrack(path string, exceptions *sync.CheckExceptions) (e
|
|||
for _, item := range subtitles.Items {
|
||||
lines = append(lines, item.String())
|
||||
}
|
||||
for _, e := range hooks.CallCustomHook("CheckGrammar", strings.Join(lines, "\n"), exceptions) {
|
||||
for _, e := range hooks.CallCustomHook("CheckGrammar", struct {
|
||||
Str string
|
||||
Language string
|
||||
}{Str: strings.Join(lines, "\n"), Language: exercice.Language}, exceptions) {
|
||||
errs = append(errs, fmt.Errorf("subtitle-track: %w", e))
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ func checkResolutionVideo(e *fic.Exercice, exceptions *sync.CheckExceptions) (er
|
|||
if !subtitles_seen && !exceptions.HasException(":subtitle:no_track") {
|
||||
errs = append(errs, fmt.Errorf("no subtitles track found"))
|
||||
} else if subtitles_seen {
|
||||
errs = append(errs, CheckGrammarSubtitleTrack(path, exceptions)...)
|
||||
errs = append(errs, CheckGrammarSubtitleTrack(path, e, exceptions)...)
|
||||
}
|
||||
|
||||
return
|
||||
|
|
|
|||
Reference in a new issue