2019-02-09 12:30:49 +00:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2019-10-17 20:42:12 +00:00
|
|
|
"net/http"
|
|
|
|
"strconv"
|
|
|
|
"strings"
|
|
|
|
|
2019-02-09 12:30:49 +00:00
|
|
|
"github.com/go-chi/chi"
|
2019-10-17 20:42:12 +00:00
|
|
|
"github.com/stashapp/stash/pkg/ffmpeg"
|
2019-02-14 23:42:52 +00:00
|
|
|
"github.com/stashapp/stash/pkg/logger"
|
|
|
|
"github.com/stashapp/stash/pkg/manager"
|
2019-11-04 21:38:33 +00:00
|
|
|
"github.com/stashapp/stash/pkg/manager/config"
|
2019-02-14 23:42:52 +00:00
|
|
|
"github.com/stashapp/stash/pkg/models"
|
|
|
|
"github.com/stashapp/stash/pkg/utils"
|
2019-02-09 12:30:49 +00:00
|
|
|
)
|
|
|
|
|
2021-01-18 01:23:20 +00:00
|
|
|
type sceneRoutes struct {
|
2021-05-20 06:58:43 +00:00
|
|
|
txnManager models.TransactionManager
|
|
|
|
sceneServer manager.SceneServer
|
2021-01-18 01:23:20 +00:00
|
|
|
}
|
2019-02-09 12:30:49 +00:00
|
|
|
|
|
|
|
func (rs sceneRoutes) Routes() chi.Router {
|
|
|
|
r := chi.NewRouter()
|
|
|
|
|
|
|
|
r.Route("/{sceneId}", func(r chi.Router) {
|
|
|
|
r.Use(SceneCtx)
|
2020-07-23 01:56:08 +00:00
|
|
|
|
|
|
|
// streaming endpoints
|
|
|
|
r.Get("/stream", rs.StreamDirect)
|
|
|
|
r.Get("/stream.mkv", rs.StreamMKV)
|
|
|
|
r.Get("/stream.webm", rs.StreamWebM)
|
|
|
|
r.Get("/stream.m3u8", rs.StreamHLS)
|
|
|
|
r.Get("/stream.ts", rs.StreamTS)
|
|
|
|
r.Get("/stream.mp4", rs.StreamMp4)
|
|
|
|
|
2019-02-09 12:30:49 +00:00
|
|
|
r.Get("/screenshot", rs.Screenshot)
|
|
|
|
r.Get("/preview", rs.Preview)
|
|
|
|
r.Get("/webp", rs.Webp)
|
|
|
|
r.Get("/vtt/chapter", rs.ChapterVtt)
|
2021-05-24 03:34:28 +00:00
|
|
|
r.Get("/funscript", rs.Funscript)
|
2019-02-09 12:30:49 +00:00
|
|
|
|
|
|
|
r.Get("/scene_marker/{sceneMarkerId}/stream", rs.SceneMarkerStream)
|
|
|
|
r.Get("/scene_marker/{sceneMarkerId}/preview", rs.SceneMarkerPreview)
|
|
|
|
})
|
|
|
|
r.With(SceneCtx).Get("/{sceneId}_thumbs.vtt", rs.VttThumbs)
|
|
|
|
r.With(SceneCtx).Get("/{sceneId}_sprite.jpg", rs.VttSprite)
|
|
|
|
|
|
|
|
return r
|
|
|
|
}
|
|
|
|
|
|
|
|
// region Handlers
|
|
|
|
|
2020-07-23 01:56:08 +00:00
|
|
|
func getSceneFileContainer(scene *models.Scene) ffmpeg.Container {
|
|
|
|
var container ffmpeg.Container
|
2020-04-09 22:38:34 +00:00
|
|
|
if scene.Format.Valid {
|
2020-07-23 01:56:08 +00:00
|
|
|
container = ffmpeg.Container(scene.Format.String)
|
2020-04-09 22:38:34 +00:00
|
|
|
} else { // container isn't in the DB
|
|
|
|
// shouldn't happen, fallback to ffprobe
|
2021-01-07 00:38:30 +00:00
|
|
|
tmpVideoFile, err := ffmpeg.NewVideoFile(manager.GetInstance().FFProbePath, scene.Path, false)
|
2020-04-09 22:38:34 +00:00
|
|
|
if err != nil {
|
|
|
|
logger.Errorf("[transcode] error reading video file: %s", err.Error())
|
2020-07-23 01:56:08 +00:00
|
|
|
return ffmpeg.Container("")
|
2020-04-09 22:38:34 +00:00
|
|
|
}
|
|
|
|
|
2020-07-23 01:56:08 +00:00
|
|
|
container = ffmpeg.MatchContainer(tmpVideoFile.Container, scene.Path)
|
2020-04-09 22:38:34 +00:00
|
|
|
}
|
|
|
|
|
2020-07-23 01:56:08 +00:00
|
|
|
return container
|
|
|
|
}
|
|
|
|
|
|
|
|
func (rs sceneRoutes) StreamDirect(w http.ResponseWriter, r *http.Request) {
|
|
|
|
scene := r.Context().Value(sceneKey).(*models.Scene)
|
|
|
|
|
2021-05-20 06:58:43 +00:00
|
|
|
ss := manager.SceneServer{
|
|
|
|
TXNManager: rs.txnManager,
|
|
|
|
}
|
|
|
|
ss.StreamSceneDirect(scene, w, r)
|
2020-07-23 01:56:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (rs sceneRoutes) StreamMKV(w http.ResponseWriter, r *http.Request) {
|
|
|
|
// only allow mkv streaming if the scene container is an mkv already
|
|
|
|
scene := r.Context().Value(sceneKey).(*models.Scene)
|
2019-10-17 20:42:12 +00:00
|
|
|
|
2020-07-23 01:56:08 +00:00
|
|
|
container := getSceneFileContainer(scene)
|
|
|
|
if container != ffmpeg.Matroska {
|
|
|
|
w.WriteHeader(http.StatusBadRequest)
|
|
|
|
w.Write([]byte("not an mkv file"))
|
2019-07-24 22:17:22 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2020-07-23 01:56:08 +00:00
|
|
|
rs.streamTranscode(w, r, ffmpeg.CodecMKVAudio)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (rs sceneRoutes) StreamWebM(w http.ResponseWriter, r *http.Request) {
|
|
|
|
rs.streamTranscode(w, r, ffmpeg.CodecVP9)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (rs sceneRoutes) StreamMp4(w http.ResponseWriter, r *http.Request) {
|
|
|
|
rs.streamTranscode(w, r, ffmpeg.CodecH264)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (rs sceneRoutes) StreamHLS(w http.ResponseWriter, r *http.Request) {
|
|
|
|
scene := r.Context().Value(sceneKey).(*models.Scene)
|
|
|
|
|
2021-01-07 00:38:30 +00:00
|
|
|
videoFile, err := ffmpeg.NewVideoFile(manager.GetInstance().FFProbePath, scene.Path, false)
|
2019-07-24 22:17:22 +00:00
|
|
|
if err != nil {
|
|
|
|
logger.Errorf("[stream] error reading video file: %s", err.Error())
|
|
|
|
return
|
|
|
|
}
|
2019-10-17 20:42:12 +00:00
|
|
|
|
2020-07-23 01:56:08 +00:00
|
|
|
logger.Debug("Returning HLS playlist")
|
2019-07-29 03:42:00 +00:00
|
|
|
|
2020-07-23 01:56:08 +00:00
|
|
|
// getting the playlist manifest only
|
|
|
|
w.Header().Set("Content-Type", ffmpeg.MimeHLS)
|
|
|
|
var str strings.Builder
|
2019-07-24 22:17:22 +00:00
|
|
|
|
2020-07-23 01:56:08 +00:00
|
|
|
ffmpeg.WriteHLSPlaylist(*videoFile, r.URL.String(), &str)
|
2020-04-09 22:38:34 +00:00
|
|
|
|
2020-07-23 01:56:08 +00:00
|
|
|
requestByteRange := utils.CreateByteRange(r.Header.Get("Range"))
|
|
|
|
if requestByteRange.RawString != "" {
|
|
|
|
logger.Debugf("Requested range: %s", requestByteRange.RawString)
|
|
|
|
}
|
2020-04-09 22:38:34 +00:00
|
|
|
|
2020-07-23 01:56:08 +00:00
|
|
|
ret := requestByteRange.Apply([]byte(str.String()))
|
|
|
|
rangeStr := requestByteRange.ToHeaderValue(int64(str.Len()))
|
|
|
|
w.Header().Set("Content-Range", rangeStr)
|
2020-04-09 22:38:34 +00:00
|
|
|
|
2020-07-23 01:56:08 +00:00
|
|
|
w.Write(ret)
|
|
|
|
}
|
2020-04-09 22:38:34 +00:00
|
|
|
|
2020-07-23 01:56:08 +00:00
|
|
|
func (rs sceneRoutes) StreamTS(w http.ResponseWriter, r *http.Request) {
|
|
|
|
rs.streamTranscode(w, r, ffmpeg.CodecHLS)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (rs sceneRoutes) streamTranscode(w http.ResponseWriter, r *http.Request, videoCodec ffmpeg.Codec) {
|
|
|
|
logger.Debugf("Streaming as %s", videoCodec.MimeType)
|
|
|
|
scene := r.Context().Value(sceneKey).(*models.Scene)
|
|
|
|
|
|
|
|
// needs to be transcoded
|
|
|
|
|
2021-01-07 00:38:30 +00:00
|
|
|
videoFile, err := ffmpeg.NewVideoFile(manager.GetInstance().FFProbePath, scene.Path, false)
|
2019-07-24 22:17:22 +00:00
|
|
|
if err != nil {
|
2020-07-23 01:56:08 +00:00
|
|
|
logger.Errorf("[stream] error reading video file: %s", err.Error())
|
2019-07-24 22:17:22 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2020-07-23 01:56:08 +00:00
|
|
|
// start stream based on query param, if provided
|
|
|
|
r.ParseForm()
|
|
|
|
startTime := r.Form.Get("start")
|
2020-10-22 04:02:27 +00:00
|
|
|
requestedSize := r.Form.Get("resolution")
|
2020-07-23 01:56:08 +00:00
|
|
|
|
|
|
|
var stream *ffmpeg.Stream
|
|
|
|
|
|
|
|
audioCodec := ffmpeg.MissingUnsupported
|
|
|
|
if scene.AudioCodec.Valid {
|
|
|
|
audioCodec = ffmpeg.AudioCodec(scene.AudioCodec.String)
|
|
|
|
}
|
2019-07-24 22:17:22 +00:00
|
|
|
|
2020-07-23 01:56:08 +00:00
|
|
|
options := ffmpeg.GetTranscodeStreamOptions(*videoFile, videoCodec, audioCodec)
|
|
|
|
options.StartTime = startTime
|
2021-04-11 23:31:33 +00:00
|
|
|
options.MaxTranscodeSize = config.GetInstance().GetMaxStreamingTranscodeSize()
|
2020-10-22 04:02:27 +00:00
|
|
|
if requestedSize != "" {
|
|
|
|
options.MaxTranscodeSize = models.StreamingResolutionEnum(requestedSize)
|
|
|
|
}
|
2019-07-24 22:17:22 +00:00
|
|
|
|
2020-07-23 01:56:08 +00:00
|
|
|
encoder := ffmpeg.NewEncoder(manager.GetInstance().FFMPEGPath)
|
|
|
|
stream, err = encoder.GetTranscodeStream(options)
|
2019-07-24 22:17:22 +00:00
|
|
|
|
|
|
|
if err != nil {
|
2020-07-23 01:56:08 +00:00
|
|
|
logger.Errorf("[stream] error transcoding video file: %s", err.Error())
|
|
|
|
w.WriteHeader(http.StatusBadRequest)
|
|
|
|
w.Write([]byte(err.Error()))
|
|
|
|
return
|
2019-07-24 22:17:22 +00:00
|
|
|
}
|
2020-07-23 01:56:08 +00:00
|
|
|
|
|
|
|
stream.Serve(w, r)
|
2019-02-09 12:30:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (rs sceneRoutes) Screenshot(w http.ResponseWriter, r *http.Request) {
|
2019-02-14 22:53:32 +00:00
|
|
|
scene := r.Context().Value(sceneKey).(*models.Scene)
|
2021-05-20 06:58:43 +00:00
|
|
|
|
|
|
|
ss := manager.SceneServer{
|
|
|
|
TXNManager: rs.txnManager,
|
2020-06-22 23:19:19 +00:00
|
|
|
}
|
2021-05-20 06:58:43 +00:00
|
|
|
ss.ServeScreenshot(scene, w, r)
|
2019-02-09 12:30:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (rs sceneRoutes) Preview(w http.ResponseWriter, r *http.Request) {
|
2019-02-14 22:53:32 +00:00
|
|
|
scene := r.Context().Value(sceneKey).(*models.Scene)
|
2021-04-11 23:31:33 +00:00
|
|
|
filepath := manager.GetInstance().Paths.Scene.GetStreamPreviewPath(scene.GetHash(config.GetInstance().GetVideoFileNamingAlgorithm()))
|
2020-07-23 02:51:35 +00:00
|
|
|
utils.ServeFileNoCache(w, r, filepath)
|
2019-02-09 12:30:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (rs sceneRoutes) Webp(w http.ResponseWriter, r *http.Request) {
|
2019-02-14 22:53:32 +00:00
|
|
|
scene := r.Context().Value(sceneKey).(*models.Scene)
|
2021-04-11 23:31:33 +00:00
|
|
|
filepath := manager.GetInstance().Paths.Scene.GetStreamPreviewImagePath(scene.GetHash(config.GetInstance().GetVideoFileNamingAlgorithm()))
|
2019-02-09 12:30:49 +00:00
|
|
|
http.ServeFile(w, r, filepath)
|
|
|
|
}
|
|
|
|
|
2021-01-18 01:23:20 +00:00
|
|
|
func (rs sceneRoutes) getChapterVttTitle(ctx context.Context, marker *models.SceneMarker) string {
|
2019-12-13 20:41:46 +00:00
|
|
|
if marker.Title != "" {
|
|
|
|
return marker.Title
|
|
|
|
}
|
|
|
|
|
2021-01-18 01:23:20 +00:00
|
|
|
var ret string
|
|
|
|
if err := rs.txnManager.WithReadTxn(ctx, func(repo models.ReaderRepository) error {
|
|
|
|
qb := repo.Tag()
|
|
|
|
primaryTag, err := qb.Find(marker.PrimaryTagID)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2019-12-13 20:41:46 +00:00
|
|
|
|
2021-01-18 01:23:20 +00:00
|
|
|
ret = primaryTag.Name
|
2019-12-13 20:41:46 +00:00
|
|
|
|
2021-01-18 01:23:20 +00:00
|
|
|
tags, err := qb.FindBySceneMarkerID(marker.ID)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, t := range tags {
|
|
|
|
ret += ", " + t.Name
|
|
|
|
}
|
2019-12-13 20:41:46 +00:00
|
|
|
|
2021-01-18 01:23:20 +00:00
|
|
|
return nil
|
|
|
|
}); err != nil {
|
|
|
|
panic(err)
|
2019-12-13 20:41:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret
|
|
|
|
}
|
|
|
|
|
2019-02-09 12:30:49 +00:00
|
|
|
func (rs sceneRoutes) ChapterVtt(w http.ResponseWriter, r *http.Request) {
|
2019-02-14 22:53:32 +00:00
|
|
|
scene := r.Context().Value(sceneKey).(*models.Scene)
|
2021-01-18 01:23:20 +00:00
|
|
|
var sceneMarkers []*models.SceneMarker
|
|
|
|
if err := rs.txnManager.WithReadTxn(r.Context(), func(repo models.ReaderRepository) error {
|
|
|
|
var err error
|
|
|
|
sceneMarkers, err = repo.SceneMarker().FindBySceneID(scene.ID)
|
|
|
|
return err
|
|
|
|
}); err != nil {
|
|
|
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
|
|
return
|
2019-02-09 12:30:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
vttLines := []string{"WEBVTT", ""}
|
2019-12-13 20:41:46 +00:00
|
|
|
for i, marker := range sceneMarkers {
|
|
|
|
vttLines = append(vttLines, strconv.Itoa(i+1))
|
2019-02-09 12:30:49 +00:00
|
|
|
time := utils.GetVTTTime(marker.Seconds)
|
2019-02-14 22:53:32 +00:00
|
|
|
vttLines = append(vttLines, time+" --> "+time)
|
2021-01-18 01:23:20 +00:00
|
|
|
vttLines = append(vttLines, rs.getChapterVttTitle(r.Context(), marker))
|
2019-02-09 12:30:49 +00:00
|
|
|
vttLines = append(vttLines, "")
|
|
|
|
}
|
|
|
|
vtt := strings.Join(vttLines, "\n")
|
|
|
|
|
|
|
|
w.Header().Set("Content-Type", "text/vtt")
|
|
|
|
_, _ = w.Write([]byte(vtt))
|
|
|
|
}
|
|
|
|
|
2021-05-24 03:34:28 +00:00
|
|
|
func (rs sceneRoutes) Funscript(w http.ResponseWriter, r *http.Request) {
|
|
|
|
scene := r.Context().Value(sceneKey).(*models.Scene)
|
|
|
|
funscript := utils.GetFunscriptPath(scene.Path)
|
|
|
|
utils.ServeFileNoCache(w, r, funscript)
|
|
|
|
}
|
|
|
|
|
2019-02-09 12:30:49 +00:00
|
|
|
func (rs sceneRoutes) VttThumbs(w http.ResponseWriter, r *http.Request) {
|
2019-02-14 22:53:32 +00:00
|
|
|
scene := r.Context().Value(sceneKey).(*models.Scene)
|
2019-02-09 12:30:49 +00:00
|
|
|
w.Header().Set("Content-Type", "text/vtt")
|
2021-04-11 23:31:33 +00:00
|
|
|
filepath := manager.GetInstance().Paths.Scene.GetSpriteVttFilePath(scene.GetHash(config.GetInstance().GetVideoFileNamingAlgorithm()))
|
2019-02-09 12:30:49 +00:00
|
|
|
http.ServeFile(w, r, filepath)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (rs sceneRoutes) VttSprite(w http.ResponseWriter, r *http.Request) {
|
2019-02-14 22:53:32 +00:00
|
|
|
scene := r.Context().Value(sceneKey).(*models.Scene)
|
2019-02-09 12:30:49 +00:00
|
|
|
w.Header().Set("Content-Type", "image/jpeg")
|
2021-04-11 23:31:33 +00:00
|
|
|
filepath := manager.GetInstance().Paths.Scene.GetSpriteImageFilePath(scene.GetHash(config.GetInstance().GetVideoFileNamingAlgorithm()))
|
2019-02-09 12:30:49 +00:00
|
|
|
http.ServeFile(w, r, filepath)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (rs sceneRoutes) SceneMarkerStream(w http.ResponseWriter, r *http.Request) {
|
2019-02-14 22:53:32 +00:00
|
|
|
scene := r.Context().Value(sceneKey).(*models.Scene)
|
2019-02-09 12:30:49 +00:00
|
|
|
sceneMarkerID, _ := strconv.Atoi(chi.URLParam(r, "sceneMarkerId"))
|
2021-01-18 01:23:20 +00:00
|
|
|
var sceneMarker *models.SceneMarker
|
|
|
|
if err := rs.txnManager.WithReadTxn(r.Context(), func(repo models.ReaderRepository) error {
|
|
|
|
var err error
|
|
|
|
sceneMarker, err = repo.SceneMarker().Find(sceneMarkerID)
|
|
|
|
return err
|
|
|
|
}); err != nil {
|
|
|
|
logger.Warnf("Error when getting scene marker for stream: %s", err.Error())
|
|
|
|
http.Error(w, http.StatusText(500), 500)
|
2019-02-09 12:30:49 +00:00
|
|
|
return
|
|
|
|
}
|
2021-04-11 23:31:33 +00:00
|
|
|
filepath := manager.GetInstance().Paths.SceneMarkers.GetStreamPath(scene.GetHash(config.GetInstance().GetVideoFileNamingAlgorithm()), int(sceneMarker.Seconds))
|
2019-02-09 12:30:49 +00:00
|
|
|
http.ServeFile(w, r, filepath)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (rs sceneRoutes) SceneMarkerPreview(w http.ResponseWriter, r *http.Request) {
|
2019-02-14 22:53:32 +00:00
|
|
|
scene := r.Context().Value(sceneKey).(*models.Scene)
|
2019-02-09 12:30:49 +00:00
|
|
|
sceneMarkerID, _ := strconv.Atoi(chi.URLParam(r, "sceneMarkerId"))
|
2021-01-18 01:23:20 +00:00
|
|
|
var sceneMarker *models.SceneMarker
|
|
|
|
if err := rs.txnManager.WithReadTxn(r.Context(), func(repo models.ReaderRepository) error {
|
|
|
|
var err error
|
|
|
|
sceneMarker, err = repo.SceneMarker().Find(sceneMarkerID)
|
|
|
|
return err
|
|
|
|
}); err != nil {
|
|
|
|
logger.Warnf("Error when getting scene marker for stream: %s", err.Error())
|
|
|
|
http.Error(w, http.StatusText(500), 500)
|
2019-02-09 12:30:49 +00:00
|
|
|
return
|
|
|
|
}
|
2021-04-11 23:31:33 +00:00
|
|
|
filepath := manager.GetInstance().Paths.SceneMarkers.GetStreamPreviewImagePath(scene.GetHash(config.GetInstance().GetVideoFileNamingAlgorithm()), int(sceneMarker.Seconds))
|
2019-06-01 16:48:28 +00:00
|
|
|
|
|
|
|
// If the image doesn't exist, send the placeholder
|
|
|
|
exists, _ := utils.FileExists(filepath)
|
|
|
|
if !exists {
|
|
|
|
w.Header().Set("Content-Type", "image/png")
|
|
|
|
w.Header().Set("Cache-Control", "no-store")
|
|
|
|
_, _ = w.Write(utils.PendingGenerateResource)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2019-02-09 12:30:49 +00:00
|
|
|
http.ServeFile(w, r, filepath)
|
|
|
|
}
|
|
|
|
|
|
|
|
// endregion
|
|
|
|
|
|
|
|
func SceneCtx(next http.Handler) http.Handler {
|
|
|
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
|
|
sceneIdentifierQueryParam := chi.URLParam(r, "sceneId")
|
|
|
|
sceneID, _ := strconv.Atoi(sceneIdentifierQueryParam)
|
|
|
|
|
|
|
|
var scene *models.Scene
|
2021-01-18 01:23:20 +00:00
|
|
|
manager.GetInstance().TxnManager.WithReadTxn(r.Context(), func(repo models.ReaderRepository) error {
|
|
|
|
qb := repo.Scene()
|
|
|
|
if sceneID == 0 {
|
|
|
|
// determine checksum/os by the length of the query param
|
|
|
|
if len(sceneIdentifierQueryParam) == 32 {
|
|
|
|
scene, _ = qb.FindByChecksum(sceneIdentifierQueryParam)
|
|
|
|
} else {
|
|
|
|
scene, _ = qb.FindByOSHash(sceneIdentifierQueryParam)
|
|
|
|
}
|
2020-08-09 23:20:04 +00:00
|
|
|
} else {
|
2021-01-18 01:23:20 +00:00
|
|
|
scene, _ = qb.Find(sceneID)
|
2020-08-09 23:20:04 +00:00
|
|
|
}
|
2021-01-18 01:23:20 +00:00
|
|
|
|
|
|
|
return nil
|
|
|
|
})
|
2019-02-09 12:30:49 +00:00
|
|
|
|
2020-08-09 23:20:04 +00:00
|
|
|
if scene == nil {
|
2019-02-09 12:30:49 +00:00
|
|
|
http.Error(w, http.StatusText(404), 404)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2019-02-14 22:53:32 +00:00
|
|
|
ctx := context.WithValue(r.Context(), sceneKey, scene)
|
2019-02-09 12:30:49 +00:00
|
|
|
next.ServeHTTP(w, r.WithContext(ctx))
|
|
|
|
})
|
2019-02-14 22:53:32 +00:00
|
|
|
}
|