foley.sources.wikimedia_commons.adapter#
Wikimedia Commons retrieve adapter: audio files with their licence, keyless.
search turns a query into list=search over the File namespace restricted to audio
(filetype:audio), asking for each file’s URL, size, duration and extmetadata in
the same call (the generator form). Each file’s licence is read from extmetadata
(LicenseUrl, else LicenseShortName) through the one licence SSOT, so:
CC0 and CC-BY become candidates, verified; a request for CC0 only (the façade’s default
license='cc0') keeps CC0 alone;“Public domain” becomes
PDM-1.0withrights_verified=False: a claim, never cleared by the licence field alone (Commons also holds impressions of copyrighted characters labelled public domain), so the pull gate stops it until a person confirms;share-alike, no-derivatives and anything unrecognised are dropped (fail closed).
The bytes come from upload.wikimedia.org with the same descriptive User-Agent;
a 429 is waited out by the resilient transport the registry wraps around http
(see retry in the config). HTTP is injected.
Module Attributes
Registry convention (arioso): the loader imports |
Classes
Registry convention (arioso): the loader imports |
|
|
Keyless Wikimedia Commons adapter (a |
- foley.sources.wikimedia_commons.adapter.Adapter#
Registry convention (arioso): the loader imports
adapter.Adapter.
- class foley.sources.wikimedia_commons.adapter.WikimediaCommonsAdapter(config=None, *, http=None)[source]#
Bases:
objectKeyless Wikimedia Commons adapter (a
SourceAdapter).- Parameters:
- download(source_id)[source]#
The file’s audio bytes (from the URL a search hit gave, else resolved by id).
- Return type:
- get(source_id)[source]#
Resolve one file (page id) to its record.
- Raises:
LookupError – If the file is missing or its licence is not accepted.
- Return type:
- invoke_native(**params)[source]#
Call the MediaWiki
action=queryAPI with nativeparams(#61).Returns the JSON response.
It bypasses the licence filter and the per-item licence check that
search()applies: the caller owns licence gating for what comes back.- Return type:
- search(query, *, license='cc0', k=15, page=1, provider_params=None, include_pronunciations=False, **kw)[source]#
Search Commons audio for
query; return licence-checked candidates.- Parameters:
license (
Optional[str]) – A licence id ('cc0'is an alias for CC0-1.0;'cc-by'the CC-BY ids) keeps only files under it;Nonealso keeps CC-BY and the unverified public-domain claims.k (
int) – Max files requested (the API’s limit is 50).page (
int) – The results page (1-based,kper page), sent as an offset.provider_params (
Optional[dict]) – Native search params merged over the translated ones (#61); the per-item licence check still applies.include_pronunciations (
bool) – Keep recordings of a person saying a word, which are dropped by default (#295): Lingua Libre’sLL-Q…files, and any file in a pronunciation category (En-us-stumble.oggis dropped by its category, not its name; a<lang>-<word>.oggwith no such category is kept).
- Return type: