Class e.p.m.d.MediaDB(Component):

Part of elisa.plugins.media_db.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
124 Method __init__ Initialize our _backend instance variable. If backend is None
147 Class Method get_connection Undocumented
192 Method close Disconnect the backend
232 Method get_files_count_for_source_uri DOCME
243 Method prepare_source_for_update DOCME
252 Method hide_un_updated_medias_for_source DOCME
266 Method add_source Add a new media source in the database
293 Method hide_source Mark a source as unavailable in the database.
307 Method show_source Mark a source as available in the database.
321 Method is_source DOCME
327 Method add_media Add a new media in the "media" table and in specialized tables
405 Method del_media_node Mark a media as deleted in database.
430 Method get_source_for_uri Find in which media source the given uri is registered with.
447 Method media_exists Undocumented
456 Method get_media_information Find in database the media corresponding with the given URI.
490 Method get_medias Undocumented
504 Method get_media_with_id Fetch the media with given id in the database
519 Method update_media Update some attributes in database of the given media
543 Method update_media_metadata DOCME
582 Method get_next_location Undocumented
655 Method get_uris_by_meta_uri This function can handle an URI with the elisa:// scheme.
742 Method has_children Undocumented
755 Method get_artist_from_album DOCME

Inherited from Component:

Line # Kind Name Docs
85 Class PathDescriptor Undocumented
97 Class Method create Create and initialize the component.
130 Method initialize Initialize the component.
142 Method clean Clean the component.
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 )
@classmethod
def get_connection(cls):
Undocumented
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):

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 )
Returnsthe newly created source. (type: elisa.extern.db_row.DBRow )
def hide_source(self, uri):

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
Parametersurithe URI identifying the media source (type: elisa.core.media_uri.MediaUri )
Returns (type: bool )
def show_source(self, uri):

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
Parametersurithe URI identifying the media source (type: elisa.core.media_uri.MediaUri )
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-11 20:05:11.