Skip to content

Commit

Permalink
Merge pull request #25 from alternak/main
Browse files Browse the repository at this point in the history
Add option to disable SSL verification
  • Loading branch information
Salvoxia authored Jul 30, 2024
2 parents f7aae12 + 699cb8b commit a503c96
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion immich_auto_album.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import sys
import datetime
from collections import defaultdict
import urllib3

# Trying to deal with python's isnumeric() function
# not recognizing negative numbers
Expand All @@ -25,6 +26,7 @@ def is_integer(str):
parser.add_argument("-c", "--chunk-size", default=2000, type=int, help="Maximum number of assets to add to an album with a single API call")
parser.add_argument("-C", "--fetch-chunk-size", default=5000, type=int, help="Maximum number of assets to fetch with a single API call")
parser.add_argument("-l", "--log-level", default="INFO", choices=['CRITICAL', 'ERROR', 'WARNING', 'INFO', 'DEBUG'], help="Log level to use")
parser.add_argument("-i", "--ignore-ssl", action="store_true", help="Set to true to ignore SSL verification")
args = vars(parser.parse_args())
# set up logger to log in logfmt format
logging.basicConfig(level=args["log_level"], stream=sys.stdout, format='time=%(asctime)s level=%(levelname)s msg=%(message)s')
Expand All @@ -40,6 +42,7 @@ def is_integer(str):
# Album Levels Range handling
album_levels_range_arr = ()
album_level_separator = args["album_separator"]
ignore_ssl = args["ignore_ssl"]
logging.debug("root_path = %s", root_paths)
logging.debug("root_url = %s", root_url)
logging.debug("api_key = %s", api_key)
Expand All @@ -49,12 +52,16 @@ def is_integer(str):
logging.debug("album_levels = %s", album_levels)
#logging.debug("album_levels_range = %s", album_levels_range)
logging.debug("album_level_separator = %s", album_level_separator)
logging.debug("ignore_ssl = %s", ignore_ssl)

# Verify album levels
if is_integer(album_levels) and album_levels == 0:
parser.print_help()
exit(1)

if ignore_ssl:
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

# Verify album levels range
if not is_integer(album_levels):
album_levels_range_split = album_levels.split(",")
Expand Down Expand Up @@ -93,7 +100,8 @@ def is_integer(str):
'x-api-key': api_key,
'Content-Type': 'application/json',
'Accept': 'application/json'
}
},
'verify' : not ignore_ssl
}

# Yield successive n-sized
Expand Down

0 comments on commit a503c96

Please sign in to comment.