From 7b8b6858848340c8a4e645e2a2aeef0f2699d233 Mon Sep 17 00:00:00 2001 From: Patrick Sulzle Date: Wed, 27 Dec 2023 10:36:28 +0100 Subject: [PATCH] Initial submit and setup git --- get_rp.py | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100755 get_rp.py diff --git a/get_rp.py b/get_rp.py new file mode 100755 index 0000000..5273b88 --- /dev/null +++ b/get_rp.py @@ -0,0 +1,48 @@ +#!/bin/python3 + +from tkinter import * +from tkinter.font import Font +import requests + +def get_rp(): + # Get API respons + respons = requests.get("https://api.radioparadise.com/api/now_playing") + tekst = respons.json() + + # Selection of data to use + title = tekst["title"] + artist = tekst["artist"] + album = tekst["album"] + year = tekst["year"] + time = tekst["time"] +# path = tekst["cover_med"] + + # Return caller standard information + message = (f'Titel: {title}\nArtiest: {artist}\nAlbum: {album}\nJaar: {year}\nTijd: {time}') + return (message) + +def rp_quit(): + exit() + +def rp_refresh(): + rp_tekstbox.delete("1.0", "end") + rp_tekstbox.insert("1.0", get_rp()) + +if __name__=="__main__": + + window=Tk() + rp_font=Font(family="Courier", size=14) + rp_tekstbox=Text(window, height=6, width=50, font=rp_font) + + label=Label(window, font="Courier, 14", text="Radio Paradise now playing") + label.pack() + + button_quit=Button(window, text="Quit", command=rp_quit) + button_refresh=Button(window, text="Refresh", command=rp_refresh) + button_quit.pack(side=BOTTOM) + button_refresh.pack(side=TOP) + + rp_tekstbox.insert("1.0", get_rp()) + rp_tekstbox.pack() + + window.mainloop() \ No newline at end of file