foley.sources.openverse.adapter#

Openverse retrieve adapter: keyless audio search with ready attribution strings.

search calls /v1/audio/ (anonymous: page_size ≤ 20, Freesound and Jamendo rows excluded, see the config) with the licence filter pushed into the query, then re-checks each row’s licence fail-closed through foley.sources._license_gate.license_for_item() (Openverse does not verify licences: a row’s licence is the one its origin provider reported, trusted like Freesound’s own field; the landing page is the check for anything that matters). The terms’ “made using Openverse” notice is stamped on each licence record (notice_text_required), so the credits carry it. Durations arrive in milliseconds. download fetches the row’s url (cached from search, else resolved from /audio/{id}/). HTTP and the 429 sleep are injected.

Module Attributes

Adapter

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

Classes

Adapter

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

OpenverseAdapter([config, ...])

Keyless Openverse adapter (a SourceAdapter).

foley.sources.openverse.adapter.Adapter#

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

class foley.sources.openverse.adapter.OpenverseAdapter(config=None, *, include_freesound=False, http=None)[source]#

Bases: object

Keyless Openverse adapter (a SourceAdapter).

Parameters:
  • config (Optional[dict]) – The SOURCE_CONFIG (the registry passes it positionally).

  • include_freesound (bool) – Keep Freesound rows (stored by reference, bytes never cached); off by default: use the freesound source for those.

  • http (Optional[Transport]) – The injected Transport.

download(source_id)[source]#

The row’s audio bytes (from the URL a search hit gave, else resolved by id).

Return type:

bytes

get(source_id)[source]#

Resolve one row id (a UUID) to its record.

Raises:

LookupError – If its licence is not accepted.

Return type:

SoundRecord

invoke_native(path, **params)[source]#

GET an Openverse API path with native params; return the parsed JSON (#61).

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

property notice: str#

The sentence Openverse’s terms require an app to show prominently.

search(query, *, license='cc0', k=15, page=1, include_explicit=False, sources=None, kind='sfx', provider_params=None, include_pronunciations=False, **kw)[source]#

Search Openverse audio for query; return licence-checked candidates.

Parameters:
  • license (Optional[str]) – A licence id ('cc0' is an alias for CC0-1.0) keeps only rows under it, and is pushed into the native license filter (CC0, CC-BY or PDM); None asks for CC0, CC-BY and public-domain-mark rows.

  • k (int) – Max rows (anonymous limit 20).

  • page (int) – The results page (1-based, k per page).

  • include_explicit (bool) – Also return rows Openverse marks mature.

  • sources (Optional[list]) – Only these Openverse providers (wikimedia_audio, …); the excluded ones (Freesound, Jamendo) stay excluded, so asking only for them returns nothing.

  • kind (str) – sfx (default, no category filter) or music.

  • include_pronunciations (bool) – Keep recordings of a person saying a word (Lingua Libre’s LL-Q… files, rows Openverse files as pronunciation); dropped by default, as Commons drops them (#295, #319).

  • provider_params (Optional[dict]) – Native search params merged over the translated ones (#61); the per-item licence check still applies.

Return type:

list[Candidate]