From 0d7c121781e5b39daccf3cd5574010e113bf88e5 Mon Sep 17 00:00:00 2001 From: Thomas Sileo Date: Sun, 6 Nov 2022 16:57:04 +0100 Subject: [PATCH] Fix formatting --- app/media.py | 10 +++++++--- app/templates.py | 1 - 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/media.py b/app/media.py index c5638fb..287042a 100644 --- a/app/media.py +++ b/app/media.py @@ -15,8 +15,8 @@ class InvalidProxySignatureError(Exception): def proxied_media_sig(expires: int, url: str) -> str: hm = hmac_sha256() - hm.update(f'{expires}'.encode()) - hm.update(b'|') + hm.update(f"{expires}".encode()) + hm.update(b"|") hm.update(url.encode()) return base64.urlsafe_b64encode(hm.digest()).decode() @@ -34,7 +34,11 @@ def proxied_media_url(url: str) -> str: expires = int(time.time() / EXPIRY_PERIOD) + EXPIRY_LENGTH sig = proxied_media_sig(expires, url) - return BASE_URL + f"/proxy/media/{expires}/{sig}/" + base64.urlsafe_b64encode(url.encode()).decode() + return ( + BASE_URL + + f"/proxy/media/{expires}/{sig}/" + + base64.urlsafe_b64encode(url.encode()).decode() + ) def resized_media_url(url: str, size: int) -> str: diff --git a/app/templates.py b/app/templates.py index bc8adbb..3415904 100644 --- a/app/templates.py +++ b/app/templates.py @@ -1,4 +1,3 @@ -import base64 from datetime import datetime from datetime import timezone from functools import lru_cache