coherence.backends.fs_storage (module)¶
FSStore - filesystem media server¶
FSStore exposes media files found in the directory trees defined by the ‘content’ configuration entry.
The first “.jpg” or “.png” file found inside a media directory is served as a cover image.
The plugin is configured with:
<plugin active="yes">
<!-- The plugin identifier, mandatory -->
<backend>FSStore</backend>
<!-- A comma-separated list of path containing the medias to serve -->
<content>/media/path1,/media/path2</content>
<!-- The avertized media server name, default: "my media" -->
<name>my media</name>
<!-- The highest UPnP version this
media server should support, default: 2 -->
<version>2</version>
<!-- A unique identifier used to reference the media server,
autogenerated if not set explicitly. In this case, some control points
might memorize it between runs and display the same media server more
than once. -->
<uuid>2f7f4096-cba3-4390-be7d-d1d07106a6f4</uuid>
</plugin>
-
_find_thumbnail
(filename, thumbnail_folder='.thumbs')[source]¶ looks for a thumbnail file of the same basename in a folder named ‘.thumbs’ relative to the file
returns the filename of the thumb, its mimetype and the correspondig DLNA PN string or throws an Exception otherwise
-
class
FSItem
(object_id, parent, path, mimetype, urlbase, UPnPClass, update=False, store=None)[source]¶ Bases:
coherence.backend.BackendItem
-
logCategory
= 'fs_item'¶
-
check_for_cover_art
()[source]¶ let’s try to find in the current directory some jpg file, or png if the jpg search fails, and take the first one that comes around
-
get_child_count
()[source]¶ Called by the CDS.
- Returns
the number of its childs - len(childs)
or a Deferred
-
get_path
()[source]¶ Called by the MediaServer web.
- Returns
the filepath where to find the media file that this item does refer to.
-
get_name
()[source]¶ Called by the MediaServer web.
- Returns
the name of the item, it is always expected to be in unicode.
-
get_cover
()[source]¶ Called by the MediaServer web.
- Returns
the filepath where to find the album art file
Note
only needed when we have created for that item an albumArtURI property that does point back to us.
-
-
class
FSStore
(server, **kwargs)[source]¶ Bases:
coherence.backend.BackendStore
Changed in version 0.9.0: Migrated from louie/dispatcher to EventDispatcher
-
logCategory
= 'fs_store'¶
-
implements
= ['MediaServer']¶
-
description
= 'MediaServer exporting files from the file-system'¶
-
options
= [{'option': 'name', 'type': 'string', 'default': 'my media', 'help': 'the name under this MediaServer shall show up with on other UPnP clients'}, {'option': 'version', 'type': 'int', 'default': 2, 'enum': (2, 1), 'help': 'the highest UPnP version this MediaServer shall support', 'level': 'advance'}, {'option': 'uuid', 'type': 'string', 'help': 'the unique (UPnP) identifier for this MediaServer, usually automatically set', 'level': 'advance'}, {'option': 'content', 'type': 'string', 'default': None, 'help': 'the path(s) this MediaServer shall export'}, {'option': 'ignore_patterns', 'type': 'string', 'help': 'list of regex patterns, matching filenames will be ignored'}, {'option': 'enable_inotify', 'type': 'string', 'default': 'yes', 'help': 'enable real-time monitoring of the content folders'}, {'option': 'enable_destroy', 'type': 'string', 'default': 'no', 'help': 'enable deleting a file via an UPnP method'}, {'option': 'import_folder', 'type': 'string', 'help': 'The path to store files imported via an UPnP method, if empty the Import method is disabled'}]¶
-
release
()[source]¶ If anything needs to be cleaned up upon shutdown of this backend, this is the place for it. Should be overwritten in subclass.
-
get_by_id
(id)[source]¶ - Parameters
id (object) – is the id property of our DIDLLite item
- Returns
None when no matching item for that id is found,
a BackendItem,
or a Deferred
Called by the CDS or the MediaServer web.
Note
if this MediaServer implements containers that can share their content, like ‘all tracks’, ‘album’ and ‘album_of_artist’ (they all have the same track item as content), then the id may be passed by the CDS like this:
‘id@container’ or ‘id@container@container@container…’
therefore a
if isinstance(id, basestring): id = id.split('@',1) id = id[0]
may be appropriate as the first thing to do when entering this method.
-
upnp_init
()[source]¶ This method gets called after the device is fired, here all initializations of service related state variables should happen, as the services aren’t available before that point.
-