From 8b8b143874ad2dba97323f0914cbb074863991d3 Mon Sep 17 00:00:00 2001 From: Luca Date: Thu, 30 Mar 2023 17:03:50 +0200 Subject: [PATCH] Unquote names from urls --- bin/download_galleries.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bin/download_galleries.py b/bin/download_galleries.py index 97ee9e7..3789dfe 100755 --- a/bin/download_galleries.py +++ b/bin/download_galleries.py @@ -7,6 +7,7 @@ from os import utime from pathlib import Path from re import search, sub from sys import stderr +from urllib.parse import unquote from yaml import CDumper, dump import requests @@ -39,7 +40,7 @@ def parse_http_datetime(dt): return datetime.strptime(dt.replace('GMT', '+0000'), '%a, %d %b %Y %H:%M:%S %z') def download_image(url, target): - name = url.rsplit('/', 1)[-1] + name = unquote(url.rsplit('/', 1)[-1]) image = target / name if image.exists(): @@ -63,7 +64,7 @@ def download_image(url, target): print(f"downloaded image '{name}' (last modified: {last_modified.strftime('%a, %d %b %Y %H:%M:%S %Z')})", file=stderr) def download_gallery(path): - slug = path.removeprefix(f'{GALLERIES_PATH}/') + slug = unquote(path.removeprefix(f'{GALLERIES_PATH}/')) target = TARGET_DIR / slug target.mkdir(parents=True, exist_ok=True)