MediaBrowser/MediaBrowser — pull request #811 by thogil (2014-05-07 21:29:23+00:00)
Title: Item identity providers

I was not at all happy with my previous solution to supporting anime series orders. It was messy and not obvious how it was working.

The core problem that needed to be solved was that there are multiple different ways of organising media. The user has likely picked one, but our metadata providers may expect another. We need some way of detecting and converting between systems.

I have split the remote metadata providers into two phases: identification and data collection.

During identification, the system asks implementations of the IItemIdentityProvider to identify the media. These return items of the IdentityType (which is specific to each item type).

The system then looks for IItemIdentityConverter implementations which can convert from any known identities to any unknown identities.

The identities are stored in the item info instance, and can be used in the metadata providers to identify the item.

This additional identification pass is optional, and existing providers continue to work as-is without being modified.

One compromise I had to make, was that I had to copy the identities (via their base interface) into BaseItem (non-seralised) after running the remote metadata providers, to allow image providers to access the identities without making massive changes to those interfaces and the code which interacts with them.