Class e.c.m.MediaDB(log.Loggable):

Part of elisa.core.media_db View In Hierarchy

Elisa Media database store

I'm keeping a cache of media source hierarchies in a database. I use the elisa.core.db_backend to communicate with supported database backends.

Media sources are basically roots of media locations, like ~/Music folder for audio content for instance. Media sources are referenced in the "source" db table.

Medias can be both files and directories. Each Media has a parent media id and a source id. Content-type specific information are stored in diferent tables for audio, video and images.
Line # Kind Name Docs
115 Method __init__ Initialize our _backend instance variable. If backend is None
137 Method close Disconnect the backend
177 Method get_files_count_for_source_uri DOCME
188 Method prepare_source_for_update DOCME
197 Method hide_un_updated_medias_for_source DOCME
211 Method add_source Add a new media source in the database
239 Method hide_source Mark a source as unavailable in the database.
253 Method show_source Mark a source as available in the database.
267 Method is_source DOCME
273 Method add_media Add a new media in the "media" table and in specialized tables
351 Method del_media_node Mark a media as deleted in database.
376 Method get_source_for_uri Find in which media source the given uri is registered with.
393 Method media_exists Undocumented
402 Method get_media_information Find in database the media corresponding with the given URI.
436 Method get_medias Undocumented
450 Method get_media_with_id Fetch the media with given id in the database
465 Method update_media Update some attributes in database of the given media
489 Method update_media_metadata DOCME
528 Method get_next_location Undocumented
601 Method get_uris_by_meta_uri This function can handle an URI with the elisa:// scheme.
686 Method has_children Undocumented
699 Method get_artist_from_album DOCME
def __init__(self, backend=None, first_load=False):
Initialize our _backend instance variable. If backend is None we retrieve one in the Application.
Parametersbackendthe database backend to use (type: elisa.core.db_backend.DBBackend or None (to use application's) )
first_loadis it the first time the db is loaded? (type: bool )
def close(self):
Disconnect the backend
def get_files_count_for_source_uri(self, source_uri):
DOCME
def prepare_source_for_update(self, source):
DOCME
def hide_un_updated_medias_for_source(self, source):
DOCME
def add_source(self, uri, short_name):

Add a new media source in the database

Add a new row in the "source" table. Source scanning is not handled by this method. See the elisa.core.media_scanner.MediaScanner for that.
Parametersurithe URI identifying the media source (type: elisa.core.media_uri.MediaUri )
short_namestring (type: display friendly name of the source )
Returnsthe newly created source. (type: elisa.extern.db_row.DBRow )
def hide_source(self, source):

Mark a source as unavailable in the database.

Update the "available" flag of the given source record in the "source" table. Return True if source was correctly hidden
Parameterssourcethe source to mark as unavailable (type: elisa.extern.db_row.DBRow )
Returns (type: bool )
def show_source(self, source):

Mark a source as available in the database.

Update the "available" flag of the given source record in the "source" table. Return True if source was correctly shown
Parameterssourcethe source to mark as available (type: elisa.extern.db_row.DBRow )
Returns (type: bool )
def is_source(self, row):
DOCME
def add_media(self, uri, short_name, source_id, content_type, **extra):

Add a new media in the "media" table and in specialized tables

There's one specialized table for each content-type (audio, video, picture). The Media can be either a file or a directory.

If the media is already on database but marked as unavailable or deleted it will be marked as available and undeleted. In that case not further insert will be done.
Parametersurithe URI identifying the media (type: elisa.core.media_uri.MediaUri )
short_namedisplay-friendly media name (type: string )
parentthe source or media to register the media in (type: elisa.extern.db_row.DBRow )
content_typethe media content-type ('directory', 'audio', etc) (type: string )
extraextra row attributes (type: dict )
ReturnsTrue if inserted, False if updated (type: bool )
Unknown Field: todocomplete keywords list
def del_media_node(self, media, force_drop=False):

Mark a media as deleted in database.

FIXME: document force_drop
Parametersmediathe media to mark as deleted. (type: elisa.extern.db_row.DBRow )
Returns (type: bool )
def get_source_for_uri(self, uri):

Find in which media source the given uri is registered with.

The URI has to be referenced in the "source" table.
Parametersurithe URI to search in the "source" table (type: elisa.core.media_uri.MediaUri )
Returns (type: elisa.extern.db_row.DBRow )
def media_exists(self, uri):
Undocumented
def get_media_information(self, uri, extended=True, media_type=None):

Find in database the media corresponding with the given URI.

The URI has to be referenced in the "media" table.
Parametersurithe URI to search in the "media" table (type: elisa.core.media_uri.MediaUri )
Returns (type: elisa.extern.db_row.DBRow )
def get_medias(self, source=None, media_type=None):
Undocumented
def get_media_with_id(self, media_id):
Fetch the media with given id in the database
Parametersmedia_idthe identifier of the Media i have to dig in the db (type: int )
Returns (type: elisa.extern.db_row.DBRow )
def update_media(self, media, **new_values):
Update some attributes in database of the given media
Parametersmediathe media I'm checking (type: elisa.extern.db_row.DBRow )
new_valuesattributes to update. Keys have to match "media" table column names. (type: dict )
Unknown Field: tododocument valid keys of new_values dict
def update_media_metadata(self, media, **metadata):
DOCME
def get_next_location(self, uri, root_uri):
Undocumented
def get_uris_by_meta_uri(self, uri, children, start=0, item_count=-1):
This function can handle an URI with the elisa:// scheme. It returns a list of uris matching the request defined in uri's path
Parametersuriuri representing an elisa:// scheme (type: elisa.core.media_uri.MediaUri )
childrenuri representing an elisa:// scheme (type: list of tuple (uri, info) )
Returns (type: list of tuple (string, elisa.core.media_uri.MediaUri, int) )
def has_children(self, uri):
Undocumented
def get_artist_from_album(self, album):
DOCME
API Documentation for Elisa Media Center, generated by pydoctor at 2008-08-25 19:17:22.