66from PIL import Image
77from io import BytesIO
88from mtlogger import logger
9+ from natsort import natsorted
910
1011# settings
1112JPEG_FORMAT = 'JPEG'
@@ -49,7 +50,7 @@ def prompt_params():
4950def generate_covers (parent_folder , cover_type , override_existing ):
5051 cover_url = COVER_URL_MAP .get (cover_type )
5152
52- for folder_name in os .listdir (parent_folder ):
53+ for folder_name in natsorted ( os .listdir (parent_folder ) ):
5354 folder_path = os .path .join (parent_folder , folder_name )
5455
5556 if os .path .isdir (folder_path ) and folder_name .isdigit ():
@@ -60,9 +61,10 @@ def generate_covers(parent_folder, cover_type, override_existing):
6061
6162def process_folder (folder_path , folder_name , cover_url , override_existing ):
6263 cover_path = os .path .join (folder_path , TARGET_NAME )
64+ formatted_name = folder_name .rjust (7 )
6365
6466 if os .path .exists (cover_path ) and not override_existing :
65- logger .debug (f'Skipping { folder_name } . A { TARGET_NAME } file is already contained within .' )
67+ logger .debug (f'[ { formatted_name } ] SKIPPED: { TARGET_NAME } already exists .' )
6668 return
6769
6870 image_url = cover_url .format (folder_name )
@@ -90,9 +92,9 @@ def process_folder(folder_path, folder_name, cover_url, override_existing):
9092 cropped_img = resized_img .crop ((x0 , y0 , x1 , y1 ))
9193 cropped_img .save (cover_path , JPEG_FORMAT , quality = JPEG_QUALITY )
9294
93- logger .log (f'Generated cover image for game ID { folder_name } .' )
95+ logger .log (f'[ { formatted_name } ] SUCCESS: Generated cover image for game ID.' )
9496 else :
95- logger .error (f'Could not download image for game ID { folder_name } (status code { response .status_code } ).' )
97+ logger .error (f'[ { formatted_name } ] FAILED: Could not download image for game ID (status code { response .status_code } ).' )
9698
9799def play_notification_sound ():
98100 winsound .MessageBeep (winsound .MB_ICONASTERISK )
0 commit comments