42 lines
970 B
Go
Raw Normal View History

2018-12-11 06:37:15 +00:00
package episode
import (
"net/http"
"github.com/aerogo/aero"
2019-06-03 09:32:43 +00:00
"github.com/animenotifier/notify.moe/arn"
2018-12-11 06:37:15 +00:00
)
// Subtitles returns the subtitles.
2019-06-01 04:55:49 +00:00
func Subtitles(ctx aero.Context) error {
2018-12-11 06:37:15 +00:00
id := ctx.Get("id")
2024-08-09 10:09:51 +00:00
// language := ctx.Get("language")
2019-08-28 08:06:42 +00:00
// Get episode
episode, err := arn.GetEpisode(id)
2018-12-11 06:37:15 +00:00
if err != nil {
2019-08-28 08:06:42 +00:00
return ctx.Error(http.StatusNotFound, "Episode not found", err)
2018-12-11 06:37:15 +00:00
}
// Get anime
2019-08-28 08:06:42 +00:00
anime := episode.Anime()
2018-12-11 06:37:15 +00:00
2019-08-28 08:06:42 +00:00
if anime == nil {
2018-12-11 06:37:15 +00:00
return ctx.Error(http.StatusNotFound, "Anime not found", err)
}
2019-06-01 04:55:49 +00:00
ctx.Response().SetHeader("Access-Control-Allow-Origin", "*")
ctx.Response().SetHeader("Content-Type", "text/vtt; charset=utf-8")
2018-12-11 06:37:15 +00:00
2024-08-09 10:09:51 +00:00
// obj, err := arn.Spaces.GetObject(ctx.Request().Context(), "arn", fmt.Sprintf("videos/anime/%s/%d.%s.vtt", anime.ID, episode.Number, language), minio.GetObjectOptions{})
2018-12-11 06:37:15 +00:00
2024-08-09 10:09:51 +00:00
// if err != nil {
// return ctx.Error(http.StatusInternalServerError, err)
// }
2018-12-11 06:37:15 +00:00
2024-08-09 10:09:51 +00:00
// defer obj.Close()
// return ctx.ReadAll(obj)
return nil
2018-12-11 06:37:15 +00:00
}