In order to use the Discography Framework with other API's besides Discogs.com, or other entities besides the Release Node, you will need to develop your own module that plugs in to the Discography Framework. This project is designed to make it as easy as possible to do so; all you need to do is to implement a small number of hooks.

It is encouraged to put your module in the Discography package. To do so, include this line in your [module_name].info file:

package = Discography

Module naming recommendations are provided below, but they are only recommendations, not requirements. They were chosen to follow the [core module]_[sub-module] naming conventions used by projects such as Media. (Note that this has changed; previously, the recommendation was to append _prov for a Provider Adapter, and _adpt for an Entity Adapter.)

There are two types of Adapter modules you can write: Provider Adapters, and Entity Adapters. It is recommended practice that a module implement hooks from one or the other, and not both, though again this is only a recommendation.

Developing a Provider Adapter

This is the type of adapter you would create if you want to use the API of a discography provider other than Discogs.com.

The recommended name for this module would be discog_[provider]. Example: discog_last_fm. If this would cause naming conflicts, then it is recommended to append _prov to the module name.

You will need to implement these hooks:

  • hook_discog_provider_info(): Provides human-readable information about the discography provider.
  • hook_discog_search(): Handles a search query to the third-party API.
  • hook_discog_fetch_releases(): Handles a query of a particular artist, label, etc. for their releases.
  • hook_discog_fetch_release(): Handles the retrieval of a release with a given ID.

Additionally, it is recommended that you implement Drupal core's hook_help().

Documented hooks, including sample implementations, are in this subdirectory of the discog folder:
discog_mediator/docs/discog_mediator.provider.api.php

Developing an Entity Adapter

This is the type of adapter you would create if you want to use the Discography Framework to import data into your own content type.

The recommended name for this module would be discog_[type]. Example: discog_my_album. If this would cause naming conflicts, then it is recommended to append _adpt to the module name.

You will need to implement these hooks:

  • hook_discog_type_info(): Provides human-readable information about the content type into which you will save third-party data.
  • hook_discog_save_release(): Takes a structured array of release data and saves it to a content type.

Additionally, it is recommended that you implement Drupal core's hook_help().

Documented hooks, including sample implementations (and also sample helper functions), are in this subdirectory of the discog folder:
discog_mediator/docs/discog_mediator.entity.api.php

Turning an Existing Module Into an Adapter

This can be done quite easily, by implementing the above hooks in your module's code. From a programming standpoint, there is no risk in doing so - if the users don't have the Discography Framework installed, then the hooks simply will never be called.

However, from a practical standpoint, there may be advantages to creating a separate Adapter sub-module. It will make it easier to separate issues in the issue queue, and to easily identify the places in code where bugs occur. This approach will require users to explicitly enable the module if they want to use the Adapter (which may be good or bad).