tilie_server.routers.lookup#
MusicBrainz through a Reconciliation Service API 0.2 endpoint.
The editor looks values up in MusicBrainz through this server, which keeps
MusicBrainz’s rules of use for all its requests (see
tilie_server.musicbrainz). The endpoint speaks the W3C Entity
Reconciliation Community Group’s Reconciliation Service API, version 0.2,
so the editor reaches it with the same generic client as any conforming
service:
GET /api/reconcile/musicbrainz, the service manifest;queries=<JSON>(GETor aPOSTform), reconciliation queries;extend=<JSON>(POSTform, orGET), data extension with the propertiesnameandsameAs;GET …/suggest/entity, entity suggestions;GET …/properties, the properties a type can be extended with.
An identifier is <type>/<mbid>, so the identifier space
http://musicbrainz.org/ followed by it is the entity’s IRI
(http://musicbrainz.org/work/<mbid>). sameAs lists the IRIs that
timetoshare’s catalogue recognises in an entity’s URL relationships; the
catalogue is imported when a request needs it, so a server whose
timetoshare lacks it answers every other request.
Form bodies are read with the standard library, and refusals are answered
422 with {"detail": <message>}; a failure of MusicBrainz itself 502.
- tilie_server.routers.lookup.ENDPOINT = '/api/reconcile/musicbrainz'#
The service’s endpoint, root-relative.
- tilie_server.routers.lookup.TYPE_NAMES: Mapping[str, str] = {'artist': 'artist', 'recording': 'recording', 'release-group': 'release group', 'work': 'work'}#
The service’s types, in the manifest’s order, with their names.
- tilie_server.routers.lookup.DEFAULT_TYPE = 'work'#
The type of a query, a suggestion or a property proposal naming none.
- tilie_server.routers.lookup.PROPERTIES: Mapping[str, str] = {'name': 'name', 'sameAs': 'same as'}#
The properties of data extension, with their names.
- tilie_server.routers.lookup.QUERY_LIMIT = 5#
Candidates per query when it names no
limit.
- tilie_server.routers.lookup.MAX_LIMIT = 25#
The largest
limitof a query.
- tilie_server.routers.lookup.SUGGEST_LIMIT = 10#
Suggestions per request.
- tilie_server.routers.lookup.SEPARATOR = ' · '#
Joins the parts of a candidate’s description.
- tilie_server.routers.lookup.MBID = re.compile('[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}')#
A MusicBrainz identifier as MusicBrainz writes it.
- tilie_server.routers.lookup.MANIFEST: dict[str, Any] = {'defaultTypes': [{'id': 'work', 'name': 'work'}, {'id': 'artist', 'name': 'artist'}, {'id': 'recording', 'name': 'recording'}, {'id': 'release-group', 'name': 'release group'}], 'extend': {'property_settings': [], 'propose_properties': {'service_path': '/properties', 'service_url': '/api/reconcile/musicbrainz'}}, 'identifierSpace': 'http://musicbrainz.org/', 'name': 'MusicBrainz through tilie-server', 'schemaSpace': 'http://schema.org/', 'suggest': {'entity': {'service_path': '/suggest/entity', 'service_url': '/api/reconcile/musicbrainz'}}, 'versions': ['0.2'], 'view': {'url': 'https://musicbrainz.org/{{id}}'}}#
The service manifest.
- exception tilie_server.routers.lookup.Refusal(message, status_code=422)[source]#
Bases:
ExceptionA request the service cannot answer, with the status and the detail.
- async tilie_server.routers.lookup.parameters(request)[source]#
The request’s parameters: its query string, then a form body’s.
A parameter given twice takes its first value; one in the body takes the place of the same parameter in the query string.
- tilie_server.routers.lookup.json_text(value)[source]#
A value as the JSON text a refusal quotes it with, a string bare.
- tilie_server.routers.lookup.read_queries(text)[source]#
Read
queriesinto(type, text, limit)per key, all or none.
- tilie_server.routers.lookup.read_extend(text)[source]#
Read
extendinto its identifiers and properties.
- tilie_server.routers.lookup.credited(entity)[source]#
The artist credit of a recording or a release group, as displayed.
- tilie_server.routers.lookup.DESCRIPTIONS: Mapping[str, Callable[[Mapping[str, Any]], list[Any]]] = {'artist': <function <lambda>>, 'recording': <function <lambda>>, 'release-group': <function <lambda>>, 'work': <function <lambda>>}#
The parts of a candidate’s description, per type, before the empty go.
- tilie_server.routers.lookup.named(kind, entity)[source]#
An entity’s identifier, name and, where it has one, description.
- tilie_server.routers.lookup.candidates(kind, answer)[source]#
The reconciliation candidates of one MusicBrainz search.
A candidate is a match when it scores 100 and no other candidate does: MusicBrainz lists them by score, so it is the first, and the next one scores below 100.
- tilie_server.routers.lookup.catalogue_recognizer()[source]#
Answer the IRI timetoshare’s catalogue recognises in a URL, if any.
- tilie_server.routers.lookup.same_as(entity, recognized)[source]#
The IRIs recognised in an entity’s URL relationships, in order, once.
- async tilie_server.routers.lookup.reconciled(musicbrainz, text)[source]#
Answer reconciliation queries, one search per query.
- Parameters:
musicbrainz (MusicBrainz)
text (str)
- Return type:
- async tilie_server.routers.lookup.extended(musicbrainz, text)[source]#
Answer a data extension request, one lookup per identifier.
- Parameters:
musicbrainz (MusicBrainz)
text (str)
- Return type:
- async tilie_server.routers.lookup.answered(request, answer)[source]#
Run
answerand turn a refusal or an upstream failure into JSON.
- async tilie_server.routers.lookup.service(musicbrainz, given)[source]#
Answer
queries, elseextend, else return the service manifest.- Parameters:
musicbrainz (MusicBrainz)
- Return type:
- async tilie_server.routers.lookup.suggestions(musicbrainz, given)[source]#
Suggest the entities of a type whose name
prefixfinds, ten fromcursor.
- async tilie_server.routers.lookup.proposed(musicbrainz, given)[source]#
Propose the properties of data extension for a type.
- async tilie_server.routers.lookup.service_get(request)[source]#
The manifest, or the answer to
queriesorextend.- Parameters:
request (Request)
- Return type:
JSONResponse
- async tilie_server.routers.lookup.service_post(request)[source]#
The answer to a form’s
queriesorextend.- Parameters:
request (Request)
- Return type:
JSONResponse