Compare commits

1 Commits
Author SHA1 Message Date
sulzlep ab65e1dcf0 no idea 2024-11-26 21:36:25 +01:00
5 changed files with 52 additions and 4 deletions
View File
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 215 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

+1 -4
View File
@@ -5,7 +5,6 @@ from tkinter.font import Font
from PIL import Image
import requests
import urllib
import os
class RadioParadise(object):
@@ -81,6 +80,4 @@ def main():
if __name__=="__main__":
main()
os.remove("album_art.gif")
os.remove("album_art.jpg")
os._exit(0)
+51
View File
@@ -0,0 +1,51 @@
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
)
type Response struct {
Title string `json:"title"`
Artist string `json:"artist"`
Album string `json:"album"`
Year string `json:"year"`
Time int `json:"time"` // Seconds to go to end of song
Cover string `json:"cover"` // URL to picture of album cover
}
/*func getImage(url string) {
fmt.Println("Calling API and get image...")
client := &http.Client{}
req, err := http.NewRequest("GET", url, nil)
if err != nil {
fmt.Print(err.Error())
}
return req
}
*/
func main() {
fmt.Println("Calling API...")
client := &http.Client{}
req, err := http.NewRequest("GET", "https://api.radioparadise.com/api/now_playing", nil)
if err != nil {
fmt.Print(err.Error())
}
req.Header.Add("Accept", "application/json")
req.Header.Add("Content-Type", "application/json")
resp, err := client.Do(req)
defer resp.Body.Close()
bodyBytes, err := ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Print(err.Error())
}
var responseObject Response
json.Unmarshal(bodyBytes, &responseObject)
// coverUrl := responseObject.Cover
// getImage(coverUrl)
fmt.Printf("API Response as struct %+v\n", responseObject)
fmt.Println("Image from albumcover...")
}