Removed Spaces CDN

This commit is contained in:
2024-08-09 12:09:51 +02:00
parent aa87e8c65f
commit f1697323fc
11 changed files with 106 additions and 150 deletions

View File

@ -1,13 +1,11 @@
package episode
import (
"fmt"
"net/http"
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/components"
minio "github.com/minio/minio-go/v7"
)
// Get renders the anime episode.
@ -32,10 +30,10 @@ func Get(ctx aero.Context) error {
// Does the episode exist?
uploaded := false
if arn.Spaces != nil {
stat, err := arn.Spaces.StatObject(ctx.Request().Context(), "arn", fmt.Sprintf("videos/anime/%s/%d.webm", anime.ID, episode.Number), minio.StatObjectOptions{})
uploaded = (err == nil) && (stat.Size > 0)
}
// if arn.Spaces != nil {
// stat, err := arn.Spaces.StatObject(ctx.Request().Context(), "arn", fmt.Sprintf("videos/anime/%s/%d.webm", anime.ID, episode.Number), minio.StatObjectOptions{})
// uploaded = (err == nil) && (stat.Size > 0)
// }
_, episodeIndex := anime.Episodes().Find(episode.Number)

View File

@ -1,24 +1,24 @@
component Episode(anime *arn.Anime, episode *arn.Episode, episodeIndex int, uploaded bool, user *arn.User)
h1
a(href=anime.Link())= anime.Title.ByUser(user)
.episode-navigation-container
if episodeIndex > 0
.episode-arrow.episode-arrow-previous
a.light-button(href=episode.Previous().Link(), title="Previous episode")
RawIcon("chevron-left")
.episode-video
if uploaded
.video-container(id="stream-test")
video.video.lazy.action(data-action="toggleFullscreen", data-trigger="dblclick", data-id="stream-test")
source(data-src=fmt.Sprintf("https://arn.sfo2.cdn.digitaloceanspaces.com/videos/anime/%s/%d.webm", anime.ID, episode.Number), data-type="video/webm")
source(data-src=fmt.Sprintf("https://notify.moe/videos/anime/%s/%d.webm", anime.ID, episode.Number), data-type="video/webm")
track(label="English", kind="subtitles", srclang="en", src=fmt.Sprintf("/anime/%s/episode/%d/subtitles/en", anime.ID, episode.Number), default)
VideoControls("stream-test", time.Duration(0))
else
.video-container.episode-not-available(title="Episode not available yet")
//- a(href=anime.Link(), title=anime.Title.ByUser(user))
//- img.anime-cover-image.lazy(data-src=anime.ImageLink("large"), data-webp="true", data-color=anime.AverageColor(), alt=anime.Title.ByUser(user))
@ -36,6 +36,6 @@ component Episode(anime *arn.Anime, episode *arn.Episode, episodeIndex int, uplo
if validate.DateTime(episode.AiringDate.Start)
p.episode-view-airing-date
time.utc-airing-date(datetime=episode.AiringDate.Start, data-end-date=episode.AiringDate.End, data-episode-number=episode.Number)= episode.AiringDate.StartDateHuman()
footer.footer
p Make sure to support the anime you're watching by buying officially released Blu-rays and merchandise.

View File

@ -1,18 +1,16 @@
package episode
import (
"fmt"
"net/http"
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/arn"
minio "github.com/minio/minio-go/v7"
)
// Subtitles returns the subtitles.
func Subtitles(ctx aero.Context) error {
id := ctx.Get("id")
language := ctx.Get("language")
// language := ctx.Get("language")
// Get episode
episode, err := arn.GetEpisode(id)
@ -31,12 +29,13 @@ func Subtitles(ctx aero.Context) error {
ctx.Response().SetHeader("Access-Control-Allow-Origin", "*")
ctx.Response().SetHeader("Content-Type", "text/vtt; charset=utf-8")
obj, err := arn.Spaces.GetObject(ctx.Request().Context(), "arn", fmt.Sprintf("videos/anime/%s/%d.%s.vtt", anime.ID, episode.Number, language), minio.GetObjectOptions{})
// obj, err := arn.Spaces.GetObject(ctx.Request().Context(), "arn", fmt.Sprintf("videos/anime/%s/%d.%s.vtt", anime.ID, episode.Number, language), minio.GetObjectOptions{})
if err != nil {
return ctx.Error(http.StatusInternalServerError, err)
}
// if err != nil {
// return ctx.Error(http.StatusInternalServerError, err)
// }
defer obj.Close()
return ctx.ReadAll(obj)
// defer obj.Close()
// return ctx.ReadAll(obj)
return nil
}

View File

@ -9,7 +9,7 @@ component FrontPage
.bg-video-container
video.bg-video(muted, autoplay, loop)
source(src="https://arn.sfo2.cdn.digitaloceanspaces.com/videos/others/violet.webm", type="video/webm")
source(src="https://notify.moe/videos/others/violet.webm", type="video/webm")
component Footer
footer.footer.mountable