Compare commits
2 Commits
ada3580a85
...
e29c7be4fa
Author | SHA1 | Date | |
---|---|---|---|
e29c7be4fa | |||
10e3025ddc |
19
main.go
19
main.go
@ -8,6 +8,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@ -79,10 +80,13 @@ func GetAllHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func GetFileHandler(w http.ResponseWriter, r *http.Request) {
|
func GetFileHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
vars := mux.Vars(r)
|
fileName, err := url.QueryUnescape(mux.Vars(r)["file"])
|
||||||
file := vars["file"]
|
if err != nil {
|
||||||
|
InternalServerError(w, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
http.ServeFile(w, r, filepath.Join(LibraryPath, ".songs", file))
|
http.ServeFile(w, r, filepath.Join(LibraryPath, ".songs", fileName))
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetPlaylistHandler(w http.ResponseWriter, r *http.Request) {
|
func GetPlaylistHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
@ -140,8 +144,13 @@ func GetAllFilesHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func GetEncodeFileHandler(w http.ResponseWriter, r *http.Request) {
|
func GetEncodeFileHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
fileName := mux.Vars(r)["file"]
|
vars := mux.Vars(r)
|
||||||
format := mux.Vars(r)["format"]
|
format := vars["format"]
|
||||||
|
fileName, err := url.QueryUnescape(vars["file"])
|
||||||
|
if err != nil {
|
||||||
|
InternalServerError(w, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
inputFilePath := filepath.Join(LibraryPath, ".songs", fileName)
|
inputFilePath := filepath.Join(LibraryPath, ".songs", fileName)
|
||||||
outputFilePath := filepath.Join(os.TempDir(), fmt.Sprintf("%d.%s", rand.Int(), format))
|
outputFilePath := filepath.Join(os.TempDir(), fmt.Sprintf("%d.%s", rand.Int(), format))
|
||||||
|
Loading…
Reference in New Issue
Block a user