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

@ -11,3 +11,15 @@ services:
- MEDIA_DIR=/media - MEDIA_DIR=/media
- LISTEN_ADDR=:8091 - LISTEN_ADDR=:8091
restart: unless-stopped restart: unless-stopped
transcode:
image: m1k1o/go-transcode
devices:
- /dev/dri:/dev/dri
volumes:
- /mnt/user/media:/media:ro
ports:
- "8090:8080"
environment:
- TRANSCODE_BIND=:8080
restart: unless-stopped

View file

@ -26,6 +26,7 @@ func NewRouter(lib *library.Library) http.Handler {
r.Get("/api/library/{id}", detailHandler(lib)) r.Get("/api/library/{id}", detailHandler(lib))
r.Get("/api/search", searchHandler(lib)) r.Get("/api/search", searchHandler(lib))
r.Get("/api/rescan", rescanHandler(lib)) r.Get("/api/rescan", rescanHandler(lib))
r.Get("/api/stream/{id}", streamHandler(lib))
return r 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 { func rescanHandler(lib *library.Library) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) { return func(w http.ResponseWriter, r *http.Request) {
go lib.Scan() go lib.Scan()

View file

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