Skip to content
Snippets Groups Projects
Commit 786c4368 authored by jan.bednarik's avatar jan.bednarik
Browse files

shared: Download resized images from assets server

parent bdce3628
No related branches found
No related tags found
2 merge requests!456shared: Download resized images from assets server,!455shared: Download resized images from assets server
Pipeline #7499 passed
......@@ -156,7 +156,7 @@ def get_or_create_image(
) # někdy je název obrzau spojený s poznámkou apod., připravíme si fallback name
img_name = file_path.split("/")[-1] or fallback_name
img_assets_folder = repo_name.split(".")[0] # např. "praha" z praha.pirati.cz
img_url = "https://a.pirati.cz/{}/img/{}".format(
img_url = "https://a.pirati.cz/resize/4000x-/{}/img/{}".format(
img_assets_folder, file_path.split("#")[0] # cistime nazev od poznamek apod
)
img_path = os.path.join(path, img_name)
......@@ -165,7 +165,7 @@ def get_or_create_image(
except (HTTPError, UnicodeEncodeError, InvalidURL, IsADirectoryError):
try:
# druhý pokus s "posts" přidáno do URL (obvykle je ve file_path)
img_url = "https://a.pirati.cz/{}/img/posts/{}".format(
img_url = "https://a.pirati.cz/resize/4000x-/{}/img/posts/{}".format(
img_assets_folder, img_name.split()[0]
)
urllib.request.urlretrieve(img_url, img_path)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment