1
0
forked from rfa/radioweb

strip path

This commit is contained in:
ron 2019-04-05 01:02:36 +02:00
parent 6fccb8f97c
commit d7f2a21fdf

13
main.go
View File

@ -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",