This commit is contained in:
limkokhole
2020-06-23 04:48:14 +08:00
parent 3d148ddf9c
commit d42c63efb3

View File

@@ -26,7 +26,7 @@ __credits__ = ['Inspired by https://github.com/SevenLines/pinterest-board-downlo
__license__ = 'MIT' __license__ = 'MIT'
# Version increase if the output file/dir naming incompatible with existing # Version increase if the output file/dir naming incompatible with existing
#, which might re-download for some files of previous version because of dir/filename not match #, which might re-download for some files of previous version because of dir/filename not match
__version__ = 1.1 __version__ = 1.2
__maintainer__ = 'Lim Kok Hole' __maintainer__ = 'Lim Kok Hole'
__email__ = 'limkokhole@gmail.com' __email__ = 'limkokhole@gmail.com'
__status__ = 'Production' __status__ = 'Production'
@@ -624,7 +624,8 @@ def write_log(arg_timestamp_log, save_dir, images, pin):
story += ('\n\nMetadata: ' + repr(image['rich_metadata'])) story += ('\n\nMetadata: ' + repr(image['rich_metadata']))
if story: if story:
try: try:
with open(log_path, 'a') as f: # Windows need utf-8
with open(log_path, 'a', encoding='utf-8') as f:
f.write('[ ' + str(log_i + 1 - skipped_total) + ' ] Pin Id: ' + str(image_id) + '\n') f.write('[ ' + str(log_i + 1 - skipped_total) + ' ] Pin Id: ' + str(image_id) + '\n')
f.write(story + '\n\n') f.write(story + '\n\n')
except OSError: # e.g. File name too long except OSError: # e.g. File name too long
@@ -637,7 +638,8 @@ def write_log(arg_timestamp_log, save_dir, images, pin):
return got_img return got_img
def sanitize(path): def sanitize(path):
return os.path.basename( path.replace('/', '|').replace(':', '..').strip() ) # trim multiple whitespaces
return os.path.basename( path.replace(' ', ' ').replace('/', '|').replace(':', '..').strip() )
def fetch_imgs(board, uname, board_name, section, arg_timestamp, arg_timestamp_log, arg_force_update def fetch_imgs(board, uname, board_name, section, arg_timestamp, arg_timestamp_log, arg_force_update
, arg_dir, arg_thread_max, IMGS_SESSION, IMG_SESSION, V_SESSION, arg_cut, fs_f_max): , arg_dir, arg_thread_max, IMGS_SESSION, IMG_SESSION, V_SESSION, arg_cut, fs_f_max):