From 784926f8d3818dcef255c7abc36596cc05b4a777 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Forsl=C3=B6f?= Date: Mon, 31 Jan 2022 00:01:19 +0100 Subject: [PATCH 1/3] reduced rest api calls --- python/displayCoverArt.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/python/displayCoverArt.py b/python/displayCoverArt.py index 5b22f4c..1619154 100644 --- a/python/displayCoverArt.py +++ b/python/displayCoverArt.py @@ -2,6 +2,7 @@ import sys import logging from logging.handlers import RotatingFileHandler +from tkinter import image_names from getSongInfo import getSongInfo import requests from io import BytesIO @@ -43,15 +44,18 @@ default_image = os.path.join(dir, config['DEFAULT']['default_image']) print(default_image) matrix = RGBMatrix(options = options) + lastImageUrl = None try: while True: try: imageURL = getSongInfo(username, token_path)[1] - response = requests.get(imageURL) - image = Image.open(BytesIO(response.content)) - image.thumbnail((matrix.width, matrix.height), Image.ANTIALIAS) - matrix.SetImage(image.convert('RGB')) + if lastImageUrl != imageURL: + response = requests.get(imageURL) + image = Image.open(BytesIO(response.content)) + image.thumbnail((matrix.width, matrix.height), Image.ANTIALIAS) + matrix.SetImage(image.convert('RGB')) + lastImageUrl = imageURL time.sleep(1) except Exception as e: image = Image.open(default_image) From cc86235a27be31d2aa3bc96e01111b1791d219cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Forsl=C3=B6f?= <73438888+chickenTurtle@users.noreply.github.com> Date: Mon, 31 Jan 2022 00:03:05 +0100 Subject: [PATCH 2/3] Update displayCoverArt.py --- python/displayCoverArt.py | 1 - 1 file changed, 1 deletion(-) diff --git a/python/displayCoverArt.py b/python/displayCoverArt.py index 1619154..ef49218 100644 --- a/python/displayCoverArt.py +++ b/python/displayCoverArt.py @@ -2,7 +2,6 @@ import sys import logging from logging.handlers import RotatingFileHandler -from tkinter import image_names from getSongInfo import getSongInfo import requests from io import BytesIO From 1566813d27d05478a8bc19c1a8714a8f0fd8ccdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Forsl=C3=B6f?= <73438888+chickenTurtle@users.noreply.github.com> Date: Mon, 31 Jan 2022 00:03:54 +0100 Subject: [PATCH 3/3] Update displayCoverArt.py --- python/displayCoverArt.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/displayCoverArt.py b/python/displayCoverArt.py index ef49218..a9455b7 100644 --- a/python/displayCoverArt.py +++ b/python/displayCoverArt.py @@ -54,7 +54,7 @@ image = Image.open(BytesIO(response.content)) image.thumbnail((matrix.width, matrix.height), Image.ANTIALIAS) matrix.SetImage(image.convert('RGB')) - lastImageUrl = imageURL + lastImageUrl = imageURL time.sleep(1) except Exception as e: image = Image.open(default_image)