From c233767e6dbde6cd2c833a9232edc5710550336d Mon Sep 17 00:00:00 2001 From: limkokhole Date: Sat, 20 Jun 2020 16:38:05 +0800 Subject: [PATCH] [1] Unquotes url [2] description None --- pinterest-downloader.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pinterest-downloader.py b/pinterest-downloader.py index 863b51e..08bd677 100644 --- a/pinterest-downloader.py +++ b/pinterest-downloader.py @@ -329,7 +329,8 @@ def download_img(image, save_dir, arg_force_update, IMG_SESSION, V_SESSION, arg_ human_fname = '' if ('grid_title' in image) and image['grid_title']: human_fname = '_' + image['grid_title'] - if ('description' in image) and image['description'].strip(): + # Got case NoneType + if ('description' in image) and image['description'] and image['description'].strip(): human_fname = '_'.join((human_fname, image['description'].strip())) if ('created_at' in image) and image['created_at']: # Don't want ':' become '..' later, so remove ':' early @@ -612,7 +613,8 @@ def write_log(arg_timestamp_log, save_dir, images, pin): # if use 'title' may returns dict {'format': 'Find more ideas', 'text': None, 'args': []} if ('grid_title' in image) and image['grid_title']: story = '\nTitle: ' + image['grid_title'] - if ('description' in image) and image['description'].strip(): + # Got case NoneType + if ('description' in image) and image['description'] and image['description'].strip(): story += '\nDescription: ' + image['description'].strip() if ('created_at' in image) and image['created_at']: story += '\nCreated at: ' + image['created_at'] @@ -807,6 +809,9 @@ def main(): return url_path = args.path.strip().split('?')[0].split('#')[0] + # Convert % format of unicode url when copied from Firefox + # This is important especially section need compare the section name later + url_path = urllib.parse.unquote_plus(url_path) if url_path.endswith('/'): url_path = url_path[:-1] if '://' in url_path: