Skip to content

sok.media.base_media

Base media class with API integration.

Provides the BaseMedia class that extends MediaItem with functionality to search for and retrieve metadata from configured media APIs.

BaseMedia

class BaseMedia(
title: str,
media_type: MediaType,
content_type: ContentType,
media_manager: UniversalMediaManager,
language: str = 'en',
)

Bases: MediaItem

Base class for all media items with API integration.

Extends MediaItem with functionality to search and retrieve metadata from configured media APIs.

Initialize a media item with API support.

Parameters

NameTypeDefaultDescription
titlestrThe item's display title.
media_typeMediaTypeThe media category (VIDEO, MUSIC, etc.).
content_typeContentTypeThe specific content type.
media_managerUniversalMediaManagerManager instance for API calls.
languagestr'en'Language code for searches (default: 'en').
Source

Attributes

NameDescription
language

Language code for API requests.

media_manager

Manager for API operations.

path

Storage path for the media item.

get_folder_structureabstractmethod

def get_folder_structure() -> List[str]:

Return the recommended folder hierarchy for this item.

Returns

  • List[str]A list of folder names representing the path structure.
Source

get_formatted_nameabstractmethod

def get_formatted_name() -> str:

Return the formatted filename for this media item.

Returns

  • strA formatted string suitable for use as a filename.
Source

search_and_set_mediaasync

async def search_and_set_media() -> None:

Search for and populate media metadata from API.

Searches using the configured API and updates this item's metadata with the first matching result.

Raises

  • ValueErrorIf no results are found for the title.
Source

set_path

def set_path(path: str) -> None:

Set the storage path for this media item.

Parameters

NameTypeDescription
pathstrFile system path where the media is stored.
Source
Built with Kiln