Compare commits

2 Commits
Author SHA1 Message Date
sulzlep 9db01a2dc7 more graceful ending by deleting the graphics and cleanup 2024-10-07 18:12:34 +02:00
sulzlep c92be33c8f First commit after migration 2024-09-17 17:54:32 +02:00
5 changed files with 4 additions and 52 deletions
View File
BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 215 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 51 KiB

+4 -1
View File
@@ -5,6 +5,7 @@ from tkinter.font import Font
from PIL import Image from PIL import Image
import requests import requests
import urllib import urllib
import os
class RadioParadise(object): class RadioParadise(object):
@@ -80,4 +81,6 @@ def main():
if __name__=="__main__": if __name__=="__main__":
main() main()
os.remove("album_art.gif")
os.remove("album_art.jpg")
os._exit(0)
-51
View File
@@ -1,51 +0,0 @@
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...")
}