admin: Improve resolutions.json

This commit is contained in:
nemunaire 2022-06-20 00:08:07 +02:00
parent 8afbacd654
commit d8943ba1f3
1 changed files with 5 additions and 3 deletions

View File

@ -258,7 +258,7 @@ func listTags(c *gin.Context) {
}
// Generate the csv to export with:
// curl -s http://127.0.0.1:8081/api/resolutions.json | jq -r ".[] | [ .theme,.title, @uri \"https://fic.srs.epita.fr/resolution/\\(.videoURI)\" ] | join(\";\")"
// curl -s http://127.0.0.1:8081/api/resolutions.json | jq -r ".[] | [ .theme,.level,.title, @uri \"https://fic.srs.epita.fr/$(date +%Y)/\\(.videoURI)\" ] | join(\";\")"
func exportResolutionMovies(c *gin.Context) {
exercices, err := fic.GetExercices()
if err != nil {
@ -271,11 +271,13 @@ func exportResolutionMovies(c *gin.Context) {
if theme, err := fic.GetTheme(exercice.IdTheme); err != nil {
c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"errmsg": err.Error()})
return
} else {
} else if len(exercice.VideoURI) > 0 {
level, _ := exercice.GetLevel()
export = append(export, map[string]string{
"videoURI": exercice.VideoURI,
"videoURI": strings.Replace(exercice.VideoURI, "$FILES$/", "files/", 1),
"theme": theme.Name,
"title": exercice.Title,
"level": fmt.Sprintf("%d", level),
})
}
}