lint: formatting

This commit is contained in:
Iain Learmonth 2026-05-19 13:44:04 +01:00
parent bbf5f3d98b
commit 1a5e3a2aba
4 changed files with 22 additions and 7 deletions

View file

@ -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):

View file

@ -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
),

View file

@ -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)

View file

@ -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()