trnscoder etc

This commit is contained in:
Olive Vaughn 2026-08-26 00:46:29 -04:00
parent 27ce5a4a92
commit dfa57f2429
3 changed files with 26 additions and 1 deletions

View file

@ -26,6 +26,7 @@ func NewRouter(lib *library.Library) http.Handler {
r.Get("/api/library/{id}", detailHandler(lib))
r.Get("/api/search", searchHandler(lib))
r.Get("/api/rescan", rescanHandler(lib))
r.Get("/api/stream/{id}", streamHandler(lib))
return r
}
@ -129,6 +130,18 @@ func searchHandler(lib *library.Library) http.HandlerFunc {
}
}
func streamHandler(lib *library.Library) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
id := chi.URLParam(r, "id")
_, fullPath, ok := lib.Get(id)
if !ok {
http.Error(w, "not found", http.StatusNotFound)
return
}
http.ServeFile(w, r, fullPath)
}
}
func rescanHandler(lib *library.Library) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
go lib.Scan()

View file

@ -61,7 +61,7 @@ func (l *Library) Scan() error {
RelPath: f.RelPath,
Size: f.Size,
ModTime: f.ModTime,
StreamURL: "/stream/vod/" + f.RelPath + "/index.m3u8",
StreamURL: "/vod/" + f.RelPath + "/index.m3u8",
fullPath: f.Path,
}
items = append(items, item)