fixed broken single images

This commit is contained in:
Kevin F 2021-10-03 22:04:34 +00:00
parent e93fd69ba8
commit 28d2d77c19

View File

@ -36,12 +36,12 @@ def get(url: str, write_dir: str, delete=True):
url += "/layout/blog" url += "/layout/blog"
if not album: if not album:
print('getting img', url) print('Getting img', url)
url = 'https://i.imgur.com/' + url.rsplit('/', 1)[-1].replace('jpeg', '').replace('jpg', '') url = 'https://i.imgur.com/' + url.rsplit('/', 1)[-1].replace('jpeg', 'jpg')
with open(f'{write_dir}/{url[-12:]}', 'wb') as img: with open(f'{write_dir}/{url[-11:]}', 'wb') as img:
img.write(requests.get(url).content) img.write(requests.get(url).content)
if delete: 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: else:
print('Detecting album/gallery images', url) print('Detecting album/gallery images', url)
soup = bs4.BeautifulSoup(requests.get(url).text, 'html.parser') soup = bs4.BeautifulSoup(requests.get(url).text, 'html.parser')