Merge pull request 'dev' (#2) from dev into master

Reviewed-on: http://gitea.fritz.box:3000/sulzlep/get_rp/pulls/2
This commit is contained in:
2023-12-27 20:28:06 +01:00
4 changed files with 19 additions and 16 deletions
+2
View File
@@ -0,0 +1,2 @@
album_art.gif
album_art.jpg
BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 146 KiB

After

Width:  |  Height:  |  Size: 168 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 46 KiB

+16 -15
View File
@@ -26,10 +26,21 @@ def get_rp():
def rp_quit(): def rp_quit():
exit() exit()
# Refresh data from Radio Paradise when asked
def rp_refresh(): def rp_refresh():
rp_tekstbox.delete("1.0", "end") rp_tekstbox.delete("1.0", "end")
rp_tekstbox.insert("1.0", get_rp()[0]) rp_tekstbox.insert("1.0", get_rp()[0])
# Convert the jpg-file from RP to a manageable gif
get_and_convert_art()
# Load the image into the label
img = PhotoImage(file="album_art.gif", format='gif')
image_lbl.configure(image=img)
image_lbl.image=img
# Converts and stores a .jpg into a .gif
def get_and_convert_art():
rp_image_path = get_rp()[1] rp_image_path = get_rp()[1]
rp_image_file = requests.get(rp_image_path).content rp_image_file = requests.get(rp_image_path).content
@@ -40,17 +51,15 @@ def rp_refresh():
rp_image.save("album_art.gif") rp_image.save("album_art.gif")
rp_image.close() rp_image.close()
img = PhotoImage(file="album_art.gif", format='gif')
image_lbl.configure(image=img)
image_lbl.image=img
if __name__=="__main__": if __name__=="__main__":
window=Tk() window=Tk()
rp_font=Font(family="Courier", size=14) window.title("Radio Paradise")
rp_font=Font(family="Arial", size=14)
rp_tekstbox=Text(window, height=6, width=50, font=rp_font) rp_tekstbox=Text(window, height=6, width=50, font=rp_font)
label=Label(window, font="Courier, 14", text="Radio Paradise now playing") label=Label(window, font="Arial, 14", text="Radio Paradise now playing")
label.pack() label.pack()
button_quit=Button(window, text="Quit", command=rp_quit) button_quit=Button(window, text="Quit", command=rp_quit)
@@ -61,15 +70,7 @@ if __name__=="__main__":
rp_tekstbox.insert("1.0", get_rp()[0]) rp_tekstbox.insert("1.0", get_rp()[0])
rp_tekstbox.pack() rp_tekstbox.pack()
rp_image_path = get_rp()[1] get_and_convert_art()
rp_image_file = requests.get(rp_image_path).content
rp_file=open("album_art.jpg", 'wb')
rp_file.write(rp_image_file)
rp_file.close()
rp_image = Image.open("album_art.jpg")
rp_image.save("album_art.gif")
rp_image.close()
img = PhotoImage(file="album_art.gif", format='gif') img = PhotoImage(file="album_art.gif", format='gif')
image_lbl = Label(window, image=img) image_lbl = Label(window, image=img)