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 |
---|---|---|---|
114 | Method | __init__ | Initialize our _backend instance variable. If backend is None |
136 | Method | close | Disconnect the backend |
176 | Method | get_files_count_for_source_uri | DOCME |
187 | Method | prepare_source_for_update | DOCME |
196 | Method | hide_un_updated_medias_for_source | DOCME |
210 | Method | add_source | Add a new media source in the database |
238 | Method | hide_source | Mark a source as unavailable in the database. |
252 | Method | show_source | Mark a source as available in the database. |
266 | Method | is_source | DOCME |
272 | Method | add_media | Add a new media in the "media" table and in specialized tables |
350 | Method | del_media_node | Mark a media as deleted in database. |
375 | Method | get_source_for_uri | Find in which media source the given uri is registered with. |
392 | Method | media_exists | Undocumented |
401 | Method | get_media_information | Find in database the media corresponding with the given URI. |
435 | Method | get_medias | Undocumented |
449 | Method | get_media_with_id | Fetch the media with given id in the database |
464 | Method | update_media | Update some attributes in database of the given media |
488 | Method | update_media_metadata | DOCME |
527 | Method | get_next_location | Undocumented |
600 | Method | get_uris_by_meta_uri | This function can handle an URI with the elisa:// scheme. |
685 | Method | has_children | Undocumented |
698 | Method | get_artist_from_album | DOCME |
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
) |
short_name | string (type: display friendly name of the source ) | |
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 | source | the source to mark as unavailable
(type: elisa.extern.db_row.DBRow
) |
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 | source | the source to mark as available
(type: elisa.extern.db_row.DBRow
) |
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)
) |