Skip to content

Commit

Permalink
fix issue with blocked download of thumbnail for part details
Browse files Browse the repository at this point in the history
  • Loading branch information
markusdd authored and Bouni committed Mar 6, 2024
1 parent 20d6fd2 commit 2d46d8a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion partdetails.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,10 @@ def openpdf(self, *_):

def get_scaled_bitmap(self, url, width, height):
"""Download a picture from a URL and convert it into a wx Bitmap."""
content = requests.get(url, timeout=10).content
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36"
} # pretend we are browser, otherwise their cloud service blocks the request
content = requests.get(url, headers=headers, timeout=10).content
io_bytes = io.BytesIO(content)
image = wx.Image(io_bytes)
image = image.Scale(width, height, wx.IMAGE_QUALITY_HIGH)
Expand Down

0 comments on commit 2d46d8a

Please sign in to comment.