pycompmusic documentation

PyCompmusic is a library of tools that are used in the CompMusic research project. The main two components are feature extractors, and a wrapper to the Dunya API.

Dunya API

exception compmusic.dunya.conn.ConnectionError[source]

Bases: Exception

exception compmusic.dunya.conn.HTTPError[source]

Bases: Exception

compmusic.dunya.conn.set_hostname(hostname)[source]

Change the hostname of the dunya API endpoint.

Arguments:
hostname: The new dunya hostname to set. If you want to access over http or a different port,

include them in the hostname, e.g. http://localhost:8000

compmusic.dunya.conn.set_token(token)[source]

Set an access token. You must call this before you can make any other calls.

Arguments:

token: your access token

compmusic.dunya.docserver.add_sourcetype(document, filetype, file)[source]

Add a new file to the sourcetype.If file is a string and refers to a file on disk, the contents of the file is read and send, otherwise it is sent as-is

Parameters
  • document – Musicbrainz recording ID of the specific document

  • filetype – Name of the sourcetype

  • file – Path to the new file that will update the sourcetype

Returns

The contents of the most recent version of the derived file

compmusic.dunya.docserver.create_and_upload_document(collection, document, title, filetype, file)[source]

Create and upload a new file to the sourcetype

Parameters
  • collection – Name of the collection

  • document – Musicbrainz recording ID of the specific document

  • title – Title of the document

  • filetype – Name of the sourcetype

  • file – Path to the new file that will update the sourcetype

Returns

The contents of the most recent version of the derived file

compmusic.dunya.docserver.create_document(collection, document, title=None)[source]

Create a specific document inside a collection

Parameters
  • collection – Name of the collection

  • document – Musicbrainz recording ID of the specific document

Returns

The contents of the most recent version of the derived file

compmusic.dunya.docserver.document(recordingid)[source]

Get the available source filetypes for a Musicbrainz recording.

Parameters

recordingid – Musicbrainz recording ID

Returns

a list of filetypes in the database for this recording

compmusic.dunya.docserver.file_for_document(recordingid, thetype, subtype=None, part=None, version=None)[source]

Get the most recent derived file given a filetype.

Parameters
  • recordingid – Musicbrainz recording ID

  • thetype – the computed filetype

  • subtype – a subtype if the module has one

  • part – the file part if the module has one

  • version – a specific version, otherwise the most recent one will be used

Returns

The contents of the most recent version of the derived file

compmusic.dunya.docserver.get_collection(slug)[source]

Get the documents (recordings) in a collection.

Parameters

slug – the name of the collection

compmusic.dunya.docserver.get_collections()[source]

Get a list of all collections in the server.

compmusic.dunya.docserver.get_document_as_json(recordingid, thetype, subtype=None, part=None, version=None)[source]

Get a derived filetype and load it as json.

Parameters
  • recordingid – Musicbrainz recording ID

  • thetype – the computed filetype

  • subtype – a subtype if the module has one

  • part – the file part if the module has one

  • version – a specific version, otherwise the most recent one will be used

Returns

The contents of the most recent version of the derived file

compmusic.dunya.docserver.get_mp3(recordingid)[source]

Get a mp3 from a specific mbid

Parameters

recordingid – Musicbrainz recording ID

compmusic.dunya.docserver.update_document(collection, document, title=None)[source]

Update a specific document inside a collection

Parameters
  • collection – Name of the collection

  • document – Musicbrainz recording ID of the specific document

  • title – Name of the required document

Returns

The contents of the most recent version of the derived file

compmusic.dunya.docserver.update_sourcetype(document, filetype, file)[source]

Update a specific document considered sourcetype

Parameters
  • document – Musicbrainz recording ID of the specific document

  • filetype – Name of the sourcetype

  • file – Path to the new file that will update the sourcetype

Returns

The contents of the most recent version of the derived file

Indices and tables