diff options
author | Lars-Dominik Braun <lars@6xq.net> | 2019-06-27 21:56:15 +0200 |
---|---|---|
committer | Lars-Dominik Braun <lars@6xq.net> | 2019-06-27 22:03:02 +0200 |
commit | d42467d991ee8da8d05d1319f16229972a4e2e0f (patch) | |
tree | 8f0f5610773e3a9c9a6fa114beda2a7150770544 | |
parent | 76811bd3f0b3fc8688939e31fdab2c71c89cc75b (diff) | |
download | crocoite-d42467d991ee8da8d05d1319f16229972a4e2e0f.tar.gz crocoite-d42467d991ee8da8d05d1319f16229972a4e2e0f.tar.bz2 crocoite-d42467d991ee8da8d05d1319f16229972a4e2e0f.zip |
extract-screenshot: Allow extracting only the first screenshot
-rw-r--r-- | crocoite/tools.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/crocoite/tools.py b/crocoite/tools.py index 0beb884..bc679d0 100644 --- a/crocoite/tools.py +++ b/crocoite/tools.py @@ -122,6 +122,8 @@ def extractScreenshot (): 'WARC, write JSON info to stdout.') parser.add_argument('-f', '--force', action='store_true', help='Overwrite existing files') + parser.add_argument('-1', '--one', action='store_true', + help='Only extract the first screenshot into a file named prefix') parser.add_argument('input', type=argparse.FileType ('rb'), help='Input WARC') parser.add_argument('prefix', help='Output file prefix') @@ -139,7 +141,7 @@ def extractScreenshot (): url = URL (headers.get_header ('WARC-Target-URI')) yoff = int (headers.get_header ('X-Crocoite-Screenshot-Y-Offset')) - outpath = f'{args.prefix}{i:05d}.png' + outpath = f'{args.prefix}{i:05d}.png' if not args.one else args.prefix if args.force or not os.path.exists (outpath): json.dump ({'file': outpath, 'url': url, 'yoff': yoff}, sys.stdout, cls=StrJsonEncoder) @@ -150,6 +152,9 @@ def extractScreenshot (): else: print (f'not overwriting {outpath}', file=sys.stderr) + if args.one: + break + class Errata: __slots__ = ('uuid', 'description', 'affects') |