From 1658fd32fcaeb168d68326165dfd46b2b53c8e96 Mon Sep 17 00:00:00 2001 From: icemoon1987 Date: Thu, 18 Apr 2019 16:50:13 +0800 Subject: [PATCH 1/2] add --skip-ignore-size function --- src/you_get/common.py | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/src/you_get/common.py b/src/you_get/common.py index 87c31f89..bb9ec4a9 100755 --- a/src/you_get/common.py +++ b/src/you_get/common.py @@ -131,6 +131,7 @@ SITES = { dry_run = False json_output = False force = False +skip_ignore_size = False player = None extractor_proxy = None cookies = None @@ -633,15 +634,22 @@ def url_save( while continue_renameing: continue_renameing = False if os.path.exists(filepath): - if not force and file_size == os.path.getsize(filepath): + if not force and (file_size == os.path.getsize(filepath) or skip_ignore_size): if not is_part: if bar: bar.done() - log.w( - 'Skipping {}: file already exists'.format( - tr(os.path.basename(filepath)) + if skip_ignore_size: + log.w( + 'Skipping {} without checking size: file already exists'.format( + tr(os.path.basename(filepath)) + ) + ) + else: + log.w( + 'Skipping {}: file already exists'.format( + tr(os.path.basename(filepath)) + ) ) - ) else: if bar: bar.update_received(file_size) @@ -945,8 +953,12 @@ def download_urls( if total_size: if not force and os.path.exists(output_filepath) and not auto_rename\ - and os.path.getsize(output_filepath) >= total_size * 0.9: - log.w('Skipping %s: file already exists' % output_filepath) + and (os.path.getsize(output_filepath) >= total_size * 0.9\ + or skip_ignore_size): + if skip_ignore_size: + log.w('Skipping %s without checking size: file already exists' % output_filepath) + else: + log.w('Skipping %s: file already exists' % output_filepath) print() return bar = SimpleProgressBar(total_size, len(urls)) @@ -1455,6 +1467,10 @@ def script_main(download, download_playlist, **kwargs): '-f', '--force', action='store_true', default=False, help='Force overwriting existing files' ) + download_grp.add_argument( + '--skip-ignore-size', action='store_true', default=False, + help='Skip existing file without checking file size' + ) download_grp.add_argument( '-F', '--format', metavar='STREAM_ID', help='Set video format to STREAM_ID' @@ -1541,6 +1557,7 @@ def script_main(download, download_playlist, **kwargs): logging.getLogger().setLevel(logging.DEBUG) global force + global skip_ignore_size global dry_run global json_output global player @@ -1554,6 +1571,8 @@ def script_main(download, download_playlist, **kwargs): info_only = args.info if args.force: force = True + if args.skip_ignore_size: + skip_ignore_size = True if args.auto_rename: auto_rename = True if args.url: From 8103f29b7815c36e92e13cb57031124d54a8a46d Mon Sep 17 00:00:00 2001 From: icemoon1987 Date: Mon, 29 Apr 2019 14:16:51 +0800 Subject: [PATCH 2/2] change --skip-ignore-size to --skip-existing-file-size-check --- src/you_get/common.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/you_get/common.py b/src/you_get/common.py index bb9ec4a9..aa68f07b 100755 --- a/src/you_get/common.py +++ b/src/you_get/common.py @@ -131,7 +131,7 @@ SITES = { dry_run = False json_output = False force = False -skip_ignore_size = False +skip_existing_file_size_check = False player = None extractor_proxy = None cookies = None @@ -634,11 +634,11 @@ def url_save( while continue_renameing: continue_renameing = False if os.path.exists(filepath): - if not force and (file_size == os.path.getsize(filepath) or skip_ignore_size): + if not force and (file_size == os.path.getsize(filepath) or skip_existing_file_size_check): if not is_part: if bar: bar.done() - if skip_ignore_size: + if skip_existing_file_size_check: log.w( 'Skipping {} without checking size: file already exists'.format( tr(os.path.basename(filepath)) @@ -954,8 +954,8 @@ def download_urls( if total_size: if not force and os.path.exists(output_filepath) and not auto_rename\ and (os.path.getsize(output_filepath) >= total_size * 0.9\ - or skip_ignore_size): - if skip_ignore_size: + or skip_existing_file_size_check): + if skip_existing_file_size_check: log.w('Skipping %s without checking size: file already exists' % output_filepath) else: log.w('Skipping %s: file already exists' % output_filepath) @@ -1468,7 +1468,7 @@ def script_main(download, download_playlist, **kwargs): help='Force overwriting existing files' ) download_grp.add_argument( - '--skip-ignore-size', action='store_true', default=False, + '--skip-existing-file-size-check', action='store_true', default=False, help='Skip existing file without checking file size' ) download_grp.add_argument( @@ -1557,7 +1557,7 @@ def script_main(download, download_playlist, **kwargs): logging.getLogger().setLevel(logging.DEBUG) global force - global skip_ignore_size + global skip_existing_file_size_check global dry_run global json_output global player @@ -1571,8 +1571,8 @@ def script_main(download, download_playlist, **kwargs): info_only = args.info if args.force: force = True - if args.skip_ignore_size: - skip_ignore_size = True + if args.skip_existing_file_size_check: + skip_existing_file_size_check = True if args.auto_rename: auto_rename = True if args.url: