sok.core.adapters.media_adapters.base
Base adapter classes for API response normalization.
Provides the abstract Adapter protocol and BaseAdapter class that all media-type-specific adapters inherit from.
Adapter
class AdapterBases: Protocol
Protocol defining the adapter interface.
All media adapters must implement these methods to normalize API responses into a consistent format.
Sourceadapt_details
def adapt_details( content_type: ContentType, payload: Dict[str, Any],) -> Dict[str, Any]:Adapt detail response to normalized format.
Parameters
| Name | Type | Description |
|---|---|---|
content_type | ContentType | Type of content. |
payload | Dict[str, Any] | Raw API detail response. |
Returns
Dict[str, Any]Normalized detail dictionary.
adapt_search
def adapt_search( content_type: ContentType, results: List[Dict[str, Any]],) -> Dict[str, List[Dict[str, Any]]]:Adapt search results to normalized format.
Parameters
| Name | Type | Description |
|---|---|---|
content_type | ContentType | Type of content being searched. |
results | List[Dict[str, Any]] | Raw API search results. |
Returns
Dict[str, List[Dict[str, Any]]]Normalized search results dictionary.
BaseAdapter
class BaseAdapterBase class for media adapters.
Provides default implementations that raise NotImplementedError, forcing subclasses to implement the required methods.
Sourceadapt_details
def adapt_details( content_type: ContentType, payload: Dict[str, Any],) -> Dict[str, Any]:Adapt detail response to normalized format.
Parameters
| Name | Type | Description |
|---|---|---|
content_type | ContentType | Type of content. |
payload | Dict[str, Any] | Raw API detail response. |
Returns
Dict[str, Any]Normalized detail dictionary.
Raises
NotImplementedErrorMust be implemented by subclass.
adapt_search
def adapt_search( content_type: ContentType, results: List[Dict[str, Any]],) -> Dict[str, List[Dict[str, Any]]]:Adapt search results to normalized format.
Parameters
| Name | Type | Description |
|---|---|---|
content_type | ContentType | Type of content being searched. |
results | List[Dict[str, Any]] | Raw API search results. |
Returns
Dict[str, List[Dict[str, Any]]]Normalized search results dictionary.
Raises
NotImplementedErrorMust be implemented by subclass.