From 2071f80f32fc36984d8a01b10495a73a99a254af Mon Sep 17 00:00:00 2001 From: Marekkon5 Date: Fri, 19 Feb 2021 10:52:24 +0100 Subject: [PATCH] Album art patch --- beatport.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/beatport.py b/beatport.py index c405204..6ba84d0 100644 --- a/beatport.py +++ b/beatport.py @@ -129,7 +129,13 @@ def __init__(self, data: dict): self.publish_date = datetime.datetime.strptime(data['date']['published'], '%Y-%m-%d') def art(self, resolution: int): - return self._art.replace('{x}', str(resolution)).replace('{y}', str(resolution)).replace('{w}', str(resolution)).replace('{h}', str(resolution)) + if '{x}' in self._art or '{w}' in self._art: + return self._art.replace('{x}', str(resolution)).replace('{y}', str(resolution)).replace('{w}', str(resolution)).replace('{h}', str(resolution)) + if '/image_size/' not in self._art: + return self._art + + #Parse non-dynamic dynamic image + return re.sub(r'\/image_size\/\d+x\d+\/', f'/image_size/{resolution}x{resolution}/', self._art) #Convert Beatport key to ID3 def id3key(self):