From c398b53f4d13c9b3dbcad51f007dd76a60e1edb7 Mon Sep 17 00:00:00 2001 From: Bart Kleijngeld Date: Mon, 9 Aug 2021 16:34:04 +0200 Subject: [PATCH] Using requests HTTP session for better performance --- bin/miniplayer | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/bin/miniplayer b/bin/miniplayer index bf0d6cb..d55ef09 100755 --- a/bin/miniplayer +++ b/bin/miniplayer @@ -143,6 +143,11 @@ class Player: self.last_song = None + # Album art HTTP server + + if art_config.get("http_base_url"): + self.art_http_session = requests.Session() + # Album art only flag self.album_art_only = player_config.getboolean("album_art_only", False) @@ -338,11 +343,11 @@ class Player: album = os.path.dirname(song_file) - for cover_filename in art_config.get("http_cover_filenames").split(): + for cover_filename in art_config.get("http_cover_filenames", "cover.jpg").split(): album_art_url = posixpath.join(base_url, album, cover_filename) try: - album_art_resp = requests.get(album_art_url) + album_art_resp = self.art_http_session.get(album_art_url) except requests.RequestException: # If any exception occurs, simply give up and show default art. self.drawDefaultAlbumArt()