Proxy subtitles from S3

This commit is contained in:
Eduard Urbach 2018-12-11 15:37:15 +09:00
parent 2c487d4308
commit 616f27e363
7 changed files with 56 additions and 1769 deletions

View File

@ -67,13 +67,6 @@ func configureAssets(app *aero.Application) {
return ctx.File("audio/" + ctx.Get("file")) return ctx.File("audio/" + ctx.Get("file"))
}) })
// Subtitles
app.Get("/subtitles/*file", func(ctx *aero.Context) string {
ctx.Response().Header().Set("Access-Control-Allow-Origin", "*")
ctx.Response().Header().Set("Content-Type", "text/vtt; charset=utf-8")
return ctx.File("subtitles/" + ctx.Get("file"))
})
// Anime sitemap // Anime sitemap
app.Get("/sitemap/anime.txt", func(ctx *aero.Context) string { app.Get("/sitemap/anime.txt", func(ctx *aero.Context) string {
sitemap := sitemap.New() sitemap := sitemap.New()

View File

@ -13,7 +13,7 @@ component AnimeEpisode(anime *arn.Anime, episode *arn.AnimeEpisode, episodeIndex
.video-container(id="stream-test") .video-container(id="stream-test")
video.video.lazy.action(data-action="toggleFullscreen", data-trigger="dblclick", data-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://arn.sfo2.cdn.digitaloceanspaces.com/videos/anime/%s/%d.webm", anime.ID, episode.Number), data-type="video/webm")
track(label="English", kind="subtitles", srclang="en", src=fmt.Sprintf("/subtitles/anime/%s/%d.en.vtt", anime.ID, episode.Number), default) 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)) VideoControls("stream-test", time.Duration(0))
else else

View File

@ -0,0 +1,50 @@
package episode
import (
"fmt"
"net/http"
"github.com/aerogo/aero"
"github.com/animenotifier/arn"
minio "github.com/minio/minio-go"
)
// Subtitles returns the subtitles.
func Subtitles(ctx *aero.Context) string {
id := ctx.Get("id")
language := ctx.Get("language")
episodeNumber, err := ctx.GetInt("episode-number")
if err != nil {
return ctx.Error(http.StatusBadRequest, "Episode is not a number", err)
}
// Get anime
anime, err := arn.GetAnime(id)
if err != nil {
return ctx.Error(http.StatusNotFound, "Anime not found", err)
}
ctx.Response().Header().Set("Access-Control-Allow-Origin", "*")
ctx.Response().Header().Set("Content-Type", "text/vtt; charset=utf-8")
obj, err := spaces.GetObject("arn", fmt.Sprintf("videos/anime/%s/%d.%s.vtt", anime.ID, episodeNumber, language), minio.GetObjectOptions{})
if err != nil {
return ctx.Error(http.StatusInternalServerError, err)
}
defer obj.Close()
data := make([]byte, 0, 65535)
buffer := make([]byte, 4096)
n := 0
for err == nil {
n, err = obj.Read(buffer)
data = append(data, buffer[:n]...)
}
return string(data)
}

View File

@ -3,7 +3,7 @@ package pages
import ( import (
"github.com/aerogo/aero" "github.com/aerogo/aero"
"github.com/aerogo/layout" "github.com/aerogo/layout"
"github.com/animenotifier/notify.moe/layout" fullpage "github.com/animenotifier/notify.moe/layout"
"github.com/animenotifier/notify.moe/pages/index/amvroutes" "github.com/animenotifier/notify.moe/pages/index/amvroutes"
"github.com/animenotifier/notify.moe/pages/index/animeroutes" "github.com/animenotifier/notify.moe/pages/index/animeroutes"
"github.com/animenotifier/notify.moe/pages/index/apiroutes" "github.com/animenotifier/notify.moe/pages/index/apiroutes"
@ -38,7 +38,7 @@ func Configure(app *aero.Application) {
exploreroutes.Register(l) exploreroutes.Register(l)
amvroutes.Register(l) amvroutes.Register(l)
forumroutes.Register(l) forumroutes.Register(l)
animeroutes.Register(l) animeroutes.Register(l, app)
userlistroutes.Register(l) userlistroutes.Register(l)
quoteroutes.Register(l) quoteroutes.Register(l)
companyroutes.Register(l) companyroutes.Register(l)

View File

@ -1,6 +1,7 @@
package animeroutes package animeroutes
import ( import (
"github.com/aerogo/aero"
"github.com/aerogo/layout" "github.com/aerogo/layout"
"github.com/animenotifier/notify.moe/pages/anime" "github.com/animenotifier/notify.moe/pages/anime"
"github.com/animenotifier/notify.moe/pages/anime/editanime" "github.com/animenotifier/notify.moe/pages/anime/editanime"
@ -10,7 +11,7 @@ import (
) )
// Register registers the page routes. // Register registers the page routes.
func Register(l *layout.Layout) { func Register(l *layout.Layout, app *aero.Application) {
// Anime // Anime
l.Page("/anime/:id", anime.Get) l.Page("/anime/:id", anime.Get)
l.Page("/anime/:id/episodes", anime.Episodes) l.Page("/anime/:id/episodes", anime.Episodes)
@ -19,6 +20,7 @@ func Register(l *layout.Layout) {
l.Page("/anime/:id/relations", anime.Relations) l.Page("/anime/:id/relations", anime.Relations)
l.Page("/anime/:id/comments", anime.Comments) l.Page("/anime/:id/comments", anime.Comments)
l.Page("/anime/:id/episode/:episode-number", episode.Get) l.Page("/anime/:id/episode/:episode-number", episode.Get)
app.Get("/anime/:id/episode/:episode-number/subtitles/:language", episode.Subtitles)
// Anime redirects // Anime redirects
l.Page("/kitsu/anime/:id", anime.RedirectByMapping("kitsu/anime")) l.Page("/kitsu/anime/:id", anime.RedirectByMapping("kitsu/anime"))

View File

@ -1,656 +0,0 @@
WEBVTT
00:08.744 --> 00:11.004
<b>March 23, 380 in the time
of the realm of humanity</b>
00:23.974 --> 00:26.014
<b>Isn't that the four-thirty bell?</b>
00:29.264 --> 00:31.774
<b>You're right. Is it that late already?</b>
00:32.224 --> 00:34.024
<b>Ronie and Tiese are late.</b>
00:34.814 --> 00:38.114
<b>They've never been late to clean before,
have they?</b>
00:41.734 --> 00:43.904
<b>I have a bad feeling about this.</b>
00:48.744 --> 00:51.334
<b>I'll go check the primary trainees' dorm.</b>
00:51.874 --> 00:55.964
<b>They might be on their way here,
so you stay and wait for them.</b>
00:55.964 --> 00:58.334
<b>Hey, Kirito, you should use the front—</b>
01:01.424 --> 01:03.884
<b>Jeez, he's always in such a rush.</b>
01:18.984 --> 01:20.694
<b>Thank goodness! We were worr—</b>
01:25.614 --> 01:28.914
<b>Um... are you Elite Disciple Eugeo?</b>
01:30.034 --> 01:31.624
<b>Yes. And you are?</b>
01:31.624 --> 01:35.414
<b>I-I'm Primary Trainee Frenica Cesky.</b>
01:35.414 --> 01:39.124
<b>I-I apologize for coming to see you
without an appointment.</b>
01:39.584 --> 01:42.594
<b>But I just don't know what to do!</b>
01:42.844 --> 01:45.264
<b>You're... Frenica?</b>
01:45.674 --> 01:53.264
<b>Um, I know you've gone out of your way
in regard to my issue with Lord Humbert Zizek.</b>
01:53.264 --> 01:54.814
<b>I thank you from the bottom of my heart.</b>
01:56.854 --> 02:03.154
<b>However, tonight,
Lord Zizek has ordered me to... um...</b>
02:03.864 --> 02:08.864
<b>He's ordered me to perform a service
that's difficult to explain.</b>
02:11.744 --> 02:18.624
<b>I-If he continues to give me these kinds of orders,
I-I'd rather leave the academy!</b>
02:18.624 --> 02:21.714
<b>I confided in Tiese and Ronie about this.</b>
02:21.714 --> 02:27.594
<b>When they heard this, they said they'd go
plead with him to spare me, and left the dorm.</b>
02:28.014 --> 02:30.134
<b>I've been waiting,
but they still haven't returned.</b>
02:30.134 --> 02:31.264
<b>What?</b>
02:32.724 --> 02:34.144
<b>You wait here.</b>
02:36.974 --> 02:39.104
<b><i>So that was their goal all along?</i></b>
02:39.734 --> 02:41.774
<b><i>Not to target me, but Tiese and Ronie!</i></b>
04:11.994 --> 04:15.994
<b>Taboo Index</b>
04:20.664 --> 04:22.334
<b>Please come in.</b>
04:35.304 --> 04:40.014
<b>We just opened a 50-year-old bottle
from the western empire, so why not join us?</b>
04:40.224 --> 04:43.644
<b>It's not something a commoner
would ever get to taste.</b>
04:51.194 --> 04:52.994
<b>No, that's fine.</b>
04:53.284 --> 04:54.784
<b>Actually, Elite Disciple Zizek,</b>
04:55.654 --> 04:59.954
<b>I wanted to ask if my page,
Primary Trainee Tiese Schtrinen,</b>
05:00.374 --> 05:05.584
<b>and Disciple Kirito's page, Primary Trainee
Ronie Arabel, happened to visit your room?</b>
05:08.134 --> 05:12.134
<b>So those two are yours and Sir Kirito's pages?</b>
05:12.514 --> 05:16.934
<b>To suddenly visit the first-seat elite disciple,
who stands at the pinnacle of the student body,</b>
05:16.934 --> 05:22.434
<b>as well as the second-seat elite disciple,
they're certainly brave for primary trainees!</b>
05:22.434 --> 05:24.894
<b>No wonder they're your pages.</b>
05:28.234 --> 05:31.024
<b>That said, they do need to be careful.</b>
05:31.024 --> 05:34.324
<b>Assertiveness can sometimes be taken
as rudeness or disrespect.</b>
05:34.904 --> 05:38.164
<b>Wouldn't you agree, Disciple Eugeo?</b>
05:39.034 --> 05:41.914
<b>I will hear your valued opinion another time.</b>
05:42.084 --> 05:44.584
<b>Where are Tiese and Ronie right now?</b>
06:11.114 --> 06:12.274
<b>What's this?</b>
06:17.074 --> 06:17.614
<b>Wh...</b>
06:18.114 --> 06:20.574
<b>What's the meaning of this, Lord Raios?</b>
06:20.574 --> 06:24.084
<b>These measures were unavoidable, Sir Eugeo.</b>
06:24.084 --> 06:31.384
<b>Since Primary Trainees Schtrinen and Arabel
disrespected us to an outrageous degree.</b>
06:31.964 --> 06:33.344
<b>Disrespected how?</b>
06:33.674 --> 06:39.384
<b>These two lesser noble girls had the gall
to accuse me, a fourth-rank nobleman,</b>
06:39.384 --> 06:45.314
<b>of needlessly abusing my own page
and satisfying my own lust, offending me greatly.</b>
06:45.644 --> 06:51.444
<b>After all I've done as the second-seat elite disciple
to guide Frenica down the proper path!</b>
06:52.444 --> 06:55.524
<b>And that's not all, Sir Eugeo.</b>
06:55.524 --> 07:02.664
<b>They made the absurd claim that
as Humbert's roommate, I was just as accountable.</b>
07:02.664 --> 07:07.624
<b>I mean, the daughter of a mere sixth-rank noble
asking me, the eldest son of a third-rank noble,</b>
07:07.624 --> 07:10.124
<b>"Have you no pride as a noble?"</b>
07:10.124 --> 07:12.464
<b>To have said such a thing...</b>
07:16.054 --> 07:19.974
<b>Still, Lord Raios, even if everything happened
the way you described,</b>
07:19.974 --> 07:22.304
<b>binding them with ropes
and locking them in your bedroom</b>
07:22.804 --> 07:26.434
<b>is surely a flagrant deviation
from the disciple punishment authority!</b>
07:26.434 --> 07:28.524
<b>Disciple punishment authority?</b>
07:29.274 --> 07:32.734
<b>Have you forgotten what the academy rules say?</b>
07:33.274 --> 07:38.614
<b>That "regarding all punishment,
higher law take precedence!"</b>
07:42.784 --> 07:47.164
<b>Higher law, as in the Taboo Index,
not to mention the Basic Imperial Law.</b>
07:47.164 --> 07:52.834
<b>In other words, as a third-rank noble's eldest son,
what I can exercise on those sixth-rank noble girls</b>
07:52.834 --> 07:57.044
<b>isn't the disciple punishment authority,
but the nobles' judicial authority...</b>
07:59.004 --> 08:02.094
<b>...as is my right!</b>
08:04.094 --> 08:07.764
<b>Hold still. I'm going to discipline you now.</b>
08:17.984 --> 08:19.194
<b>Stop it!</b>
08:19.194 --> 08:20.484
<b>Don't move, commoner!</b>
08:21.904 --> 08:28.704
<b>This is a lawful judgment by a noble according
to the Basic Imperial Law and the Taboo Index.</b>
08:28.704 --> 08:32.664
<b>And to obstruct such a judgment
is a serious criminal act.</b>
08:33.004 --> 08:37.884
<b>If you take even one step closer,
you'll become a criminal who has broken the law.</b>
08:38.134 --> 08:39.344
<b>That's...</b>
08:41.924 --> 08:42.974
<b><i>My legs!</i></b>
08:46.304 --> 08:47.894
<b>No! No!</b>
09:03.654 --> 09:06.664
<b>Senpai! Senpai!</b>
09:11.454 --> 09:16.044
<b><i>After all, there are things you shouldn't do,
even if it's not forbidden by law.</i></b>
09:16.714 --> 09:18.214
<b><i>On the other hand,</i></b>
09:18.214 --> 09:22.964
<b><i>there might be things you should do,
even if they're forbidden by law.</i></b>
09:30.974 --> 09:33.684
<b>N-No! No!</b>
09:33.894 --> 09:38.694
<b>No! Help me! Help me, Eugeo-senpai!</b>
09:38.694 --> 09:40.984
<b>Eugeo-senpai!</b>
09:41.194 --> 09:46.034
<b><i>Tiese and Ronie worked up the courage
to help their friend,</i></b>
09:46.034 --> 09:48.914
<b><i>only to be punished by such a cruel law.</i></b>
09:50.574 --> 09:56.624
<b><i>A law that can't deter Raios and Humbert,
who ensnared them and are now about to defile them.</i></b>
09:56.834 --> 10:00.084
<b><i>If upholding such a law is the "right" thing to do...</i></b>
10:01.924 --> 10:02.924
<b><i>I...</i></b>
10:03.964 --> 10:05.094
<b><i>I...</i></b>
10:19.404 --> 10:21.444
<b><i>What's... this?</i></b>
10:21.694 --> 10:24.904
<b><i>No, this is the same as that time.</i></b>
10:28.534 --> 10:32.034
<b><i>Unforgivable. It's absolutely...</i></b>
10:34.334 --> 10:35.704
<b><i>...unforgivable!</i></b>
10:37.044 --> 10:40.174
<b>No! No! Senpai!</b>
11:12.244 --> 11:16.334
<b>A-Arm... My arm is... bleeding!</b>
11:16.334 --> 11:19.964
<b>So much blood! My life is decreasing!</b>
11:20.964 --> 11:23.044
<b>Lord Raios, a sacred arts spell...</b>
11:23.504 --> 11:26.344
<b>No, a normal spell won't heal this in time!</b>
11:26.344 --> 11:29.554
<b>Your life! Please share some of your life!</b>
11:38.724 --> 11:45.404
<b>Magnificent! I've never seen
anyone commit such a crime before.</b>
11:48.114 --> 11:53.494
<b>Though the nobles' judicial authority generally
only applies to lesser nobles and tenant commoners,</b>
11:56.084 --> 12:00.754
<b>exceptions can be made
for heinous criminals who've broken a Taboo!</b>
12:06.134 --> 12:09.464
<b>I've never cut off someone's head
with my sword before.</b>
12:09.464 --> 12:11.804
<b>This will make me even more powerful!</b>
12:13.684 --> 12:15.724
<b>Disciple Eugeo...</b>
12:15.934 --> 12:18.314
<b>No, heinous criminal Eugeo!</b>
12:18.894 --> 12:24.274
<b>I, Raios Antinous, a third-rank nobleman's heir,
in accordance with the nobles' judicial authority,</b>
12:24.984 --> 12:26.524
<b>shall now execute you!</b>
12:41.044 --> 12:42.544
<b>Kirito.</b>
12:43.004 --> 12:44.504
<b>Put away your sword, Raios!</b>
12:44.794 --> 12:47.464
<b>I won't let you hurt Eugeo!</b>
12:49.384 --> 12:52.634
<b>So you finally showed up, Disciple Kirito?</b>
12:52.634 --> 12:55.594
<b>However, you're a bit too late.</b>
12:55.594 --> 12:59.684
<b>That country bumpkin there is a heinous criminal
who violated the Taboo Index!</b>
12:59.684 --> 13:01.724
<b>No, you stand back and watch.</b>
13:01.974 --> 13:07.524
<b>Just like those flowers that day,
witness this criminal's head being cut off!</b>
13:07.524 --> 13:10.154
<b>I don't care about your taboos and noble rights!</b>
13:10.574 --> 13:12.614
<b>Eugeo's my friend.</b>
13:12.614 --> 13:13.784
<b>And you...</b>
13:14.324 --> 13:17.074
<b>are scum lower than the goblins
from the land of darkness!</b>
13:24.374 --> 13:29.674
<b>To think that two country bumpkins
would commit such grave crimes.</b>
13:29.674 --> 13:33.054
<b>This means I can get rid of you both
at the same time.</b>
13:33.264 --> 13:38.684
<b>What a wonderful day!
Surely this is the guidance of Stacia!</b>
13:51.944 --> 13:53.324
<b>It's fine.</b>
14:09.584 --> 14:13.214
<b>My secret skill will demolish that piece of junk!</b>
14:13.214 --> 14:14.424
<b>Come on then, Raios!</b>
14:35.784 --> 14:38.534
<b>How's that? How's that?</b>
14:38.534 --> 14:45.204
<b>As if I, Raios Antinous, would fail to keep up
with a mere commoner like you!</b>
14:51.084 --> 14:51.754
<b>Kirito.</b>
15:16.944 --> 15:23.874
<b>Arms! My arms are...
bleeding... They're bleeding!</b>
15:26.954 --> 15:28.544
<b>Humbert!</b>
15:28.544 --> 15:31.294
<b>Bleeding... Stop my bleeding!</b>
15:31.584 --> 15:35.254
<b>Untie your rope, and bind my arms instead!</b>
15:35.884 --> 15:36.844
<b>No!</b>
15:36.844 --> 15:39.884
<b>U-Untying it will reduce my life!</b>
15:40.134 --> 15:42.804
<b>That order is a violation of the Taboo Index!</b>
15:42.804 --> 15:45.514
<b>Taboo? But...</b>
15:45.514 --> 15:48.684
<b>My blood is... Humbert!</b>
15:48.684 --> 15:50.774
<b>You... Taboo...</b>
15:50.774 --> 15:52.944
<b>But... My life will...</b>
15:55.064 --> 16:01.574
<b>Taboo... Life... Blood! Taboo!</b>
16:02.664 --> 16:12.964
<b>Life... Blood... Taboo...
Life... Taboo... Life... Taboo...</b>
16:13.504 --> 16:14.834
<b>Life...</b>
16:14.834 --> 16:16.344
<b>Use this to stop the bleeding.</b>
16:17.254 --> 16:20.844
<b>Life... Taboo... Life... Taboo...</b>
16:47.034 --> 16:48.624
<b><i>What was that?</i></b>
16:48.914 --> 16:50.664
<b><i>Did something happen to the Fluctlight?</i></b>
16:55.214 --> 16:56.334
<b>Lord Raios is...</b>
16:56.634 --> 16:59.344
<b>He's... He's... You... You...</b>
17:00.344 --> 17:03.304
<b>Murderer! Monster!</b>
17:13.394 --> 17:14.644
<b>I'm sorry.</b>
17:17.194 --> 17:19.984
<b>I'm sorry, Eugeo-senpai!</b>
17:19.984 --> 17:22.534
<b>It's... It's all my fault!</b>
17:23.404 --> 17:26.034
<b>No, it's not. You're not to blame.</b>
17:26.204 --> 17:30.204
<b>I... It's because I didn't think it through.</b>
17:30.454 --> 17:31.874
<b>You're not responsible.</b>
17:32.124 --> 17:33.834
<b>B-But...</b>
17:34.794 --> 17:35.834
<b>But...</b>
17:36.044 --> 17:39.424
<b>It's all right. After all, you and Ronie are safe.</b>
17:39.884 --> 17:41.344
<b>I'm the one who should apologize.</b>
17:42.554 --> 17:45.304
<b>Sorry. For subjecting you to such a horror.</b>
18:12.744 --> 18:14.254
<b><i>I've seen this before.</i></b>
18:14.544 --> 18:17.624
<b><i>Somewhere, long ago, I saw this before.</i></b>
18:20.634 --> 18:22.254
<b>Don't let Tiese and Ronie hear this!</b>
18:23.424 --> 18:26.094
<b><i>Singular unit detected.</i></b>
18:26.094 --> 18:28.054
<b><i>Tracing ID.</i></b>
18:28.384 --> 18:30.304
<b><i>Coordinates fixed.</i></b>
18:30.304 --> 18:32.264
<b><i>Report complete.</i></b>
18:47.864 --> 18:51.204
<b><i>Murderer! Monster!</i></b>
18:51.494 --> 18:55.954
<b>Now I'm just like those goblins.</b>
19:01.634 --> 19:05.174
<b>You're a human, Eugeo. Just like me.</b>
19:05.174 --> 19:09.474
<b>Every time you make a mistake,
you continue to struggle to find its meaning.</b>
19:09.934 --> 19:11.184
<b>You're a human.</b>
19:11.804 --> 19:12.934
<b>Kirito.</b>
19:52.094 --> 19:53.304
<b>Come out.</b>
20:00.144 --> 20:01.064
<b>Come closer.</b>
20:08.824 --> 20:12.324
<b>System Call. Generate Luminous Element.</b>
20:12.864 --> 20:15.034
<b>Reconstruct Lost Organ.</b>
20:18.794 --> 20:20.544
<b>Try to open your eye.</b>
20:20.544 --> 20:21.254
<b>Yes.</b>
20:28.424 --> 20:30.884
<b>Thank you very much, Ms. Azurica!</b>
20:30.884 --> 20:39.354
<b>No, actually, Disciple Eugeo and Disciple Kirito,
I need to hand you over to your escort.</b>
20:39.524 --> 20:42.314
<b>Before that, I'll say only this.</b>
20:44.144 --> 20:45.734
<b>Disciple Eugeo.</b>
20:46.154 --> 20:49.404
<b>You've broken a seal I was never able to break.</b>
20:49.784 --> 20:53.574
<b>Therefore, you should be able to go
where I was never able to go.</b>
20:54.204 --> 20:57.244
<b>Believe in that sword, and in your friend.</b>
20:58.624 --> 20:59.994
<b>Disciple Kirito.</b>
21:00.544 --> 21:04.674
<b>I was never able to get to know
who you really are.</b>
21:05.374 --> 21:10.054
<b>Nevertheless, when you reach that tower,
something will definitely happen.</b>
21:10.884 --> 21:15.844
<b>I'll be here, praying that you'll find the light.</b>
21:15.844 --> 21:16.934
<b>Forever.</b>
21:43.004 --> 21:48.044
<b><i>I've seen this combination
of blue and gold before somewhere.</i></b>
21:49.674 --> 21:54.014
<b>I am the overseer of the capital city of Centoria,
an Integrity Knight of the Axiom Church...</b>
22:04.434 --> 22:06.894
<b>Alice Synthesis Thirty.</b>
23:38.534 --> 23:41.574
<b>Next time: Central Cathedral.</b>

File diff suppressed because it is too large Load Diff