Skip to content

Commit

Permalink
Update kemono-dl.py
Browse files Browse the repository at this point in the history
if icon or banner doesn't download don't try to read downloaded or remove downloaded file
  • Loading branch information
AlphaSlayer1964 authored Oct 10, 2021
1 parent 932d528 commit bf6c823
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions kemono-dl.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import json
from PIL import Image

version = '2021.10.09'
version = '2021.10.10'

ap = argparse.ArgumentParser()
ap.add_argument("--version", action='store_true', help="Displays the current version then exits")
Expand Down Expand Up @@ -266,13 +266,13 @@ def get_pfp_banner(info):
# /icons/{service}/{creator_id}
# /banners/{service}/{creator_id}
file_name = '{username} [{user_id}] {}'.format(item, **info)
download_file(file_name, 'https://kemono.party/{}s/{service}/{user_id}'.format(item, **info).format(**info), folder_path)
try:
image = Image.open(os.path.join(folder_path, file_name))
image.save(os.path.join(folder_path, '{}.{}'.format(file_name, image.format.lower())), format=image.format)
os.remove(os.path.join(folder_path, file_name))
except:
os.remove(os.path.join(folder_path, file_name)) # site might return garbage data if no icon or banner is found
if download_file(file_name, 'https://kemono.party/{}s/{service}/{user_id}'.format(item, **info).format(**info), folder_path):
try:
image = Image.open(os.path.join(folder_path, file_name))
image.save(os.path.join(folder_path, '{}.{}'.format(file_name, image.format.lower())), format=image.format)
os.remove(os.path.join(folder_path, file_name))
except:
os.remove(os.path.join(folder_path, file_name)) # site might return garbage data if no icon or banner is found

def get_discord():
print('Discord is not currently supported by this downloader. (in progress)')
Expand Down

0 comments on commit bf6c823

Please sign in to comment.