For new photo posts use YYYY/name if possible, and fall back on YYYY/MM/name if not

This commit is contained in:
Eryn Wells 2023-03-04 10:25:04 -08:00
parent 74ae4174e0
commit a2653e185c

View file

@ -48,7 +48,20 @@ def main(argv):
month = earliest_exif_date.month
name = args.title if args.title else os.path.splitext(os.path.basename(photo))[0]
post_path = os.path.join(PHOTOS_CONTENT_DIR, f'{year:04}', f'{month:02}', name)
post_path_year = os.path.join(PHOTOS_CONTENT_DIR, f'{year:04}', name)
post_path_year_month = os.path.join(PHOTOS_CONTENT_DIR, f'{year:04}', f'{month:02}', name)
if os.path.exists(post_path_year):
if os.path.exists(post_path_year_month):
print("Couldn't find path for photo post. Both of the following paths exist.", file=sys.stderr)
print(f' {post_path_year}', file=sys.stderr)
print(f' {post_path_year_month}', file=sys.stderr)
return -1
else:
post_path = post_path_year_month
else:
post_path = post_path_year
try:
hugo_command = ['hugo', 'new', '--clock', earliest_exif_date.isoformat(), post_path]