Allow serving of interactive CSVs directly to Handy (#3756)

* allow direct serve interactive CSVs to Handy
---------
Co-authored-by: kermieisinthehouse <kermie@isinthe.house>
This commit is contained in:
hontheinternet
2023-07-11 13:02:09 +09:00
committed by GitHub
parent 8e235a26ee
commit 4f0e0e1d99
12 changed files with 159 additions and 16 deletions

View File

@@ -72,6 +72,7 @@ func (rs sceneRoutes) Routes() chi.Router {
r.Get("/vtt/thumbs", rs.VttThumbs)
r.Get("/vtt/sprite", rs.VttSprite)
r.Get("/funscript", rs.Funscript)
r.Get("/interactive_csv", rs.InteractiveCSV)
r.Get("/interactive_heatmap", rs.InteractiveHeatmap)
r.Get("/caption", rs.CaptionLang)
@@ -374,6 +375,20 @@ func (rs sceneRoutes) Funscript(w http.ResponseWriter, r *http.Request) {
utils.ServeStaticFile(w, r, filepath)
}
func (rs sceneRoutes) InteractiveCSV(w http.ResponseWriter, r *http.Request) {
s := r.Context().Value(sceneKey).(*models.Scene)
filepath := video.GetFunscriptPath(s.Path)
// TheHandy directly only accepts interactive CSVs
csvBytes, err := manager.ConvertFunscriptToCSV(filepath)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
utils.ServeStaticContent(w, r, csvBytes)
}
func (rs sceneRoutes) InteractiveHeatmap(w http.ResponseWriter, r *http.Request) {
scene := r.Context().Value(sceneKey).(*models.Scene)
sceneHash := scene.GetHash(config.GetInstance().GetVideoFileNamingAlgorithm())