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 (
|
||||
"container/ring"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
melody "gopkg.in/olahol/melody.v1"
|
||||
@ -26,15 +26,18 @@ func main() {
|
||||
})
|
||||
|
||||
r.POST("/update", func(c *gin.Context) {
|
||||
artist := c.PostForm("artist")
|
||||
title := c.PostForm("title")
|
||||
if artist == "" || title == "" {
|
||||
metadata := c.PostForm("metadata")
|
||||
|
||||
if strings.HasPrefix(metadata, "/srv/audio/") {
|
||||
metadata = strings.Replace(metadata, "/srv/audio/", "", 1)
|
||||
}
|
||||
|
||||
if metadata == "" {
|
||||
c.JSON(http.StatusBadRequest, gin.H{
|
||||
"status": "failure",
|
||||
})
|
||||
return
|
||||
}
|
||||
metadata := fmt.Sprintf("%s - %s", artist, title)
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": "success",
|
||||
|
Loading…
Reference in New Issue
Block a user