From dfa57f24299d0fb0f988da2c30364e618a864d54 Mon Sep 17 00:00:00 2001 From: Olive Vaughn Date: Wed, 26 Aug 2026 00:46:29 -0400 Subject: [PATCH] trnscoder etc --- docker-compose.yml | 12 ++++++++++++ internal/api/api.go | 13 +++++++++++++ internal/library/library.go | 2 +- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 04d82d1..a5c5598 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,3 +11,15 @@ services: - MEDIA_DIR=/media - LISTEN_ADDR=:8091 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 diff --git a/internal/api/api.go b/internal/api/api.go index cd922fa..ac94c1b 100644 --- a/internal/api/api.go +++ b/internal/api/api.go @@ -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() diff --git a/internal/library/library.go b/internal/library/library.go index ad29c01..82e70c0 100644 --- a/internal/library/library.go +++ b/internal/library/library.go @@ -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)