diff --git a/convert.py b/convert.py index da5d575..ac80b50 100644 --- a/convert.py +++ b/convert.py @@ -2,11 +2,13 @@ import os import sys from PIL import Image import argparse +import json if __name__ == '__main__': + defaults=json.load(open('defaults.json')) parser = argparse.ArgumentParser() - parser.add_argument('--original', help='Path to the original images', default='original') - parser.add_argument('--webp', help='Path to the webp images', default='webp') - parser.add_argument('--quality', help='Quality of the webp images', default=90, type=int) + parser.add_argument('--original', help='Path to the original images', default=defaults['original']) + parser.add_argument('--webp', help='Path to the webp images', default=defaults['webp']) + parser.add_argument('--quality', help='Quality of the webp images', default=defaults['quality'], type=int) parser.add_argument('--overwrite', help='Overwrite existing images', action='store_true') args = parser.parse_args() diff --git a/defaults.json b/defaults.json new file mode 100644 index 0000000..d40e763 --- /dev/null +++ b/defaults.json @@ -0,0 +1 @@ +{ "original": "../pictures", "webp": "../webp1", "quality": 90, "container": "tmp", "remote": "", "local": "../pictures", "ignore": []} \ No newline at end of file diff --git a/sync.py b/sync.py index dfa18ed..f1a48cd 100644 --- a/sync.py +++ b/sync.py @@ -2,15 +2,17 @@ import os, uuid from azure.identity import DefaultAzureCredential from azure.storage.blob import BlobServiceClient, BlobClient, ContainerClient import argparse +import json +defaults=json.load(open('defaults.json')) parser = argparse.ArgumentParser() -parser.add_argument('--container', help='Name of the container', default='blog') -parser.add_argument('--remote', help='Path to the remote images', default='posts') -parser.add_argument('--local', help='Path to the local images', default='webp') -parser.add_argument('--ignore', help='Files to ignore', default=['background.webp'], action='append') +parser.add_argument('--container', help='Name of the container', default=defaults['container']) +parser.add_argument('--remote', help='Path to the remote images', default=defaults['remote']) +parser.add_argument('--local', help='Path to the local images', default=defaults['local']) +parser.add_argument('--ignore', help='Files to ignore', default=defaults['ignore'], action='append') parser.add_argument('--overwrite', help='Overwrite existing images', action='store_true') args=parser.parse_args() -if args.remote[-1] != '/': +if args.remote!='' and args.remote[-1] != '/': args.remote += '/' try: