trnscoder etc
This commit is contained in:
parent
27ce5a4a92
commit
dfa57f2429
3 changed files with 26 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue