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.0 with rights_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

Adapter

Registry convention (arioso): the loader imports adapter.Adapter.

Classes

Adapter

Registry convention (arioso): the loader imports adapter.Adapter.

WikimediaCommonsAdapter([config, http])

Keyless Wikimedia Commons adapter (a SourceAdapter).

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: object

Keyless 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:

bytes

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:

SoundRecord

invoke_native(**params)[source]#

Call the MediaWiki action=query API with native params (#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:

dict

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; None also 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, k per 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’s LL-Q… files, and any file in a pronunciation category (En-us-stumble.ogg is dropped by its category, not its name; a <lang>-<word>.ogg with no such category is kept).

Return type:

list[Candidate]