courlan.settings¶
Configuration constants for URL filtering and content detection.
General settings for package execution.
Settings reference¶
Name |
Type |
Purpose |
|---|---|---|
|
|
Domain fragments to exclude (social media, CDNs, e-commerce, etc.) |
|
|
Query parameters preserved during cleaning (content IDs, pagination) |
|
|
Query parameter names used for language detection (e.g. |
|
|
ISO 639-1 codes mapped to accepted variants (e.g. |
Customizing settings¶
Settings are module-level objects loaded at import time. Patch them at runtime before any filtering calls — in place:
import courlan.settings as settings
settings.BLACKLIST.add("myservice.com")
settings.ALLOWED_PARAMS.add("story_id")
settings.TARGET_LANGS.setdefault("fr", set()).add("français")
Mutating methods (.add(), .discard(), .clear(), .setdefault()) are the
only ones that take effect. Rebinding does not work: the filter modules do
from .settings import BLACKLIST, ... at import time, so they hold the original
objects and settings.BLACKLIST = set() has no effect on filtering.
For permanent changes, edit courlan/settings.py directly and reinstall in editable mode (pip install -e .).
Default values¶
The most commonly-tuned defaults live in courlan/settings.py. Current
values (refer to the file for the authoritative list) include:
BLACKLIST — a set of domain fragments excluded by default (social media, CDNs, common platforms). Example entries:
"facebook","amazonaws","youtube".ALLOWED_PARAMS — query parameter names preserved during cleaning (content IDs, pagination), e.g.
"page","id","post".LANG_PARAMS — query parameter names used for language signals, typically
{ "lang", "language" }.TARGET_LANGS — mapping of ISO 639-1 codes to accepted variants, e.g.
{"en": {"en", "english"}, "de": {"de", "deutsch"}}. Only used for query-parameter language values, see the table above.
To inspect defaults at runtime:
import courlan.settings as settings
print(settings.BLACKLIST)
print(settings.ALLOWED_PARAMS)
Be cautious: overly aggressive changes (e.g., BLACKLIST.clear()) can
significantly alter filtering behavior.