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. |
Parameters | backend | the database backend to use
(type: elisa.core.db_backend.DBBackend
or None (to use application's)
) |
first_load | is it the first time the db is loaded? (type: bool ) |
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 theelisa.core.media_scanner.MediaScanner
for that.
Parameters | uri | the URI identifying the media source
(type: elisa.core.media_uri.MediaUri
) |
Returns | the newly created source.
(type: elisa.extern.db_row.DBRow
) |
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 hiddenParameters | uri | the URI identifying the media source
(type: elisa.core.media_uri.MediaUri
) |
Returns | (type: bool ) |
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 shownParameters | uri | the URI identifying the media source
(type: elisa.core.media_uri.MediaUri
) |
Returns | (type: bool ) |
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.Parameters | uri | the URI identifying the media
(type: elisa.core.media_uri.MediaUri
) |
short_name | display-friendly media name (type: string ) | |
parent | the source or media to register the media in
(type: elisa.extern.db_row.DBRow
) | |
content_type | the media content-type ('directory', 'audio', etc) (type: string ) | |
extra | extra row attributes (type: dict ) | |
Returns | True if inserted, False if updated (type: bool ) | |
Unknown Field: todo | complete keywords list |
Mark a media as deleted in database.
FIXME: document force_dropParameters | media | the media to mark as deleted.
(type: elisa.extern.db_row.DBRow
) |
Returns | (type: bool ) |
Find in which media source the given uri is registered with.
The URI has to be referenced in the "source" table.Parameters | uri | the URI to search in the "source" table
(type: elisa.core.media_uri.MediaUri
) |
Returns | (type: elisa.extern.db_row.DBRow
) |
Find in database the media corresponding with the given URI.
The URI has to be referenced in the "media" table.Parameters | uri | the URI to search in the "media" table
(type: elisa.core.media_uri.MediaUri
) |
Returns | (type: elisa.extern.db_row.DBRow
) |
Parameters | media_id | the identifier of the Media i have to dig in the db (type: int ) |
Returns | (type: elisa.extern.db_row.DBRow
) |
Parameters | media | the media I'm checking
(type: elisa.extern.db_row.DBRow
) |
new_values | attributes to update. Keys have to match "media" table column names. (type: dict ) | |
Unknown Field: todo | document valid keys of new_values dict |
Parameters | uri | uri representing an elisa:// scheme
(type: elisa.core.media_uri.MediaUri
) |
children | uri representing an elisa:// scheme (type: list of tuple (uri, info) ) | |
Returns | (type: list of tuple (string, elisa.core.media_uri.MediaUri ,
int)
) |