Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9db01a2dc7 | ||
|
|
c92be33c8f |
Binary file not shown.
|
Before Width: | Height: | Size: 215 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 51 KiB |
+4
-1
@@ -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)
|
||||||
|
|||||||
@@ -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...")
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user