diff --git a/SubSonic.py b/SubSonic.py index 625536d..e3abe80 100644 --- a/SubSonic.py +++ b/SubSonic.py @@ -374,6 +374,18 @@ class SubpyConn: return requests.get(url + self._encodePayload(payload), stream=True) + # Saves cover art id + def getCoverArt(self, cover_art_id: str, path: str | None = None) -> None: + url = self.base_url + '/rest/getCoverArt?' + + payload = self._getBasePayload() + payload['id'] = cover_art_id + + r = requests.get(url + self._encodePayload(payload)) + + with open(path if path else 'cover.png', 'wb') as file: + file.write(r.content) + def getSong(self, song_id: str) -> Song: url = self.base_url + '/rest/getSong?' diff --git a/cover.png b/cover.png new file mode 100644 index 0000000..40feda5 Binary files /dev/null and b/cover.png differ diff --git a/main.py b/main.py index 866fa42..a7a2134 100644 --- a/main.py +++ b/main.py @@ -100,8 +100,10 @@ class SubPyPlayer: # for song in conn.getStarredSongs(): # print(song.title) -for song in conn.getPlaylist('9d76a86b-901f-4727-a2ec-01210157ff01'): - print(song.title) +# for song in conn.getPlaylist('9d76a86b-901f-4727-a2ec-01210157ff01'): +# print(song.title) + +conn.getCoverArt('al-1d2749574810ce63fa1c47b57e8e3e73_678fdf31') # player.play_song(echidna_id) diff --git a/rich-pixel.py b/rich-pixel.py new file mode 100644 index 0000000..65a31eb --- /dev/null +++ b/rich-pixel.py @@ -0,0 +1,10 @@ +from rich_pixels import Pixels +from rich.console import Console +from PIL import Image + +console = Console() + +with Image.open("cover.png") as image: + pixels = Pixels.from_image(image, resize=(60, 60)) + +console.print(pixels) \ No newline at end of file