admin: add a new route to generate a file for movie links
This commit is contained in:
parent
41ef7f2555
commit
650f1f4d59
@ -14,6 +14,7 @@ import (
|
||||
|
||||
func init() {
|
||||
router.GET("/api/exercices/", apiHandler(listExercices))
|
||||
router.GET("/api/resolutions.json", apiHandler(exportResolutionMovies))
|
||||
|
||||
router.GET("/api/exercices/:eid", apiHandler(exerciceHandler(showExercice)))
|
||||
router.PUT("/api/exercices/:eid", apiHandler(exerciceHandler(updateExercice)))
|
||||
@ -85,6 +86,28 @@ func listExercices(_ httprouter.Params, body []byte) (interface{}, error) {
|
||||
return fic.GetExercices()
|
||||
}
|
||||
|
||||
// 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(\";\")"
|
||||
func exportResolutionMovies(_ httprouter.Params, body []byte) (interface{}, error) {
|
||||
if exercices, err := fic.GetExercices(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
export := []map[string]string{}
|
||||
for _, exercice := range exercices {
|
||||
if theme, err := fic.GetTheme(exercice.IdTheme); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
export = append(export, map[string]string{
|
||||
"videoURI": exercice.VideoURI,
|
||||
"theme": theme.Name,
|
||||
"title": exercice.Title,
|
||||
})
|
||||
}
|
||||
}
|
||||
return export, nil
|
||||
}
|
||||
}
|
||||
|
||||
func listExerciceFiles(exercice fic.Exercice, body []byte) (interface{}, error) {
|
||||
return exercice.GetFiles()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user