diff --git a/src/link/router.py b/src/link/router.py index 75ebbac..bb802fa 100644 --- a/src/link/router.py +++ b/src/link/router.py @@ -14,7 +14,13 @@ router = APIRouter() @router.get("/api/v1/link") -def get_link(background_tasks: BackgroundTasks, db: DbSession, auth: ApiKey, url: str, type_: str = Query(default="auto", alias="type")): +def get_link( + background_tasks: BackgroundTasks, + db: DbSession, + auth: ApiKey, + url: str, + type_: str = Query(default="auto", alias="type"), +): if auth and type_ in ["auto", "live", "live-short"]: s = db.query(Link).filter(Link.url == url, Link.pool == 0).first() if not s and resolve_mirror(db, url): diff --git a/src/snapshots/client.py b/src/snapshots/client.py index 1b269e9..31202f7 100644 --- a/src/snapshots/client.py +++ b/src/snapshots/client.py @@ -248,9 +248,9 @@ class SnapshotCamera: article_description=self.get_attribute_value( 'meta[name="description"]', "content", optional=True ), - article_image=fetch_url(self.url, article_image_source) - if article_image_source - else None, + article_image=( + fetch_url(self.url, article_image_source) if article_image_source else None + ), article_image_caption=self.get_element_content( self.config.article_image_caption_selector, optional=True ), diff --git a/src/snapshots/router.py b/src/snapshots/router.py index a7d5157..c2c59c2 100644 --- a/src/snapshots/router.py +++ b/src/snapshots/router.py @@ -23,7 +23,9 @@ def context(auth: ApiKey, url: str = "https://www.bbc.com/russian/articles/ckgee if settings.ENVIRONMENT.is_debug or auth: ctx = SnapshotCamera(url).get_context() if ctx is None: - raise HTTPException(status.HTTP_404_NOT_FOUND, detail="No configuration for URL") + raise HTTPException( + status.HTTP_404_NOT_FOUND, detail="No configuration for URL" + ) return ctx raise HTTPException(status.HTTP_404_NOT_FOUND) @@ -51,7 +53,12 @@ def snap( ): s = db.query(Snapshot).filter(Snapshot.url == url, Snapshot.pool == 0).first() if not s and config_for_url(url): - s = Snapshot(url=url, pool=0, snapshot_state=SnapshotState.PENDING, provider=SnapshotProvider.GOOGLE) + s = Snapshot( + url=url, + pool=0, + snapshot_state=SnapshotState.PENDING, + provider=SnapshotProvider.GOOGLE, + ) db.add(s) db.commit() background_tasks.add_task(generate_snapshot, s.id) diff --git a/src/snapshots/tasks.py b/src/snapshots/tasks.py index a946c7c..3f36437 100644 --- a/src/snapshots/tasks.py +++ b/src/snapshots/tasks.py @@ -19,7 +19,9 @@ def generate_snapshot(id_: int) -> None: return try: content = SnapshotCamera(snapshot.url).render() - upload_blob(hashids.encode(snapshot.id) + ".html", content.encode("utf-8"), "text/html") + upload_blob( + hashids.encode(snapshot.id) + ".html", content.encode("utf-8"), "text/html" + ) snapshot.snapshot_state = SnapshotState.UPDATING snapshot.snapshot_published_at = datetime.now() db.commit()