From 28d2d77c199cf1a7d88a0148822d4343a966a51f Mon Sep 17 00:00:00 2001 From: Kevin F Date: Sun, 3 Oct 2021 22:04:34 +0000 Subject: [PATCH] fixed broken single images --- imgin/get.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/imgin/get.py b/imgin/get.py index 0259d0a..8deaccd 100644 --- a/imgin/get.py +++ b/imgin/get.py @@ -36,12 +36,12 @@ def get(url: str, write_dir: str, delete=True): url += "/layout/blog" if not album: - print('getting img', url) - url = 'https://i.imgur.com/' + url.rsplit('/', 1)[-1].replace('jpeg', '').replace('jpg', '') - with open(f'{write_dir}/{url[-12:]}', 'wb') as img: + print('Getting img', url) + url = 'https://i.imgur.com/' + url.rsplit('/', 1)[-1].replace('jpeg', 'jpg') + with open(f'{write_dir}/{url[-11:]}', 'wb') as img: img.write(requests.get(url).content) if delete: - Thread(target=delete_file, args=[f"{write_dir}/{url[-12:]}"]).start() + Thread(target=delete_file, args=[f"{write_dir}/{url[-11:]}"]).start() else: print('Detecting album/gallery images', url) soup = bs4.BeautifulSoup(requests.get(url).text, 'html.parser')