Add uguu.se artwork upload for private Navidrome instances #4
+2
-1
@@ -4,6 +4,7 @@ import (
|
|||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net/url"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/navidrome/navidrome/plugins/pdk/go/host"
|
"github.com/navidrome/navidrome/plugins/pdk/go/host"
|
||||||
@@ -115,7 +116,7 @@ func getImageViaUguu(username, trackID string) string {
|
|||||||
// uploadToImgbb uploads image data to imgbb and returns the display URL.
|
// uploadToImgbb uploads image data to imgbb and returns the display URL.
|
||||||
func uploadToImgbb(apiKey string, imageData []byte) (string, error) {
|
func uploadToImgbb(apiKey string, imageData []byte) (string, error) {
|
||||||
encoded := base64.StdEncoding.EncodeToString(imageData)
|
encoded := base64.StdEncoding.EncodeToString(imageData)
|
||||||
body := fmt.Sprintf("key=%s&image=%s&expiration=86400", apiKey, encoded)
|
body := fmt.Sprintf("key=%s&image=%s&expiration=86400", url.QueryEscape(apiKey), url.QueryEscape(encoded))
|
||||||
|
|
||||||
req := pdk.NewHTTPRequest(pdk.MethodPost, "https://api.imgbb.com/1/upload")
|
req := pdk.NewHTTPRequest(pdk.MethodPost, "https://api.imgbb.com/1/upload")
|
||||||
req.SetHeader("Content-Type", "application/x-www-form-urlencoded")
|
req.SetHeader("Content-Type", "application/x-www-form-urlencoded")
|
||||||
|
|||||||
+1
-1
@@ -46,7 +46,7 @@
|
|||||||
"type": "string",
|
"type": "string",
|
||||||
"title": "Image Hosting Service",
|
"title": "Image Hosting Service",
|
||||||
"description": "Upload artwork to a public image host so Discord can display it. Required when Navidrome is not publicly accessible.",
|
"description": "Upload artwork to a public image host so Discord can display it. Required when Navidrome is not publicly accessible.",
|
||||||
"enum": ["imgbb", "uguu"]
|
"enum": ["", "imgbb", "uguu"]
|
||||||
},
|
},
|
||||||
"imgbbapikey": {
|
"imgbbapikey": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
|||||||
Reference in New Issue
Block a user