New section/boards case. Clean code/comment.

This commit is contained in:
limkokhole
2022-01-23 23:32:30 +08:00
parent 2bac9d75dc
commit 8e0070714b
2 changed files with 12 additions and 19 deletions

View File

@@ -68,10 +68,12 @@ Download all images/videos from Pinterest user/board/section.
newer images reorder below local highest Pin ID image newer images reorder below local highest Pin ID image
and missed unless fetch all pages. and missed unless fetch all pages.
-ua, --update-all Update all folders in current directory recursively -ua, --update-all Update all folders in current directory recursively
based on theirs urls-pinterest-downloader.urls. based on theirs urls-pinterest-downloader.urls. New
Options other than -c, -j, -rs, -ps/p will ignore. -c section will not downlaod. New board may download if
must same if provided previously or else filename not previously download by username Options other than -c,
same will re-download. Not recommend to use -c at all. -j, -rs, -ps/p will ignore. -c must same if provided
previously or else filename not same will re-download.
Not recommend to use -c at all.
-es, --exclude-section -es, --exclude-section
Exclude sections if download from username or board. Exclude sections if download from username or board.
-ps HTTPS_PROXY, --https-proxy HTTPS_PROXY -ps HTTPS_PROXY, --https-proxy HTTPS_PROXY
@@ -129,7 +131,7 @@ Download all images/videos from Pinterest user/board/section.
Input URL: https://www.pinterest.com/antonellomiglio/computer/ Input URL: https://www.pinterest.com/antonellomiglio/computer/
Folder URL: https://www.pinterest.com/antonellomiglio/computer/ Folder URL: https://www.pinterest.com/antonellomiglio/computer/
##### Or log-pinterest-downloader.log (only exist if any folder item contains title/description/link/metadata). ##### Or log-pinterest-downloader.log (only exist if any folder item contains title/description/link/metadata/date).
xb@dnxb:~/Downloads/pinterest/pinterest-downloader$ head -28 comp/antonellomiglio/Computer/log-pinterest-downloader.log xb@dnxb:~/Downloads/pinterest/pinterest-downloader$ head -28 comp/antonellomiglio/Computer/log-pinterest-downloader.log
Pinterest Downloader: Version 1.9 Pinterest Downloader: Version 1.9

View File

@@ -1255,7 +1255,6 @@ Please ensure your username/boardname/[section] or link has media item.\n') )
def update_all( arg_thread_max :int, arg_cut :int, arg_rescrape :bool def update_all( arg_thread_max :int, arg_cut :int, arg_rescrape :bool
, arg_https_proxy :str, arg_http_proxy :str): , arg_https_proxy :str, arg_http_proxy :str):
#return quit('--update-all temporary disabled.')
bk_cwd = os.path.abspath(os.getcwd()) bk_cwd = os.path.abspath(os.getcwd())
cwd_component_total = len(PurePath(os.path.abspath(bk_cwd)).parts[:]) cwd_component_total = len(PurePath(os.path.abspath(bk_cwd)).parts[:])
imgs_f = [] imgs_f = []
@@ -1286,17 +1285,10 @@ def update_all( arg_thread_max :int, arg_cut :int, arg_rescrape :bool
# Safeguard to avoid travel to parent of current directory # Safeguard to avoid travel to parent of current directory
if len(dir_split) < cwd_component_total: if len(dir_split) < cwd_component_total:
cprint(''.join([ HIGHER_YELLOW, '%s' % ('\n' + 'Update from parent directory of current directory is forbidden. Skipped.\n' cprint(''.join([ HIGHER_YELLOW, '%s' % ('\n' + 'Update from parent directory of current directory is forbidden. Skipped.\n'
+ 'You should cd to parent directory to update this folder.\nInput url: ' + 'You should cd to parent directory to update this folder:'
+ input_url + '\nFolder url: ' + folder_url + '\nurls file: ' + f + '\nInput url: '+ input_url + '\nFolder url: ' + folder_url
+ '\nurls file: ' + f + '\ncd back steps: ' + str(cd_back_count) + '\nParent directory: ' + '\nParent directory: ' + dir_origin
+ dir_origin + '\nCurrent directory: ' + bk_cwd + '\n\n') ])) + '\nCurrent directory: ' + bk_cwd + '\n\n') ]))
# geek log:
#cprint(''.join([ HIGHER_YELLOW, '%s' % ('\n' + 'Update from parent directory of current directory is forbidden. Skipped.\nInput url: '
# + input_url + '\nFolder url: ' + folder_url
# + '\nurls file: ' + f + '\ncd back count: ' + str(cd_back_count) + '\ndir origin: '
# + dir_origin + '\ncwd: ' + bk_cwd + '\ndir origin len: ' + str(len(dir_split))
# + '\ncwd component total: ' + str(cwd_component_total) + '\n\n') ])
# , attrs=BOLD_ONLY, end='' )
break break
if dir_origin in urls_map: if dir_origin in urls_map:
# cd_back_count: 3 means section, 2 means board, 1 means username # cd_back_count: 3 means section, 2 means board, 1 means username
@@ -1313,8 +1305,6 @@ def update_all( arg_thread_max :int, arg_cut :int, arg_rescrape :bool
urls_map[dir_origin] = {'info': [ {'url': input_url, 'cd': cd_back_count} ], 'username': True if (cd_back_count == 1) else False} urls_map[dir_origin] = {'info': [ {'url': input_url, 'cd': cd_back_count} ], 'username': True if (cd_back_count == 1) else False}
break # Only read headers break # Only read headers
bk_cwd = os.getcwd()
pre_calc_total = 0 pre_calc_total = 0
for i, (dir_origin, map_d) in enumerate(urls_map.items()): for i, (dir_origin, map_d) in enumerate(urls_map.items()):
got_username = map_d['username'] got_username = map_d['username']
@@ -1575,6 +1565,7 @@ def run_direct_main():
This option disable that behavior and re-scrape all, use it when you feel missing images somewhere or incomplete download.\n\ This option disable that behavior and re-scrape all, use it when you feel missing images somewhere or incomplete download.\n\
This issue is because Pinterest only lists reordered as you see in the webpage which possible newer images reorder below local highest Pin ID image and missed unless fetch all pages.') This issue is because Pinterest only lists reordered as you see in the webpage which possible newer images reorder below local highest Pin ID image and missed unless fetch all pages.')
arg_parser.add_argument('-ua', '--update-all', dest='update_all', action='store_true', help='Update all folders in current directory recursively based on theirs urls-pinterest-downloader.urls.\n\ arg_parser.add_argument('-ua', '--update-all', dest='update_all', action='store_true', help='Update all folders in current directory recursively based on theirs urls-pinterest-downloader.urls.\n\
New section will not downlaod. New board may download if previously download by username\n\
Options other than -c, -j, -rs, -ps/p will ignore.\n\ Options other than -c, -j, -rs, -ps/p will ignore.\n\
-c must same if provided previously or else filename not same will re-download. Not recommend to use -c at all.') -c must same if provided previously or else filename not same will re-download. Not recommend to use -c at all.')
arg_parser.add_argument('-es', '--exclude-section', dest='exclude_section', action='store_true', help='Exclude sections if download from username or board.') arg_parser.add_argument('-es', '--exclude-section', dest='exclude_section', action='store_true', help='Exclude sections if download from username or board.')