coherence.backends.models.stores (module)

Backend models for BackendStore

Backend stores to be subclassed. The base class BackendBaseStore inherits from BackendStore. The store classes represents some basic stores to create backend’s media servers. The available backend stores are:

Note

Be aware that we use super to initialize all the classes of this module in order to have a better MRO class resolution…so…take it into account if you inherit from one of this classes.

New in version 0.8.3.

class BackendBaseStore(server, *args, **kwargs)[source]

Bases: coherence.backend.BackendStore

The Base class to create a server which will hold some kind of items. This class will do most of the work: download page set in root_url, find items based on root_find_items and also will create the right item type to add into your container.

Warning

This class is intended to be used as a base class to create a custom BackendStore, so…some variables must be set into the corresponding inherited class. The mandatory variables are: item_cls, item_type, root_url, root_find_items. Also be sure to overwrite the method parse_item() in your inherited class.

Changed in version 0.9.0: Migrated from louie/dispatcher to EventDispatcher

logCategory = 'BackendBaseStore'
implements = ['MediaServer']
upnp_protocols = []

The upnp protocols that the server should be capable to manage.

container_cls

alias of coherence.backends.models.containers.BackendContainer

item_cls

alias of coherence.backends.models.items.BackendBaseItem

item_type = ''
root_id = 0

The id of the store.

root_url = None

The root url to parse.

root_find_items = ''

The xml’s findall command to parse your items. For example, if your xml data/file looks like this:

<root>
    <item>
        <name>Example item 1</name>
    </item>
    <item>
        <name>Example item 2</name>
    </item>
</root>

The root_find_items should be:

root_find_items = './root/item'
name = 'Backend Base Store'

The name of the store.

queue_update(result)[source]

Schedules a refresh of the media server data.

update_data()[source]
parse_data(root)[source]

Iterate over all items found inside the provided tree and parse each one of them.

parse_item(item)[source]

Convenient method to extract data from an item.

Warning

this method must be sub classed and must return a dictionary which should hold the data that you want to be set for your items.

add_item(data)[source]

Creates and adds an instance of your defined item_cls into the :attr:container_cls. The item will be initialized with the provided data, collected from the method parse_item()

get_by_id(item_id)[source]

Get an item based on his id.

upnp_init()[source]

Define what kind of media content we do provide

class BackendVideoStore(server, *args, **kwargs)[source]

Bases: coherence.backends.models.stores.BackendBaseStore

The Base class to create a server for Video items. This class supports most typical upnp video protocols. If you need some video protocol not listed, you can subclass with your protocols according to your needs.

Note

See the base class BackendBaseStore for more detailed information

Warning

The default variable for item_type has been established to ‘http-get::video/mp4:’. Make sure to set the right video protocol for your needs

logCategory = 'BackendVideoStore'
upnp_protocols = ['http-get:*:video/mp4:*', 'http-get:*:video/mp4v:*', 'http-get:*:video/mpeg:*', 'http-get:*:video/mpegts:*', 'http-get:*:video/matroska:*', 'http-get:*:video/h264:*', 'http-get:*:video/h265:*', 'http-get:*:video/avi:*', 'http-get:*:video/divx:*', 'http-get:*:video/quicktime:*', 'http-get:*:video/x-msvideo:*', 'http-get:*:video/x-ms-wmv:*', 'http-get:*:video/ogg:*']
item_cls

alias of coherence.backends.models.items.BackendVideoItem

item_type = 'http-get:*:video/mp4:*'
name = 'Backend Video Store'
class BackendAudioStore(server, *args, **kwargs)[source]

Bases: coherence.backends.models.stores.BackendBaseStore

The Base class to create a server for Audio items. This class supports most typical upnp audio protocols. If you need some audio protocol not listed, you can subclass with your protocols according to your needs.

Warning

The default variable for item_type has been established to ‘http-get::audio/mpeg:’ (which should be fine for mp3). Make sure to set the right audio protocol for your needs.

logCategory = 'BackendAudioStore'
upnp_protocols = ['http-get:*:audio/mp4:*', 'http-get:*:audio/mp4a:*', 'http-get:*:audio/mpeg:*', 'http-get:*:audio/x-wav:*', 'http-get:*:audio/x-scpls:*', 'http-get:*:audio/x-msaudio:*', 'http-get:*:audio/x-ms-wma:*', 'http-get:*:audio/flac:*', 'http-get:*:audio/ogg:*']
item_cls

alias of coherence.backends.models.items.BackendVideoItem

item_type = 'http-get:*:audio/mpeg:*'
name = 'Backend Audio Store'
class BackendImageStore(server, *args, **kwargs)[source]

Bases: coherence.backends.models.stores.BackendBaseStore

The Base class to create a server for Image items. This class supports most typical upnp image protocols. If you need some image protocol not listed, you can subclass with your protocols according to your needs.

Warning

The default variable for item_type has been established to ‘http-get::audio/jpeg:’. Make sure to set the right image protocol for your needs.

logCategory = 'BackendImageStore'
upnp_protocols = ['http-get:*:image/jpeg:*', 'http-get:*:image/jpg:*', 'http-get:*:image/gif:*', 'http-get:*:image/png:*']
item_cls

alias of coherence.backends.models.items.BackendImageItem

item_type = 'http-get:*:image/jpeg:*'
name = 'Backend Image Store'