Fix reorder causes duplicated log
This commit is contained in:
@@ -847,6 +847,7 @@ def write_log(arg_timestamp_log, save_dir, images, pin, arg_cut, break_from_late
|
|||||||
|
|
||||||
if images:
|
if images:
|
||||||
index_last = 0
|
index_last = 0
|
||||||
|
existing_indexes = []
|
||||||
if break_from_latest_pin and not arg_timestamp_log:
|
if break_from_latest_pin and not arg_timestamp_log:
|
||||||
try:
|
try:
|
||||||
with open(log_path) as f:
|
with open(log_path) as f:
|
||||||
@@ -854,6 +855,8 @@ def write_log(arg_timestamp_log, save_dir, images, pin, arg_cut, break_from_late
|
|||||||
index_last_tmp = index_line[-1].split('[ ')[1].split(' ]')[0]
|
index_last_tmp = index_line[-1].split('[ ')[1].split(' ]')[0]
|
||||||
if index_last_tmp.isdigit():
|
if index_last_tmp.isdigit():
|
||||||
index_last = int(index_last_tmp)
|
index_last = int(index_last_tmp)
|
||||||
|
for l in index_line:
|
||||||
|
existing_indexes.append(l.split('[ ')[1].split(' ] Pin Id: ')[1].strip())
|
||||||
except (FileNotFoundError, OSError, KeyError, TypeError):
|
except (FileNotFoundError, OSError, KeyError, TypeError):
|
||||||
cprint(''.join([ HIGHER_YELLOW, '%s' % ('\nWrite log increment from last log stored index failed with -u. Fallback to -lt\n\n') ]), attrs=BOLD_ONLY, end='' )
|
cprint(''.join([ HIGHER_YELLOW, '%s' % ('\nWrite log increment from last log stored index failed with -u. Fallback to -lt\n\n') ]), attrs=BOLD_ONLY, end='' )
|
||||||
log_timestamp = 'log-pinterest-downloader_' + datetime.now().strftime('%Y-%m-%d %H.%M.%S')
|
log_timestamp = 'log-pinterest-downloader_' + datetime.now().strftime('%Y-%m-%d %H.%M.%S')
|
||||||
@@ -864,12 +867,16 @@ def write_log(arg_timestamp_log, save_dir, images, pin, arg_cut, break_from_late
|
|||||||
with open(log_path, 'w') as f: # Reset before append
|
with open(log_path, 'w') as f: # Reset before append
|
||||||
f.write('Pinterest Downloader: Version ' + str(__version__) + '\n\n') # Easy to recognize if future want to change something
|
f.write('Pinterest Downloader: Version ' + str(__version__) + '\n\n') # Easy to recognize if future want to change something
|
||||||
skipped_total = 0
|
skipped_total = 0
|
||||||
|
#print(existing_indexes)
|
||||||
for log_i, image in enumerate(images):
|
for log_i, image in enumerate(images):
|
||||||
if 'id' not in image:
|
if 'id' not in image:
|
||||||
skipped_total+=1
|
skipped_total+=1
|
||||||
continue
|
continue
|
||||||
got_img = True
|
got_img = True
|
||||||
image_id = image['id']
|
image_id = image['id']
|
||||||
|
if image_id in existing_indexes:
|
||||||
|
# Still got_img True to try re-download flow since only want to ensure log don't want duplicated if reorder
|
||||||
|
continue
|
||||||
#print('got img: ' + image_id) # Possible got id but empty section
|
#print('got img: ' + image_id) # Possible got id but empty section
|
||||||
#, so still failed to use got_img to skip showing estimated 1 image if actually empty
|
#, so still failed to use got_img to skip showing estimated 1 image if actually empty
|
||||||
story = ''
|
story = ''
|
||||||
|
|||||||
Reference in New Issue
Block a user