Add Platsbanken as a third search provider

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
WolfandClaude Sonnet 5.5 committed 2026-09-29 16:10:45 +02:00
1 parent b6afe24eaa
commit 00e111961e
4 files changed
+257 -12

No files matched your search

+10 -3
View File
@@ -25,7 +25,7 @@ if TYPE_CHECKING:
from app.jobs.discover import Discovery
#: The providers `plugins.search` runs, and which of them needs a key.
PROVIDERS = ("jobindex", "adzuna")
PROVIDERS = ("jobindex", "adzuna", "platsbanken")
def set_fetch(store: Store, sub_id: int, fetch: bool) -> tuple[Subscription, int]:
@@ -213,7 +213,7 @@ def seed_companies(store: Store, path: str | Path) -> dict[str, Any]:
def search_params(provider: str, q: str, *, area: int = 0, country: str = "",
where: str = "", pages: int = 0) -> dict[str, Any]:
where: str = "", region: str = "", pages: int = 0) -> dict[str, Any]:
"""The `params` a search subscription stores, with only the keys its
provider reads."""
if provider not in PROVIDERS:
@@ -227,13 +227,20 @@ def search_params(provider: str, q: str, *, area: int = 0, country: str = "",
params["country"] = country.strip().lower()
if where.strip():
params["where"] = where.strip()
if provider == "platsbanken":
from plugins.search import PLATSBANKEN_REGIONS
region = region.strip()
if region and region not in PLATSBANKEN_REGIONS:
raise ValueError("region is empty or the id of a Swedish län")
params["region"] = region
if pages:
params["pages"] = int(pages)
return params
def has_key(config: Config, provider: str) -> bool:
"""Whether `provider` can run: jobindex always, adzuna with a key in the
"""Whether `provider` can run: jobindex and platsbanken always, adzuna with a key in the
config or the environment."""
if provider != "adzuna":
return True