2018-12-11 15:37:15 +09:00
|
|
|
package episode
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"github.com/aerogo/aero"
|
2019-06-03 18:32:43 +09:00
|
|
|
"github.com/animenotifier/notify.moe/arn"
|
2018-12-11 15:37:15 +09:00
|
|
|
)
|
|
|
|
|
|
|
|
// Subtitles returns the subtitles.
|
2019-06-01 13:55:49 +09:00
|
|
|
func Subtitles(ctx aero.Context) error {
|
2018-12-11 15:37:15 +09:00
|
|
|
id := ctx.Get("id")
|
2024-08-09 12:09:51 +02:00
|
|
|
// language := ctx.Get("language")
|
2019-08-28 17:06:42 +09:00
|
|
|
|
|
|
|
// Get episode
|
|
|
|
episode, err := arn.GetEpisode(id)
|
2018-12-11 15:37:15 +09:00
|
|
|
|
|
|
|
if err != nil {
|
2019-08-28 17:06:42 +09:00
|
|
|
return ctx.Error(http.StatusNotFound, "Episode not found", err)
|
2018-12-11 15:37:15 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
// Get anime
|
2019-08-28 17:06:42 +09:00
|
|
|
anime := episode.Anime()
|
2018-12-11 15:37:15 +09:00
|
|
|
|
2019-08-28 17:06:42 +09:00
|
|
|
if anime == nil {
|
2018-12-11 15:37:15 +09:00
|
|
|
return ctx.Error(http.StatusNotFound, "Anime not found", err)
|
|
|
|
}
|
|
|
|
|
2019-06-01 13:55:49 +09:00
|
|
|
ctx.Response().SetHeader("Access-Control-Allow-Origin", "*")
|
|
|
|
ctx.Response().SetHeader("Content-Type", "text/vtt; charset=utf-8")
|
2018-12-11 15:37:15 +09:00
|
|
|
|
2024-08-09 12:09:51 +02: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 15:37:15 +09:00
|
|
|
|
2024-08-09 12:09:51 +02:00
|
|
|
// if err != nil {
|
|
|
|
// return ctx.Error(http.StatusInternalServerError, err)
|
|
|
|
// }
|
2018-12-11 15:37:15 +09:00
|
|
|
|
2024-08-09 12:09:51 +02:00
|
|
|
// defer obj.Close()
|
|
|
|
// return ctx.ReadAll(obj)
|
|
|
|
return nil
|
2018-12-11 15:37:15 +09:00
|
|
|
}
|