admin: Improve resolutions.json
This commit is contained in:
parent
8afbacd654
commit
d8943ba1f3
1 changed files with 5 additions and 3 deletions
|
@ -258,7 +258,7 @@ func listTags(c *gin.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate the csv to export with:
|
// 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) {
|
func exportResolutionMovies(c *gin.Context) {
|
||||||
exercices, err := fic.GetExercices()
|
exercices, err := fic.GetExercices()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -271,11 +271,13 @@ func exportResolutionMovies(c *gin.Context) {
|
||||||
if theme, err := fic.GetTheme(exercice.IdTheme); err != nil {
|
if theme, err := fic.GetTheme(exercice.IdTheme); err != nil {
|
||||||
c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"errmsg": err.Error()})
|
c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"errmsg": err.Error()})
|
||||||
return
|
return
|
||||||
} else {
|
} else if len(exercice.VideoURI) > 0 {
|
||||||
|
level, _ := exercice.GetLevel()
|
||||||
export = append(export, map[string]string{
|
export = append(export, map[string]string{
|
||||||
"videoURI": exercice.VideoURI,
|
"videoURI": strings.Replace(exercice.VideoURI, "$FILES$/", "files/", 1),
|
||||||
"theme": theme.Name,
|
"theme": theme.Name,
|
||||||
"title": exercice.Title,
|
"title": exercice.Title,
|
||||||
|
"level": fmt.Sprintf("%d", level),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue