62 lines
1.5 KiB
Python
Executable File
62 lines
1.5 KiB
Python
Executable File
#!/bin/python3
|
|
|
|
from tkinter import *
|
|
from tkinter.font import Font
|
|
from PIL import Image
|
|
import requests
|
|
import urllib
|
|
|
|
|
|
class RadioParadise(object):
|
|
def __init__(self):
|
|
self.title=None
|
|
self.artist=None
|
|
self.album=None
|
|
self.year=None
|
|
self.time=None
|
|
self.jpg_path=None
|
|
|
|
def rp_reload_api(self):
|
|
respons=requests.get("https://api.radioparadise.com/api/now_playing")
|
|
rp_dict=respons.json()
|
|
self.title=rp_dict["title"]
|
|
self.artist=rp_dict["artist"]
|
|
self.album=rp_dict["album"]
|
|
self.year=rp_dict["year"]
|
|
self.time=rp_dict["time"]
|
|
self.jpg_path=rp_dict["cover"]
|
|
|
|
class AlbumCover(RadioParadise):
|
|
def __init__(self, path):
|
|
self.jpg_path=path
|
|
|
|
def store_albumcover(self):
|
|
rp_raw_image=requests.get(self.jpg_path).content
|
|
rp_file=open("album_art.jpg", "wb")
|
|
rp_file.write("rp_raw_image")
|
|
rp_file.close()
|
|
rp_convert_img=Image.open("album_art.jpg")
|
|
rp_convert_img.save("album_art.gif")
|
|
rp_convert_img.close()
|
|
|
|
|
|
class RPViewer(Tk):
|
|
def __init__(self, *args, **kwargs):
|
|
super().__init__(*args, **kwargs)
|
|
self.title("Radio Paradise Viewer")
|
|
self.geometry("500x740")
|
|
self.resizable(False,False)
|
|
|
|
|
|
def main():
|
|
rp_play=RadioParadise()
|
|
rp_play.rp_reload_api()
|
|
print (rp_play.title)
|
|
print(rp_play.artist)
|
|
print (rp_play.time)
|
|
app=RPViewer()
|
|
app.mainloop()
|
|
|
|
if __name__=="__main__":
|
|
main()
|
|
|