forked from rfa/radioweb
strip path
This commit is contained in:
parent
6fccb8f97c
commit
d7f2a21fdf
13
main.go
13
main.go
@ -2,8 +2,8 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"container/ring"
|
"container/ring"
|
||||||
"fmt"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
melody "gopkg.in/olahol/melody.v1"
|
melody "gopkg.in/olahol/melody.v1"
|
||||||
@ -26,15 +26,18 @@ func main() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
r.POST("/update", func(c *gin.Context) {
|
r.POST("/update", func(c *gin.Context) {
|
||||||
artist := c.PostForm("artist")
|
metadata := c.PostForm("metadata")
|
||||||
title := c.PostForm("title")
|
|
||||||
if artist == "" || title == "" {
|
if strings.HasPrefix(metadata, "/srv/audio/") {
|
||||||
|
metadata = strings.Replace(metadata, "/srv/audio/", "", 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
if metadata == "" {
|
||||||
c.JSON(http.StatusBadRequest, gin.H{
|
c.JSON(http.StatusBadRequest, gin.H{
|
||||||
"status": "failure",
|
"status": "failure",
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
metadata := fmt.Sprintf("%s - %s", artist, title)
|
|
||||||
|
|
||||||
c.JSON(http.StatusOK, gin.H{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
"status": "success",
|
"status": "success",
|
||||||
|
Loading…
Reference in New Issue
Block a user