coherence.backends (package)

Submodules

coherence.backends.ampache_storage (module)

sha256(s)[source]
md5(s)[source]
class ProxySong(uri)[source]

Bases: coherence.upnp.core.utils.ReverseProxyResource

delEntity(name)
entityType = <InterfaceClass twisted.web.resource.IResource>
getChild(path, request)

Create and return a proxy resource with the same proxy configuration as this one, except that its path also contains the segment given by C{path} at the end.

getChildForRequest(request)
getChildWithDefault(path, request)

Retrieve a static or dynamically generated child resource from me.

First checks if a resource was added manually by putChild, and then call getChild to check for dynamic resources. Only override if you want to affect behaviour of all child lookups, rather than just dynamic ones.

This will check to see if I have a pre-registered child resource of the given name, and call getChild if I do not.

@see: L{IResource.getChildWithDefault}

getDynamicEntity(name, request)
getStaticEntity(name)
isLeaf = 0
listDynamicEntities(request=None)
listDynamicNames()
listEntities()
listNames()
listStaticEntities()
listStaticNames()
proxyClientFactoryClass

alias of coherence.upnp.core.utils.ProxyClientFactory

putChild(path, child)

Register a static child.

You almost certainly don’t want ‘/’ in your path. If you intended to have the root of a folder, e.g. /foo/, you want path to be ‘’.

@see: L{IResource.putChild}

reallyPutEntity(name, entity)
render(request)

Render a request by forwarding it to the proxied server.

render_HEAD(request)

Default handling of HEAD method.

I just return self.render_GET(request). When method is HEAD, the framework will handle this correctly.

resetTarget(host, port, path, qs='')
server = None
class Container(id, parent_id, name, store=None, children_callback=None, container_class=<class 'coherence.upnp.core.DIDLLite.Container'>, play_container=False)[source]

Bases: coherence.backend.BackendItem

logCategory = 'ampache_store'
get_path = None
add_child(child)[source]
get_children(start=0, end=0)[source]

called by the CDS and the MediaServer web should return

  • a list of its childs[start:end]
  • or a Deferred

if end == 0, the request is for all childs after start - childs[start:]

get_child_count()[source]

called by the CDS should return

  • the number of its childs - len(childs)
  • or a Deferred
get_item()[source]

called by the CDS and the MediaServer web should return

  • an UPnP ContentDirectoryServer DIDLLite object
  • or a Deferred
get_name()[source]

called by the MediaServer web should return

  • the name of the item, it is always expected to be in unicode
get_id()[source]
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
get_cover()

called by the MediaServer web should return

  • the filepath where to find the album art file

only needed when we have created for that item an albumArtURI property that does point back to us

info(message, *args, **kwargs)
log(message, *args, **kwargs)
msg(message, *args, **kwargs)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
class Playlist(store, element)[source]

Bases: coherence.backend.BackendItem

logCategory = 'ampache_store'
get_path = None
get_children(start=0, end=0)[source]

called by the CDS and the MediaServer web should return

  • a list of its childs[start:end]
  • or a Deferred

if end == 0, the request is for all childs after start - childs[start:]

get_child_count()[source]

called by the CDS should return

  • the number of its childs - len(childs)
  • or a Deferred
get_item(parent_id=104)[source]

called by the CDS and the MediaServer web should return

  • an UPnP ContentDirectoryServer DIDLLite object
  • or a Deferred
get_id()[source]
get_name()[source]

called by the MediaServer web should return

  • the name of the item, it is always expected to be in unicode
get_cover()[source]

called by the MediaServer web should return

  • the filepath where to find the album art file

only needed when we have created for that item an albumArtURI property that does point back to us

COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
info(message, *args, **kwargs)
log(message, *args, **kwargs)
msg(message, *args, **kwargs)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
class Album(store, element)[source]

Bases: coherence.backend.BackendItem

logCategory = 'ampache_store'
get_path = None
get_children(start=0, end=0)[source]

called by the CDS and the MediaServer web should return

  • a list of its childs[start:end]
  • or a Deferred

if end == 0, the request is for all childs after start - childs[start:]

get_child_count()[source]

called by the CDS should return

  • the number of its childs - len(childs)
  • or a Deferred
get_item(parent_id=103)[source]

called by the CDS and the MediaServer web should return

  • an UPnP ContentDirectoryServer DIDLLite object
  • or a Deferred
get_id()[source]
get_name()[source]

called by the MediaServer web should return

  • the name of the item, it is always expected to be in unicode
get_cover()[source]

called by the MediaServer web should return

  • the filepath where to find the album art file

only needed when we have created for that item an albumArtURI property that does point back to us

COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
info(message, *args, **kwargs)
log(message, *args, **kwargs)
msg(message, *args, **kwargs)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
class Artist(store, element)[source]

Bases: coherence.backend.BackendItem

logCategory = 'ampache_store'
get_path = None
get_children(start=0, end=0)[source]

called by the CDS and the MediaServer web should return

  • a list of its childs[start:end]
  • or a Deferred

if end == 0, the request is for all childs after start - childs[start:]

get_child_count()[source]

called by the CDS should return

  • the number of its childs - len(childs)
  • or a Deferred
get_item(parent_id=102)[source]

called by the CDS and the MediaServer web should return

  • an UPnP ContentDirectoryServer DIDLLite object
  • or a Deferred
get_id()[source]
get_name()[source]

called by the MediaServer web should return

  • the name of the item, it is always expected to be in unicode
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
get_cover()

called by the MediaServer web should return

  • the filepath where to find the album art file

only needed when we have created for that item an albumArtURI property that does point back to us

info(message, *args, **kwargs)
log(message, *args, **kwargs)
msg(message, *args, **kwargs)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
class Genre(store, element)[source]

Bases: coherence.backend.BackendItem

logCategory = 'ampache_store'
get_path = None
get_children(start=0, end=0)[source]

called by the CDS and the MediaServer web should return

  • a list of its childs[start:end]
  • or a Deferred

if end == 0, the request is for all childs after start - childs[start:]

get_child_count()[source]

called by the CDS should return

  • the number of its childs - len(childs)
  • or a Deferred
get_item(parent_id=105)[source]

called by the CDS and the MediaServer web should return

  • an UPnP ContentDirectoryServer DIDLLite object
  • or a Deferred
get_id()[source]
get_name()[source]

called by the MediaServer web should return

  • the name of the item, it is always expected to be in unicode
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
get_cover()

called by the MediaServer web should return

  • the filepath where to find the album art file

only needed when we have created for that item an albumArtURI property that does point back to us

info(message, *args, **kwargs)
log(message, *args, **kwargs)
msg(message, *args, **kwargs)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
class Tag(store, element)[source]

Bases: coherence.backend.BackendItem

logCategory = 'ampache_store'
get_path = None
get_children(start=0, end=0)[source]

called by the CDS and the MediaServer web should return

  • a list of its childs[start:end]
  • or a Deferred

if end == 0, the request is for all childs after start - childs[start:]

get_child_count()[source]

called by the CDS should return

  • the number of its childs - len(childs)
  • or a Deferred
get_item(parent_id=106)[source]

called by the CDS and the MediaServer web should return

  • an UPnP ContentDirectoryServer DIDLLite object
  • or a Deferred
get_id()[source]
get_name()[source]

called by the MediaServer web should return

  • the name of the item, it is always expected to be in unicode
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
get_cover()

called by the MediaServer web should return

  • the filepath where to find the album art file

only needed when we have created for that item an albumArtURI property that does point back to us

info(message, *args, **kwargs)
log(message, *args, **kwargs)
msg(message, *args, **kwargs)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
class Track(store, element)[source]

Bases: coherence.backend.BackendItem

logCategory = 'ampache_store'
get_children(start=0, request_count=0)[source]

called by the CDS and the MediaServer web should return

  • a list of its childs[start:end]
  • or a Deferred

if end == 0, the request is for all childs after start - childs[start:]

get_child_count()[source]

called by the CDS should return

  • the number of its childs - len(childs)
  • or a Deferred
get_item(parent_id=None)[source]

called by the CDS and the MediaServer web should return

  • an UPnP ContentDirectoryServer DIDLLite object
  • or a Deferred
get_id()[source]
get_name()[source]

called by the MediaServer web should return

  • the name of the item, it is always expected to be in unicode
get_url()[source]
get_path()[source]

called by the MediaServer web should return

  • the filepath where to find the media file that this item does refer to
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
get_cover()

called by the MediaServer web should return

  • the filepath where to find the album art file

only needed when we have created for that item an albumArtURI property that does point back to us

info(message, *args, **kwargs)
log(message, *args, **kwargs)
msg(message, *args, **kwargs)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
class Video(store, element)[source]

Bases: coherence.backend.BackendItem

logCategory = 'ampache_store'
get_children(start=0, request_count=0)[source]

called by the CDS and the MediaServer web should return

  • a list of its childs[start:end]
  • or a Deferred

if end == 0, the request is for all childs after start - childs[start:]

get_child_count()[source]

called by the CDS should return

  • the number of its childs - len(childs)
  • or a Deferred
get_item(parent_id=200)[source]

called by the CDS and the MediaServer web should return

  • an UPnP ContentDirectoryServer DIDLLite object
  • or a Deferred
get_id()[source]
get_name()[source]

called by the MediaServer web should return

  • the name of the item, it is always expected to be in unicode
get_url()[source]
get_path()[source]

called by the MediaServer web should return

  • the filepath where to find the media file that this item does refer to
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
get_cover()

called by the MediaServer web should return

  • the filepath where to find the album art file

only needed when we have created for that item an albumArtURI property that does point back to us

info(message, *args, **kwargs)
log(message, *args, **kwargs)
msg(message, *args, **kwargs)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
class AmpacheStore(server, **kwargs)[source]

Bases: coherence.backend.BackendStore

this is a backend to the Ampache Media DB

implements = ['MediaServer']
logCategory = 'ampache_store'
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
_get_all_items(id)

a helper method to get all items as a response to some XBox 360 UPnP Search action probably never be used as the backend will overwrite the wmc_mapping with more appropriate methods

critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
info(message, *args, **kwargs)
init_completed(*args, **kwargs)

inform Coherence that this backend is ready for announcement this method just accepts any form of arguments as we don’t under which circumstances it is called

log(message, *args, **kwargs)
msg(message, *args, **kwargs)
release()

if anything needs to be cleaned up upon shutdown of this backend, this is the place for it

warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
get_by_id(id)[source]

called by the CDS or the MediaServer web

id is the id property of our DIDLLite item

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

should return

  • None when no matching item for that id is found,
  • a BackendItem,
  • or a Deferred
got_auth_response(response, renegotiate=False)[source]
got_auth_error(e, renegotiate=False)[source]
get_token(renegotiate=False)[source]

ask Ampache for the authorization token

got_error(e)[source]
got_response(response, query_item, request)[source]
ampache_query(item, start=0, request_count=0, filter=None)[source]
ampache_query_songs(start=0, request_count=0)[source]
ampache_query_albums(start=0, request_count=0)[source]
ampache_query_artists(start=0, request_count=0)[source]
ampache_query_playlists(start=0, request_count=0)[source]
ampache_query_genres(start=0, request_count=0)[source]
ampache_query_tags(start=0, request_count=0)[source]
ampache_query_videos(start=0, request_count=0)[source]
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

upnp_XBrowse(*args, **kwargs)[source]

coherence.backends.appletrailers_storage (module)

This is a Media Backend that allows you to access the Trailers from Apple.com

class AppleTrailerProxy(uri)[source]

Bases: coherence.upnp.core.utils.ReverseProxyUriResource

render(request)[source]

Render a request by forwarding it to the proxied server.

delEntity(name)
entityType = <InterfaceClass twisted.web.resource.IResource>
getChild(path, request)

Create and return a proxy resource with the same proxy configuration as this one, except that its path also contains the segment given by C{path} at the end.

getChildForRequest(request)
getChildWithDefault(path, request)

Retrieve a static or dynamically generated child resource from me.

First checks if a resource was added manually by putChild, and then call getChild to check for dynamic resources. Only override if you want to affect behaviour of all child lookups, rather than just dynamic ones.

This will check to see if I have a pre-registered child resource of the given name, and call getChild if I do not.

@see: L{IResource.getChildWithDefault}

getDynamicEntity(name, request)
getStaticEntity(name)
isLeaf = 0
listDynamicEntities(request=None)
listDynamicNames()
listEntities()
listNames()
listStaticEntities()
listStaticNames()
proxyClientFactoryClass

alias of coherence.upnp.core.utils.ProxyClientFactory

putChild(path, child)

Register a static child.

You almost certainly don’t want ‘/’ in your path. If you intended to have the root of a folder, e.g. /foo/, you want path to be ‘’.

@see: L{IResource.putChild}

reallyPutEntity(name, entity)
render_HEAD(request)

Default handling of HEAD method.

I just return self.render_GET(request). When method is HEAD, the framework will handle this correctly.

resetTarget(host, port, path, qs='')
resetUri(uri)
server = None
uri = None
class Trailer(parent_id, urlbase, id=None, name=None, cover=None, url=None)[source]

Bases: coherence.backend.BackendItem

get_path()[source]

called by the MediaServer web should return

  • the filepath where to find the media file that this item does refer to
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
get_child_count()

called by the CDS should return

  • the number of its childs - len(childs)
  • or a Deferred
get_children(start=0, end=0)

called by the CDS and the MediaServer web should return

  • a list of its childs[start:end]
  • or a Deferred

if end == 0, the request is for all childs after start - childs[start:]

get_cover()

called by the MediaServer web should return

  • the filepath where to find the album art file

only needed when we have created for that item an albumArtURI property that does point back to us

get_item()

called by the CDS and the MediaServer web should return

  • an UPnP ContentDirectoryServer DIDLLite object
  • or a Deferred
get_name()

called by the MediaServer web should return

  • the name of the item, it is always expected to be in unicode
info(message, *args, **kwargs)
log(message, *args, **kwargs)
logCategory = 'backend_item'
msg(message, *args, **kwargs)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
class Container(id, parent_id, name, store=None, children_callback=None)[source]

Bases: coherence.backend.BackendItem

logCategory = 'apple_trailers'
get_children(start=0, end=0)[source]

called by the CDS and the MediaServer web should return

  • a list of its childs[start:end]
  • or a Deferred

if end == 0, the request is for all childs after start - childs[start:]

get_child_count()[source]

called by the CDS should return

  • the number of its childs - len(childs)
  • or a Deferred
get_item()[source]

called by the CDS and the MediaServer web should return

  • an UPnP ContentDirectoryServer DIDLLite object
  • or a Deferred
get_name()[source]

called by the MediaServer web should return

  • the name of the item, it is always expected to be in unicode
get_id()[source]
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
get_cover()

called by the MediaServer web should return

  • the filepath where to find the album art file

only needed when we have created for that item an albumArtURI property that does point back to us

get_path()[source]

called by the MediaServer web should return

  • the filepath where to find the media file that this item does refer to
info(message, *args, **kwargs)
log(message, *args, **kwargs)
msg(message, *args, **kwargs)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
class AppleTrailersStore(server, *args, **kwargs)[source]

Bases: coherence.backend.BackendStore

logCategory = 'apple_trailers'
implements = ['MediaServer']
queue_update(result)[source]
update_data()[source]
parse_data(root)[source]
_parse_into_trailer(item)[source]

info = item.find(‘info’)

for attr in (‘title’, ‘runtime’, ‘rating’, ‘studio’, ‘postdate’,
‘releasedate’, ‘copyright’, ‘director’, ‘description’):

setattr(trailer, attr, info.find(attr).text)

get_by_id(id)[source]

called by the CDS or the MediaServer web

id is the id property of our DIDLLite item

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

should return

  • None when no matching item for that id is found,
  • a BackendItem,
  • or a Deferred
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

COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
_get_all_items(id)

a helper method to get all items as a response to some XBox 360 UPnP Search action probably never be used as the backend will overwrite the wmc_mapping with more appropriate methods

critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
info(message, *args, **kwargs)
init_completed(*args, **kwargs)

inform Coherence that this backend is ready for announcement this method just accepts any form of arguments as we don’t under which circumstances it is called

log(message, *args, **kwargs)
msg(message, *args, **kwargs)
release()

if anything needs to be cleaned up upon shutdown of this backend, this is the place for it

warn(message, *args, **kwargs)
warning(message, *args, **kwargs)

coherence.backends.audiocd_storage (module)

class TrackItem(device_name='/dev/cdrom', track_number=1, artist='Unknown', title='Unknown')[source]

Bases: coherence.backend.BackendItem

logCategory = 'audiocd'
get_item()[source]

called by the CDS and the MediaServer web should return

  • an UPnP ContentDirectoryServer DIDLLite object
  • or a Deferred
get_name()[source]

called by the MediaServer web should return

  • the name of the item, it is always expected to be in unicode
get_path()[source]

called by the MediaServer web should return

  • the filepath where to find the media file that this item does refer to
get_size()[source]
get_id()[source]
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
get_child_count()

called by the CDS should return

  • the number of its childs - len(childs)
  • or a Deferred
get_children(start=0, end=0)

called by the CDS and the MediaServer web should return

  • a list of its childs[start:end]
  • or a Deferred

if end == 0, the request is for all childs after start - childs[start:]

get_cover()

called by the MediaServer web should return

  • the filepath where to find the album art file

only needed when we have created for that item an albumArtURI property that does point back to us

info(message, *args, **kwargs)
log(message, *args, **kwargs)
msg(message, *args, **kwargs)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
class AudioCDStore(server, **kwargs)[source]

Bases: coherence.backend.AbstractBackendStore

logCategory = 'audiocd'
implements = ['MediaServer']
description = ('audioCD', '', None)
options = [{'option': 'version', 'text': 'UPnP Version:', 'type': 'int', 'default': 2, 'enum': (2, 1), 'help': 'the highest UPnP version this MediaServer shall support', 'level': 'advance'}, {'option': 'uuid', 'text': 'UUID Identifier:', 'type': 'string', 'help': 'the unique (UPnP) identifier for this MediaServer, usually automatically set', 'level': 'advance'}, {'option': 'device_name', 'text': 'device name for audio CD:', 'type': 'string', 'help': 'device name containing the audio cd.'}]
disc_title = None
cdrom = None
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

extractAudioCdInfo()[source]

extract the CD info (album art + artist + tracks), and construct the UPnP items

checkIfAudioCdStillPresent()[source]
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
_get_all_items(id)

a helper method to get all items as a response to some XBox 360 UPnP Search action probably never be used as the backend will overwrite the wmc_mapping with more appropriate methods

append_item(item, storage_id=None)
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
get_by_id(id)

called by the CDS or the MediaServer web

id is the id property of our DIDLLite item

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

should return

  • None when no matching item for that id is found,
  • a BackendItem,
  • or a Deferred
get_root_id()
get_root_item()
getnextID()
info(message, *args, **kwargs)
init_completed(*args, **kwargs)

inform Coherence that this backend is ready for announcement this method just accepts any form of arguments as we don’t under which circumstances it is called

len()
log(message, *args, **kwargs)
msg(message, *args, **kwargs)
release()

if anything needs to be cleaned up upon shutdown of this backend, this is the place for it

remove_item(item)
set_root_item(item)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)

coherence.backends.axiscam_storage (module)

class AxisCamItem(id, obj, parent, mimetype, urlbase, UPnPClass, update=False)[source]

Bases: coherence.backend.BackendItem

logCategory = 'axis_cam_item'
remove()[source]
add_child(child, update=False)[source]
remove_child(child)[source]
get_children(start=0, request_count=0)[source]

called by the CDS and the MediaServer web should return

  • a list of its childs[start:end]
  • or a Deferred

if end == 0, the request is for all childs after start - childs[start:]

get_child_count()[source]

called by the CDS should return

  • the number of its childs - len(childs)
  • or a Deferred
get_id()[source]
get_update_id()[source]
get_path()[source]

called by the MediaServer web should return

  • the filepath where to find the media file that this item does refer to
get_name()[source]

called by the MediaServer web should return

  • the name of the item, it is always expected to be in unicode
get_parent()[source]
get_item()[source]

called by the CDS and the MediaServer web should return

  • an UPnP ContentDirectoryServer DIDLLite object
  • or a Deferred
get_xml()[source]
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
get_cover()

called by the MediaServer web should return

  • the filepath where to find the album art file

only needed when we have created for that item an albumArtURI property that does point back to us

info(message, *args, **kwargs)
log(message, *args, **kwargs)
msg(message, *args, **kwargs)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
class AxisCamStore(server, **kwargs)[source]

Bases: coherence.backend.BackendStore

logCategory = 'axis_cam_store'
implements = ['MediaServer']
append(obj, parent)[source]
len()[source]
get_by_id(id)[source]

called by the CDS or the MediaServer web

id is the id property of our DIDLLite item

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

should return

  • None when no matching item for that id is found,
  • a BackendItem,
  • or a Deferred
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
_get_all_items(id)

a helper method to get all items as a response to some XBox 360 UPnP Search action probably never be used as the backend will overwrite the wmc_mapping with more appropriate methods

critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
getnextID()[source]
info(message, *args, **kwargs)
init_completed(*args, **kwargs)

inform Coherence that this backend is ready for announcement this method just accepts any form of arguments as we don’t under which circumstances it is called

log(message, *args, **kwargs)
msg(message, *args, **kwargs)
release()

if anything needs to be cleaned up upon shutdown of this backend, this is the place for it

warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
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

main()[source]

coherence.backends.banshee_storage (module)

TODO:

  • podcasts
get_cover_path(artist_name, album_title)[source]
class SQLiteDB(database)[source]

Bases: coherence.log.LogAble

Python DB API 2.0 backend support.

Connect to a db backend hosting the given database.

logCategory = 'sqlite'
__init__(database)[source]

Connect to a db backend hosting the given database.

disconnect()[source]
connect()[source]

Connect to the database, set L{_db} instance variable.

reconnect()[source]

Disconnect and reconnect to the database.

sql_execute(request, *params, **kw)[source]

Execute a SQL query in the db backend

COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
info(message, *args, **kwargs)
log(message, *args, **kwargs)
msg(message, *args, **kwargs)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
class Container(id, parent_id, name, children_callback=None, store=None, play_container=False)[source]

Bases: coherence.backend.BackendItem

get_path = None
add_child(child)[source]
get_children(start=0, request_count=0)[source]

called by the CDS and the MediaServer web should return

  • a list of its childs[start:end]
  • or a Deferred

if end == 0, the request is for all childs after start - childs[start:]

get_child_count()[source]

called by the CDS should return

  • the number of its childs - len(childs)
  • or a Deferred
get_item()[source]

called by the CDS and the MediaServer web should return

  • an UPnP ContentDirectoryServer DIDLLite object
  • or a Deferred
get_name()[source]

called by the MediaServer web should return

  • the name of the item, it is always expected to be in unicode
get_id()[source]
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
get_cover()

called by the MediaServer web should return

  • the filepath where to find the album art file

only needed when we have created for that item an albumArtURI property that does point back to us

info(message, *args, **kwargs)
log(message, *args, **kwargs)
logCategory = 'backend_item'
msg(message, *args, **kwargs)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
class Artist(*args, **kwargs)[source]

Bases: coherence.backend.BackendItem

get_children(start=0, end=0)[source]

called by the CDS and the MediaServer web should return

  • a list of its childs[start:end]
  • or a Deferred

if end == 0, the request is for all childs after start - childs[start:]

get_child_count()[source]

called by the CDS should return

  • the number of its childs - len(childs)
  • or a Deferred
get_item()[source]

called by the CDS and the MediaServer web should return

  • an UPnP ContentDirectoryServer DIDLLite object
  • or a Deferred
get_id()[source]
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
get_cover()

called by the MediaServer web should return

  • the filepath where to find the album art file

only needed when we have created for that item an albumArtURI property that does point back to us

get_name()

called by the MediaServer web should return

  • the name of the item, it is always expected to be in unicode
get_path()

called by the MediaServer web should return

  • the filepath where to find the media file that this item does refer to
info(message, *args, **kwargs)
log(message, *args, **kwargs)
logCategory = 'backend_item'
msg(message, *args, **kwargs)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
class Album(*args, **kwargs)[source]

Bases: coherence.backend.BackendItem

definition for an album

mimetype = 'directory'
get_path = None
get_children(start=0, request_count=0)[source]

called by the CDS and the MediaServer web should return

  • a list of its childs[start:end]
  • or a Deferred

if end == 0, the request is for all childs after start - childs[start:]

get_child_count()[source]

called by the CDS should return

  • the number of its childs - len(childs)
  • or a Deferred
get_item()[source]

called by the CDS and the MediaServer web should return

  • an UPnP ContentDirectoryServer DIDLLite object
  • or a Deferred
get_id()[source]
get_name()[source]

called by the MediaServer web should return

  • the name of the item, it is always expected to be in unicode
get_cover()[source]

called by the MediaServer web should return

  • the filepath where to find the album art file

only needed when we have created for that item an albumArtURI property that does point back to us

COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
info(message, *args, **kwargs)
log(message, *args, **kwargs)
logCategory = 'backend_item'
msg(message, *args, **kwargs)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
class BasePlaylist(*args, **kwargs)[source]

Bases: coherence.backend.BackendItem

definition for a playlist

id_type = 'baseplaylist'
mimetype = 'directory'
get_path = None
db_id

Should be implemented in subclass

get_tracks(request_count)[source]
db_to_didl(row)[source]
get_id()[source]
get_children(start=0, request_count=0)[source]

called by the CDS and the MediaServer web should return

  • a list of its childs[start:end]
  • or a Deferred

if end == 0, the request is for all childs after start - childs[start:]

get_child_count()[source]

called by the CDS should return

  • the number of its childs - len(childs)
  • or a Deferred
get_item()[source]

called by the CDS and the MediaServer web should return

  • an UPnP ContentDirectoryServer DIDLLite object
  • or a Deferred
get_name()[source]

called by the MediaServer web should return

  • the name of the item, it is always expected to be in unicode
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
get_cover()

called by the MediaServer web should return

  • the filepath where to find the album art file

only needed when we have created for that item an albumArtURI property that does point back to us

info(message, *args, **kwargs)
log(message, *args, **kwargs)
logCategory = 'backend_item'
msg(message, *args, **kwargs)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
class MusicPlaylist(*args, **kwargs)[source]

Bases: coherence.backends.banshee_storage.BasePlaylist

id_type = 'musicplaylist'
db_id

Should be implemented in subclass

get_tracks(request_count)[source]
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
critical(message, *args, **kwargs)
db_to_didl(row)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
get_child_count()

called by the CDS should return

  • the number of its childs - len(childs)
  • or a Deferred
get_children(start=0, request_count=0)

called by the CDS and the MediaServer web should return

  • a list of its childs[start:end]
  • or a Deferred

if end == 0, the request is for all childs after start - childs[start:]

get_cover()

called by the MediaServer web should return

  • the filepath where to find the album art file

only needed when we have created for that item an albumArtURI property that does point back to us

get_id()
get_item()

called by the CDS and the MediaServer web should return

  • an UPnP ContentDirectoryServer DIDLLite object
  • or a Deferred
get_name()

called by the MediaServer web should return

  • the name of the item, it is always expected to be in unicode
get_path = None
info(message, *args, **kwargs)
log(message, *args, **kwargs)
logCategory = 'backend_item'
mimetype = 'directory'
msg(message, *args, **kwargs)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
class MusicSmartPlaylist(*args, **kwargs)[source]

Bases: coherence.backends.banshee_storage.BasePlaylist

id_type = 'musicsmartplaylist'
db_id

Should be implemented in subclass

get_tracks(request_count)[source]
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
critical(message, *args, **kwargs)
db_to_didl(row)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
get_child_count()

called by the CDS should return

  • the number of its childs - len(childs)
  • or a Deferred
get_children(start=0, request_count=0)

called by the CDS and the MediaServer web should return

  • a list of its childs[start:end]
  • or a Deferred

if end == 0, the request is for all childs after start - childs[start:]

get_cover()

called by the MediaServer web should return

  • the filepath where to find the album art file

only needed when we have created for that item an albumArtURI property that does point back to us

get_id()
get_item()

called by the CDS and the MediaServer web should return

  • an UPnP ContentDirectoryServer DIDLLite object
  • or a Deferred
get_name()

called by the MediaServer web should return

  • the name of the item, it is always expected to be in unicode
get_path = None
info(message, *args, **kwargs)
log(message, *args, **kwargs)
logCategory = 'backend_item'
mimetype = 'directory'
msg(message, *args, **kwargs)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
class VideoPlaylist(*args, **kwargs)[source]

Bases: coherence.backends.banshee_storage.MusicPlaylist

id_type = 'videoplaylist'
db_to_didl(row)[source]
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
critical(message, *args, **kwargs)
db_id

Should be implemented in subclass

debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
get_child_count()

called by the CDS should return

  • the number of its childs - len(childs)
  • or a Deferred
get_children(start=0, request_count=0)

called by the CDS and the MediaServer web should return

  • a list of its childs[start:end]
  • or a Deferred

if end == 0, the request is for all childs after start - childs[start:]

get_cover()

called by the MediaServer web should return

  • the filepath where to find the album art file

only needed when we have created for that item an albumArtURI property that does point back to us

get_id()
get_item()

called by the CDS and the MediaServer web should return

  • an UPnP ContentDirectoryServer DIDLLite object
  • or a Deferred
get_name()

called by the MediaServer web should return

  • the name of the item, it is always expected to be in unicode
get_path = None
get_tracks(request_count)
info(message, *args, **kwargs)
log(message, *args, **kwargs)
logCategory = 'backend_item'
mimetype = 'directory'
msg(message, *args, **kwargs)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
class VideoSmartPlaylist(*args, **kwargs)[source]

Bases: coherence.backends.banshee_storage.MusicSmartPlaylist

id_type = 'videosmartplaylist'
db_to_didl(row)[source]
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
critical(message, *args, **kwargs)
db_id

Should be implemented in subclass

debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
get_child_count()

called by the CDS should return

  • the number of its childs - len(childs)
  • or a Deferred
get_children(start=0, request_count=0)

called by the CDS and the MediaServer web should return

  • a list of its childs[start:end]
  • or a Deferred

if end == 0, the request is for all childs after start - childs[start:]

get_cover()

called by the MediaServer web should return

  • the filepath where to find the album art file

only needed when we have created for that item an albumArtURI property that does point back to us

get_id()
get_item()

called by the CDS and the MediaServer web should return

  • an UPnP ContentDirectoryServer DIDLLite object
  • or a Deferred
get_name()

called by the MediaServer web should return

  • the name of the item, it is always expected to be in unicode
get_path = None
get_tracks(request_count)
info(message, *args, **kwargs)
log(message, *args, **kwargs)
logCategory = 'backend_item'
mimetype = 'directory'
msg(message, *args, **kwargs)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
class BaseTrack(*args, **kwargs)[source]

Bases: coherence.backend.BackendItem

definition for a track

get_children(start=0, request_count=0)[source]

called by the CDS and the MediaServer web should return

  • a list of its childs[start:end]
  • or a Deferred

if end == 0, the request is for all childs after start - childs[start:]

get_child_count()[source]

called by the CDS should return

  • the number of its childs - len(childs)
  • or a Deferred
get_resources()[source]
get_path()[source]

called by the MediaServer web should return

  • the filepath where to find the media file that this item does refer to
get_id()[source]
get_name()[source]

called by the MediaServer web should return

  • the name of the item, it is always expected to be in unicode
get_url()[source]
get_cover()[source]

called by the MediaServer web should return

  • the filepath where to find the album art file

only needed when we have created for that item an albumArtURI property that does point back to us

COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
get_item()

called by the CDS and the MediaServer web should return

  • an UPnP ContentDirectoryServer DIDLLite object
  • or a Deferred
info(message, *args, **kwargs)
log(message, *args, **kwargs)
logCategory = 'backend_item'
msg(message, *args, **kwargs)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
class Track(*args, **kwargs)[source]

Bases: coherence.backends.banshee_storage.BaseTrack

get_item()[source]

called by the CDS and the MediaServer web should return

  • an UPnP ContentDirectoryServer DIDLLite object
  • or a Deferred
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
get_child_count()

called by the CDS should return

  • the number of its childs - len(childs)
  • or a Deferred
get_children(start=0, request_count=0)

called by the CDS and the MediaServer web should return

  • a list of its childs[start:end]
  • or a Deferred

if end == 0, the request is for all childs after start - childs[start:]

get_cover()

called by the MediaServer web should return

  • the filepath where to find the album art file

only needed when we have created for that item an albumArtURI property that does point back to us

get_id()
get_name()

called by the MediaServer web should return

  • the name of the item, it is always expected to be in unicode
get_path()

called by the MediaServer web should return

  • the filepath where to find the media file that this item does refer to
get_resources()
get_url()
info(message, *args, **kwargs)
log(message, *args, **kwargs)
logCategory = 'backend_item'
msg(message, *args, **kwargs)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
class Video(*args, **kwargs)[source]

Bases: coherence.backends.banshee_storage.BaseTrack

get_item()[source]

called by the CDS and the MediaServer web should return

  • an UPnP ContentDirectoryServer DIDLLite object
  • or a Deferred
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
get_child_count()

called by the CDS should return

  • the number of its childs - len(childs)
  • or a Deferred
get_children(start=0, request_count=0)

called by the CDS and the MediaServer web should return

  • a list of its childs[start:end]
  • or a Deferred

if end == 0, the request is for all childs after start - childs[start:]

get_cover()

called by the MediaServer web should return

  • the filepath where to find the album art file

only needed when we have created for that item an albumArtURI property that does point back to us

get_id()
get_name()

called by the MediaServer web should return

  • the name of the item, it is always expected to be in unicode
get_path()

called by the MediaServer web should return

  • the filepath where to find the media file that this item does refer to
get_resources()
get_url()
info(message, *args, **kwargs)
log(message, *args, **kwargs)
logCategory = 'backend_item'
msg(message, *args, **kwargs)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
class BansheeDB(path=None)[source]

Bases: coherence.log.LogAble

logCategory = 'banshee_db'
open_db()[source]
close()[source]
get_local_music_library_id()[source]
get_local_video_library_id()[source]
get_artists()[source]
get_albums()[source]
get_music_playlists()[source]
get_playlists(source_id, PlaylistClass, SmartPlaylistClass)[source]
get_artist_with_id(artist_id)[source]
get_album_with_id(album_id)[source]
get_playlist_with_id(playlist_id, PlaylistClass)[source]
get_smart_playlist_with_id(playlist_id, PlaylistClass)[source]
get_music_playlist_with_id(playlist_id)[source]
get_music_smart_playlist_with_id(playlist_id)[source]
get_video_playlist_with_id(playlist_id)[source]
get_video_smart_playlist_with_id(playlist_id)[source]
get_track_with_id(track_id)[source]
get_track_for_uri(track_uri)[source]
get_tracks()[source]
get_video_with_id(video_id)[source]
get_videos()[source]
get_video_playlists()[source]
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
info(message, *args, **kwargs)
log(message, *args, **kwargs)
msg(message, *args, **kwargs)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
class BansheeStore(server, **kwargs)[source]

Bases: coherence.backend.BackendStore, coherence.backends.banshee_storage.BansheeDB

logCategory = 'banshee_store'
implements = ['MediaServer']
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
_get_all_items(id)

a helper method to get all items as a response to some XBox 360 UPnP Search action probably never be used as the backend will overwrite the wmc_mapping with more appropriate methods

close()
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
get_album_with_id(album_id)
get_albums()
get_artist_with_id(artist_id)
get_artists()
get_local_music_library_id()
get_local_video_library_id()
get_music_playlist_with_id(playlist_id)
get_music_playlists()
get_music_smart_playlist_with_id(playlist_id)
get_playlist_with_id(playlist_id, PlaylistClass)
get_playlists(source_id, PlaylistClass, SmartPlaylistClass)
get_smart_playlist_with_id(playlist_id, PlaylistClass)
get_track_for_uri(track_uri)
get_track_with_id(track_id)
get_tracks()
get_video_playlist_with_id(playlist_id)
get_video_playlists()
get_video_smart_playlist_with_id(playlist_id)
get_video_with_id(video_id)
get_videos()
info(message, *args, **kwargs)
init_completed(*args, **kwargs)

inform Coherence that this backend is ready for announcement this method just accepts any form of arguments as we don’t under which circumstances it is called

log(message, *args, **kwargs)
msg(message, *args, **kwargs)
open_db()
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

warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
release()[source]

if anything needs to be cleaned up upon shutdown of this backend, this is the place for it

get_by_id(item_id)[source]

called by the CDS or the MediaServer web

id is the id property of our DIDLLite item

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

should return

  • None when no matching item for that id is found,
  • a BackendItem,
  • or a Deferred
_lookup(item_type, item_id)[source]

coherence.backends.bbc_storage (module)

class BBCItem(parent_id, id, title, url)[source]

Bases: coherence.backend.BackendItem

get_item()[source]

called by the CDS and the MediaServer web should return

  • an UPnP ContentDirectoryServer DIDLLite object
  • or a Deferred
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
get_child_count()

called by the CDS should return

  • the number of its childs - len(childs)
  • or a Deferred
get_children(start=0, end=0)

called by the CDS and the MediaServer web should return

  • a list of its childs[start:end]
  • or a Deferred

if end == 0, the request is for all childs after start - childs[start:]

get_cover()

called by the MediaServer web should return

  • the filepath where to find the album art file

only needed when we have created for that item an albumArtURI property that does point back to us

get_name()

called by the MediaServer web should return

  • the name of the item, it is always expected to be in unicode
get_path()

called by the MediaServer web should return

  • the filepath where to find the media file that this item does refer to
info(message, *args, **kwargs)
log(message, *args, **kwargs)
logCategory = 'backend_item'
msg(message, *args, **kwargs)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
class Container(id, store, parent_id, title)[source]

Bases: coherence.backend.BackendItem

add_child(child)[source]
get_children(start=0, end=0)[source]

called by the CDS and the MediaServer web should return

  • a list of its childs[start:end]
  • or a Deferred

if end == 0, the request is for all childs after start - childs[start:]

get_child_count()[source]

called by the CDS should return

  • the number of its childs - len(childs)
  • or a Deferred
get_path()[source]

called by the MediaServer web should return

  • the filepath where to find the media file that this item does refer to
get_item()[source]

called by the CDS and the MediaServer web should return

  • an UPnP ContentDirectoryServer DIDLLite object
  • or a Deferred
get_name()[source]

called by the MediaServer web should return

  • the name of the item, it is always expected to be in unicode
get_id()[source]
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
get_cover()

called by the MediaServer web should return

  • the filepath where to find the album art file

only needed when we have created for that item an albumArtURI property that does point back to us

info(message, *args, **kwargs)
log(message, *args, **kwargs)
logCategory = 'backend_item'
msg(message, *args, **kwargs)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
class BBCStore(server, *args, **kwargs)[source]

Bases: coherence.backend.BackendStore

implements = ['MediaServer']
rss_url = 'http://open.bbc.co.uk/rad/uriplay/availablecontent'
get_next_id()[source]
get_by_id(id)[source]

called by the CDS or the MediaServer web

id is the id property of our DIDLLite item

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

should return

  • None when no matching item for that id is found,
  • a BackendItem,
  • or a Deferred
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

update_data()[source]
parse_data(root)[source]
queue_update(error_or_failure)[source]
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
_get_all_items(id)

a helper method to get all items as a response to some XBox 360 UPnP Search action probably never be used as the backend will overwrite the wmc_mapping with more appropriate methods

critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
info(message, *args, **kwargs)
init_completed(*args, **kwargs)

inform Coherence that this backend is ready for announcement this method just accepts any form of arguments as we don’t under which circumstances it is called

log(message, *args, **kwargs)
logCategory = 'backend_store'
msg(message, *args, **kwargs)
release()

if anything needs to be cleaned up upon shutdown of this backend, this is the place for it

warn(message, *args, **kwargs)
warning(message, *args, **kwargs)

coherence.backends.buzztard_control (module)

class BzClient(*args, **kwargs)[source]

Bases: twisted.protocols.basic.LineReceiver, coherence.log.LogAble

logCategory = 'buzztard_client'
factory = None
connectionMade()[source]

Called when a connection is made.

This may be considered the initializer of the protocol, because it is called when the connection is completed. For clients, this is called once the connection to the server has been established; for servers, this is called after an accept() call stops blocking and a socket has been received. If you need to send any greeting or initial message, do it here.

lineReceived(line)[source]

Override this for when each line is received.

@param line: The line which was received with the delimiter removed. @type line: C{bytes}

COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
MAX_LENGTH = 16384
_Loggable__logger = None
_buffer = b''
_busyReceiving = False
clearLineBuffer()

Clear buffered data.

@return: All of the cleared buffered data. @rtype: C{bytes}

connected = 0
connectionLost(reason=<twisted.python.failure.Failure twisted.internet.error.ConnectionDone: Connection was closed cleanly.>)

Called when the connection is shut down.

Clear any circular references here, and any external references to this Protocol. The connection has been closed.

@type reason: L{twisted.python.failure.Failure}

critical(message, *args, **kwargs)
dataReceived(data)

Protocol.dataReceived. Translates bytes into lines, and calls lineReceived (or rawDataReceived, depending on mode.)

debug(message, *args, **kwargs)
delimiter = b'\r\n'
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
info(message, *args, **kwargs)
lineLengthExceeded(line)

Called when the maximum line length has been reached. Override if it needs to be dealt with in some special way.

The argument ‘line’ contains the remainder of the buffer, starting with (at least some part) of the line which is too long. This may be more than one line, or may be only the initial portion of the line.

line_mode = 1
log(message, *args, **kwargs)
logPrefix()

Return a prefix matching the class name, to identify log messages related to this protocol instance.

makeConnection(transport)

Make a connection to a transport and a server.

This sets the ‘transport’ attribute of this Protocol, and calls the connectionMade() callback.

msg(message, *args, **kwargs)
pauseProducing()
paused = False
rawDataReceived(data)

Override this for when raw data is received.

resumeProducing()
sendLine(line)

Sends a line to the other end of the connection.

@param line: The line to send, not including the delimiter. @type line: C{bytes}

setLineMode(extra=b'')

Sets the line-mode of this receiver.

If you are calling this from a rawDataReceived callback, you can pass in extra unhandled data, and that data will be parsed for lines. Further data received will be sent to lineReceived rather than rawDataReceived.

Do not pass extra data if calling this function from within a lineReceived callback.

setRawMode()

Sets the raw mode of this receiver. Further data received will be sent to rawDataReceived rather than lineReceived.

stopProducing()
transport = None
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
class BzFactory(backend)[source]

Bases: twisted.internet.protocol.ClientFactory, coherence.log.LogAble

logCategory = 'buzztard_factory'
protocol

alias of BzClient

clientConnectionFailed(connector, reason)[source]

Called when a connection has failed to connect.

It may be useful to call connector.connect() - this will reconnect.

@type reason: L{twisted.python.failure.Failure}

clientConnectionLost(connector, reason)[source]

Called when an established connection is lost.

It may be useful to call connector.connect() - this will reconnect.

@type reason: L{twisted.python.failure.Failure}

startFactory()[source]

This will be called before I begin listening on a Port or Connector.

It will only be called once, even if the factory is connected to multiple ports.

This can be used to perform ‘unserialization’ tasks that are best put off until things are actually running, such as connecting to a database, opening files, etcetera.

clientReady(instance)[source]
sendMessage(msg)[source]
rebrowse()[source]
browse()[source]
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
buildProtocol(addr)

Create an instance of a subclass of Protocol.

The returned instance will handle input on an incoming server connection, and an attribute “factory” pointing to the creating factory.

Alternatively, L{None} may be returned to immediately close the new connection.

Override this method to alter how Protocol instances get created.

@param addr: an object implementing L{twisted.internet.interfaces.IAddress}

critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
doStart()

Make sure startFactory is called.

Users should not call this function themselves!

doStop()

Make sure stopFactory is called.

Users should not call this function themselves!

error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
classmethod forProtocol(protocol, *args, **kwargs)

Create a factory for the given protocol.

It sets the C{protocol} attribute and returns the constructed factory instance.

@param protocol: A L{Protocol} subclass

@param args: Positional arguments for the factory.

@param kwargs: Keyword arguments for the factory.

@return: A L{Factory} instance wired up to C{protocol}.

info(message, *args, **kwargs)
log(message, *args, **kwargs)
logPrefix()

Describe this factory for log messages.

msg(message, *args, **kwargs)
noisy = True
numPorts = 0
startedConnecting(connector)

Called when a connection has been started.

You can call connector.stopConnecting() to stop the connection attempt.

@param connector: a Connector object.

stopFactory()

This will be called before I stop listening on all Ports/Connectors.

This can be overridden to perform ‘shutdown’ tasks such as disconnecting database connections, closing files, etc.

It will be called, for example, before an application shuts down, if it was connected to a port. User code should not call this function directly.

warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
class BzConnection(backend=None, host='localhost', port=7654)[source]

Bases: coherence.log.LogAble

a singleton class

logCategory = 'buzztard_connection'
connection = None
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
info(message, *args, **kwargs)
log(message, *args, **kwargs)
msg(message, *args, **kwargs)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
class BuzztardItem(id, name, parent, mimetype, urlbase, host, update=False)[source]

Bases: coherence.log.LogAble

logCategory = 'buzztard_item'
remove(store)[source]
add_child(child, update=False)[source]
remove_child(child)[source]
get_children(start=0, request_count=0)[source]
get_child_count()[source]
get_id()[source]
get_update_id()[source]
get_path()[source]
get_name()[source]
get_parent()[source]
get_item()[source]
get_xml()[source]
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
info(message, *args, **kwargs)
log(message, *args, **kwargs)
msg(message, *args, **kwargs)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
class BuzztardStore(server, **kwargs)[source]

Bases: coherence.log.LogAble, coherence.extern.simple_plugin.Plugin

logCategory = 'buzztard_store'
implements = ['MediaServer']
add_content(line)[source]
append(name, mimetype, parent)[source]
remove(id)[source]
clear()[source]
len()[source]
get_by_id(id)[source]
getnextID()[source]
upnp_init()[source]
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
info(message, *args, **kwargs)
log(message, *args, **kwargs)
msg(message, *args, **kwargs)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
class BuzztardPlayer(device, **kwargs)[source]

Bases: coherence.log.LogAble

logCategory = 'buzztard_player'
implements = ['MediaRenderer']
vendor_value_defaults = {'RenderingControl': {'A_ARG_TYPE_Channel': 'Master'}}
vendor_range_defaults = {'RenderingControl': {'Volume': {'maximum': 100}}}
event(line)[source]
poll_player()[source]
load(uri, metadata=None)[source]
start(uri)[source]
stop()[source]
play()[source]
pause()[source]
seek(location)[source]
@param location: simple number = time to seek to, in seconds
+nL = relative seek forward n seconds -nL = relative seek backwards n seconds
mute()[source]
unmute()[source]
get_mute(line)[source]
get_repeat(line)[source]
set_repeat(playmode)[source]
get_volume(line)[source]
set_volume(volume)[source]
upnp_init()[source]
upnp_Play(*args, **kwargs)[source]
upnp_Pause(*args, **kwargs)[source]
upnp_Stop(*args, **kwargs)[source]
upnp_SetAVTransportURI(*args, **kwargs)[source]
upnp_SetMute(*args, **kwargs)[source]
upnp_SetVolume(*args, **kwargs)[source]
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
info(message, *args, **kwargs)
log(message, *args, **kwargs)
msg(message, *args, **kwargs)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
test_init_complete(backend)[source]
main()[source]

coherence.backends.dvbd_storage (module)

class Container(id, parent_id, name, store=None, children_callback=None, container_class=<class 'coherence.upnp.core.DIDLLite.Container'>)[source]

Bases: coherence.backend.BackendItem

logCategory = 'dvbd_store'
add_child(child)[source]
get_children(start=0, end=0)[source]

called by the CDS and the MediaServer web should return

  • a list of its childs[start:end]
  • or a Deferred

if end == 0, the request is for all childs after start - childs[start:]

remove_children()[source]
get_child_count()[source]

called by the CDS should return

  • the number of its childs - len(childs)
  • or a Deferred
get_item()[source]

called by the CDS and the MediaServer web should return

  • an UPnP ContentDirectoryServer DIDLLite object
  • or a Deferred
get_name()[source]

called by the MediaServer web should return

  • the name of the item, it is always expected to be in unicode
get_id()[source]
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
get_cover()

called by the MediaServer web should return

  • the filepath where to find the album art file

only needed when we have created for that item an albumArtURI property that does point back to us

get_path()[source]

called by the MediaServer web should return

  • the filepath where to find the media file that this item does refer to
info(message, *args, **kwargs)
log(message, *args, **kwargs)
msg(message, *args, **kwargs)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
class Channel(store, id, parent_id, name, url, network, mimetype)[source]

Bases: coherence.backend.BackendItem

logCategory = 'dvbd_store'
get_children(start=0, end=0)[source]

called by the CDS and the MediaServer web should return

  • a list of its childs[start:end]
  • or a Deferred

if end == 0, the request is for all childs after start - childs[start:]

get_child_count()[source]

called by the CDS should return

  • the number of its childs - len(childs)
  • or a Deferred
get_item(parent_id=None)[source]

called by the CDS and the MediaServer web should return

  • an UPnP ContentDirectoryServer DIDLLite object
  • or a Deferred
get_id()[source]
get_name()[source]

called by the MediaServer web should return

  • the name of the item, it is always expected to be in unicode
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
get_cover()

called by the MediaServer web should return

  • the filepath where to find the album art file

only needed when we have created for that item an albumArtURI property that does point back to us

get_path()

called by the MediaServer web should return

  • the filepath where to find the media file that this item does refer to
info(message, *args, **kwargs)
log(message, *args, **kwargs)
msg(message, *args, **kwargs)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
class Recording(store, id, parent_id, file, title, date, duration, mimetype)[source]

Bases: coherence.backend.BackendItem

logCategory = 'dvbd_store'
get_children(start=0, end=0)[source]

called by the CDS and the MediaServer web should return

  • a list of its childs[start:end]
  • or a Deferred

if end == 0, the request is for all childs after start - childs[start:]

get_child_count()[source]

called by the CDS should return

  • the number of its childs - len(childs)
  • or a Deferred
get_item(parent_id=None)[source]

called by the CDS and the MediaServer web should return

  • an UPnP ContentDirectoryServer DIDLLite object
  • or a Deferred
get_id()[source]
get_name()[source]

called by the MediaServer web should return

  • the name of the item, it is always expected to be in unicode
get_url()[source]
get_path()[source]

called by the MediaServer web should return

  • the filepath where to find the media file that this item does refer to
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
get_cover()

called by the MediaServer web should return

  • the filepath where to find the album art file

only needed when we have created for that item an albumArtURI property that does point back to us

info(message, *args, **kwargs)
log(message, *args, **kwargs)
msg(message, *args, **kwargs)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
class DVBDStore(server, **kwargs)[source]

Bases: coherence.backend.BackendStore

this is a backend to the DVB Daemon http://www.k-d-w.org/node/42

implements = ['MediaServer']
logCategory = 'dvbd_store'
get_by_id(id)[source]

called by the CDS or the MediaServer web

id is the id property of our DIDLLite item

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

should return

  • None when no matching item for that id is found,
  • a BackendItem,
  • or a Deferred
recording_changed(id, mode)[source]
get_recording_details(id)[source]
get_recordings()[source]
get_channel_details(channelList_interface, id)[source]
get_channelgroup_members(channel_items, channelList_interface)[source]
get_tv_channels(channelList_interface)[source]
get_deviceGroup_details(devicegroup_interface)[source]
get_device_groups(results)[source]
get_channel_groups()[source]
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

hidden_upnp_DestroyObject(*args, **kwargs)[source]
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
_get_all_items(id)

a helper method to get all items as a response to some XBox 360 UPnP Search action probably never be used as the backend will overwrite the wmc_mapping with more appropriate methods

critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
info(message, *args, **kwargs)
init_completed(*args, **kwargs)

inform Coherence that this backend is ready for announcement this method just accepts any form of arguments as we don’t under which circumstances it is called

log(message, *args, **kwargs)
msg(message, *args, **kwargs)
release()

if anything needs to be cleaned up upon shutdown of this backend, this is the place for it

warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
class DVBDScheduledRecording(server, **kwargs)[source]

Bases: coherence.backend.BackendStore

logCategory = 'dvbd_store'
get_timer_details(tid)[source]
get_timers()[source]
add_timer(channel_id, start_datetime, duration)[source]
delete_timer(tid)[source]
upnp_GetPropertyList(*args, **kwargs)[source]
upnp_GetAllowedValues(*args, **kwargs)[source]
upnp_GetStateUpdateID(*args, **kwargs)[source]
upnp_BrowseRecordSchedules(*args, **kwargs)[source]
upnp_BrowseRecordTasks(*args, **kwargs)[source]
upnp_CreateRecordSchedule(*args, **kwargs)[source]
upnp_DeleteRecordSchedule(*args, **kwargs)[source]
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
_get_all_items(id)

a helper method to get all items as a response to some XBox 360 UPnP Search action probably never be used as the backend will overwrite the wmc_mapping with more appropriate methods

critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
get_by_id(id)

called by the CDS or the MediaServer web

id is the id property of our DIDLLite item

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

should return

  • None when no matching item for that id is found,
  • a BackendItem,
  • or a Deferred
implements = []
info(message, *args, **kwargs)
init_completed(*args, **kwargs)

inform Coherence that this backend is ready for announcement this method just accepts any form of arguments as we don’t under which circumstances it is called

log(message, *args, **kwargs)
msg(message, *args, **kwargs)
release()

if anything needs to be cleaned up upon shutdown of this backend, this is the place for it

upnp_GetRecordSchedule(*args, **kwargs)[source]
upnp_init()

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

warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
upnp_GetRecordTask(*args, **kwargs)[source]

coherence.backends.elisa_renderer (module)

class ElisaPlayer(device, **kwargs)[source]

Bases: coherence.log.LogAble, coherence.extern.simple_plugin.Plugin

a backend to the Elisa player

logCategory = 'elisa_player'
implements = ['MediaRenderer']
vendor_value_defaults = {'RenderingControl': {'A_ARG_TYPE_Channel': 'Master'}}
vendor_range_defaults = {'RenderingControl': {'Volume': {'maximum': 100}}}
call_player(method, callback, *args)[source]
poll_player()[source]
query_position()[source]
load(uri, metadata)[source]
start(uri, metadata=None)[source]
stop()[source]
play()[source]
pause()[source]
seek(location)[source]
@param location: simple number = time to seek to, in seconds
+nL = relative seek forward n seconds -nL = relative seek backwards n seconds
mute()[source]
unmute()[source]
get_mute()[source]
get_volume()[source]

playbin volume is a double from 0.0 - 10.0

set_volume(volume)[source]
upnp_init()[source]
upnp_Play(*args, **kwargs)[source]
upnp_Pause(*args, **kwargs)[source]
upnp_Stop(*args, **kwargs)[source]
upnp_SetAVTransportURI(*args, **kwargs)[source]
upnp_SetMute(*args, **kwargs)[source]
upnp_SetVolume(*args, **kwargs)[source]
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
info(message, *args, **kwargs)
log(message, *args, **kwargs)
msg(message, *args, **kwargs)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
main()[source]

coherence.backends.elisa_storage (module)

class ElisaMediaStore(server, **kwargs)[source]

Bases: coherence.extern.simple_plugin.Plugin

this is a backend to the Elisa Media DB

Elisa needs to expose two methods

get_root_id(media_type)
if media_type == ‘*’
this returns the root id of the media collection
if media_type == ‘audio’
this returns the root id of the audio collection
get_item_by_id(id)
this returns a dict with the following keys: id = id in the media db parent_id = parent_id in the media db name = title, album name or basename mimetype = ‘directory’ or real mimetype children = list of objects for which this item is the parent location = filesystem path if item is a file cover = url by which the cover image can be retrieved (OPTIONAL) size = in bytes (OPTIONAL)
implements = ['MediaServer']
get_store()[source]
get_by_id(id)[source]
set_root_id(id)[source]
get_root_id(media_type='audio')[source]

ask Elisa to tell us the id of the top item representing the media_type == ‘something’ collection

upnp_init()[source]
upnp_Browse(*args, **kwargs)[source]

coherence.backends.feed_storage (module)

class RedirectingReverseProxyUriResource(uri, reactor=<twisted.internet.epollreactor.EPollReactor object>)[source]

Bases: coherence.upnp.core.utils.ReverseProxyUriResource

render(request)[source]

Render a request by forwarding it to the proxied server.

follow_redirect(uri)[source]
delEntity(name)
entityType = <InterfaceClass twisted.web.resource.IResource>
getChild(path, request)

Create and return a proxy resource with the same proxy configuration as this one, except that its path also contains the segment given by C{path} at the end.

getChildForRequest(request)
getChildWithDefault(path, request)

Retrieve a static or dynamically generated child resource from me.

First checks if a resource was added manually by putChild, and then call getChild to check for dynamic resources. Only override if you want to affect behaviour of all child lookups, rather than just dynamic ones.

This will check to see if I have a pre-registered child resource of the given name, and call getChild if I do not.

@see: L{IResource.getChildWithDefault}

getDynamicEntity(name, request)
getStaticEntity(name)
isLeaf = 0
listDynamicEntities(request=None)
listDynamicNames()
listEntities()
listNames()
listStaticEntities()
listStaticNames()
proxyClientFactoryClass

alias of coherence.upnp.core.utils.ProxyClientFactory

putChild(path, child)

Register a static child.

You almost certainly don’t want ‘/’ in your path. If you intended to have the root of a folder, e.g. /foo/, you want path to be ‘’.

@see: L{IResource.putChild}

reallyPutEntity(name, entity)
render_HEAD(request)

Default handling of HEAD method.

I just return self.render_GET(request). When method is HEAD, the framework will handle this correctly.

resetTarget(host, port, path, qs='')
resetUri(uri)
server = None
uri = None
exception FeedStorageConfigurationException[source]

Bases: Exception

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

class FeedContainer(parent_id, id, title)[source]

Bases: coherence.backend.BackendItem

get_children(start=0, end=0)[source]

returns all the chidlren of this container

get_child_count()[source]

returns the number of children in this container

COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
get_cover()

called by the MediaServer web should return

  • the filepath where to find the album art file

only needed when we have created for that item an albumArtURI property that does point back to us

get_item()

called by the CDS and the MediaServer web should return

  • an UPnP ContentDirectoryServer DIDLLite object
  • or a Deferred
get_name()

called by the MediaServer web should return

  • the name of the item, it is always expected to be in unicode
get_path()

called by the MediaServer web should return

  • the filepath where to find the media file that this item does refer to
info(message, *args, **kwargs)
log(message, *args, **kwargs)
logCategory = 'backend_item'
msg(message, *args, **kwargs)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
class FeedEnclosure(store, parent, id, title, enclosure)[source]

Bases: coherence.backend.BackendItem

COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
get_child_count()

called by the CDS should return

  • the number of its childs - len(childs)
  • or a Deferred
get_children(start=0, end=0)

called by the CDS and the MediaServer web should return

  • a list of its childs[start:end]
  • or a Deferred

if end == 0, the request is for all childs after start - childs[start:]

get_cover()

called by the MediaServer web should return

  • the filepath where to find the album art file

only needed when we have created for that item an albumArtURI property that does point back to us

get_item()

called by the CDS and the MediaServer web should return

  • an UPnP ContentDirectoryServer DIDLLite object
  • or a Deferred
get_name()

called by the MediaServer web should return

  • the name of the item, it is always expected to be in unicode
get_path()

called by the MediaServer web should return

  • the filepath where to find the media file that this item does refer to
info(message, *args, **kwargs)
log(message, *args, **kwargs)
logCategory = 'backend_item'
msg(message, *args, **kwargs)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
class FeedStore(server, **kwargs)[source]

Bases: coherence.backend.BackendStore

a general feed store

logCategory = 'feed_store'
implements = ['MediaServer']
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
_get_all_items(id)

a helper method to get all items as a response to some XBox 360 UPnP Search action probably never be used as the backend will overwrite the wmc_mapping with more appropriate methods

critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
get_by_id(id)[source]

returns the item according to the DIDLite id

info(message, *args, **kwargs)
init_completed(*args, **kwargs)

inform Coherence that this backend is ready for announcement this method just accepts any form of arguments as we don’t under which circumstances it is called

log(message, *args, **kwargs)
msg(message, *args, **kwargs)
release()

if anything needs to be cleaned up upon shutdown of this backend, this is the place for it

upnp_init()

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

warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
_update_data()[source]

get the feed xml, parse it, etc.

coherence.backends.flickr_storage (module)

coherence.backends.fs_storage (module)

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 explicitely. 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>

_natural_key(s)[source]
exception NoThumbnailFound[source]

Bases: Exception

no thumbnail found

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

_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'
rebuild(urlbase)[source]
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

remove()[source]
add_child(child, update=False)[source]
remove_child(child)[source]
get_children(start=0, request_count=0)[source]

called by the CDS and the MediaServer web should return

  • a list of its childs[start:end]
  • or a Deferred

if end == 0, the request is for all childs after start - childs[start:]

get_child_count()[source]

called by the CDS should return

  • the number of its childs - len(childs)
  • or a Deferred
get_id()[source]
get_update_id()[source]
get_path()[source]

called by the MediaServer web should return

  • the filepath where to find the media file that this item does refer to
get_realpath()[source]
set_path(path=None, extension=None)[source]
get_name()[source]

called by the MediaServer web should return

  • the name of the item, it is always expected to be in unicode
get_cover()[source]

called by the MediaServer web should return

  • the filepath where to find the album art file

only needed when we have created for that item an albumArtURI property that does point back to us

get_parent()[source]
get_item()[source]

called by the CDS and the MediaServer web should return

  • an UPnP ContentDirectoryServer DIDLLite object
  • or a Deferred
get_xml()[source]
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
info(message, *args, **kwargs)
log(message, *args, **kwargs)
msg(message, *args, **kwargs)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
class FSStore(server, **kwargs)[source]

Bases: coherence.backend.BackendStore

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': [('/home/opacam/', 'audio', 'audio'), ('/home/opacam/', 'image', 'images'), ('/home/opacam/', 'video', 'videos')], '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

len()[source]
get_by_id(id)[source]

called by the CDS or the MediaServer web

id is the id property of our DIDLLite item

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

should return

  • None when no matching item for that id is found,
  • a BackendItem,
  • or a Deferred
get_id_by_name(parent='0', name='')[source]
get_url_by_name(parent='0', name='')[source]
update_config(**kwargs)[source]
add_content_folder(path)[source]
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
_get_all_items(id)

a helper method to get all items as a response to some XBox 360 UPnP Search action probably never be used as the backend will overwrite the wmc_mapping with more appropriate methods

critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
info(message, *args, **kwargs)
init_completed(*args, **kwargs)

inform Coherence that this backend is ready for announcement this method just accepts any form of arguments as we don’t under which circumstances it is called

log(message, *args, **kwargs)
msg(message, *args, **kwargs)
remove_content_folder(path)[source]
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
walk(path, parent=None, ignore_file_pattern='')[source]
create(mimetype, path, parent)[source]
append(bytes_path, parent)[source]
remove(id)[source]
notify(ignore, path, mask, parameter=None)[source]
getnextID()[source]
backend_import(item, data)[source]
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

upnp_ImportResource(*args, **kwargs)[source]
upnp_CreateObject(*args, **kwargs)[source]
hidden_upnp_DestroyObject(*args, **kwargs)[source]

coherence.backends.gallery2_storage (module)

class ProxyGallery2Image(uri)[source]

Bases: coherence.upnp.core.utils.ReverseProxyUriResource

render(request)[source]

Render a request by forwarding it to the proxied server.

delEntity(name)
entityType = <InterfaceClass twisted.web.resource.IResource>
getChild(path, request)

Create and return a proxy resource with the same proxy configuration as this one, except that its path also contains the segment given by C{path} at the end.

getChildForRequest(request)
getChildWithDefault(path, request)

Retrieve a static or dynamically generated child resource from me.

First checks if a resource was added manually by putChild, and then call getChild to check for dynamic resources. Only override if you want to affect behaviour of all child lookups, rather than just dynamic ones.

This will check to see if I have a pre-registered child resource of the given name, and call getChild if I do not.

@see: L{IResource.getChildWithDefault}

getDynamicEntity(name, request)
getStaticEntity(name)
isLeaf = 0
listDynamicEntities(request=None)
listDynamicNames()
listEntities()
listNames()
listStaticEntities()
listStaticNames()
proxyClientFactoryClass

alias of coherence.upnp.core.utils.ProxyClientFactory

putChild(path, child)

Register a static child.

You almost certainly don’t want ‘/’ in your path. If you intended to have the root of a folder, e.g. /foo/, you want path to be ‘’.

@see: L{IResource.putChild}

reallyPutEntity(name, entity)
render_HEAD(request)

Default handling of HEAD method.

I just return self.render_GET(request). When method is HEAD, the framework will handle this correctly.

resetTarget(host, port, path, qs='')
resetUri(uri)
server = None
uri = None
class Gallery2Item(id, obj, parent, mimetype, urlbase, UPnPClass, update=False)[source]

Bases: coherence.backend.BackendItem

logCategory = 'gallery2_item'
remove()[source]
add_child(child, update=False)[source]
remove_child(child)[source]
get_children(start=0, request_count=0)[source]

called by the CDS and the MediaServer web should return

  • a list of its childs[start:end]
  • or a Deferred

if end == 0, the request is for all childs after start - childs[start:]

get_child_count()[source]

called by the CDS should return

  • the number of its childs - len(childs)
  • or a Deferred
get_id()[source]
get_update_id()[source]
get_path()[source]

called by the MediaServer web should return

  • the filepath where to find the media file that this item does refer to
get_name()[source]

called by the MediaServer web should return

  • the name of the item, it is always expected to be in unicode
get_parent()[source]
get_item()[source]

called by the CDS and the MediaServer web should return

  • an UPnP ContentDirectoryServer DIDLLite object
  • or a Deferred
get_xml()[source]
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
get_cover()

called by the MediaServer web should return

  • the filepath where to find the album art file

only needed when we have created for that item an albumArtURI property that does point back to us

info(message, *args, **kwargs)
log(message, *args, **kwargs)
msg(message, *args, **kwargs)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
class Gallery2Store(server, **kwargs)[source]

Bases: coherence.backend.BackendStore

logCategory = 'gallery2_store'
implements = ['MediaServer']
description = ('Gallery2', 'exposes the photos from a Gallery2 photo repository.', None)
options = [{'option': 'name', 'text': 'Server Name:', 'type': 'string', 'default': 'my media', 'help': 'the name under this MediaServer shall show up with on other UPnP clients'}, {'option': 'version', 'text': 'UPnP Version:', 'type': 'int', 'default': 2, 'enum': (2, 1), 'help': 'the highest UPnP version this MediaServer shall support', 'level': 'advance'}, {'option': 'uuid', 'text': 'UUID Identifier:', 'type': 'string', 'help': 'the unique (UPnP) identifier for this MediaServer, usually automatically set', 'level': 'advance'}, {'option': 'server_url', 'text': 'Server URL:', 'type': 'string'}, {'option': 'username', 'text': 'User ID:', 'type': 'string', 'group': 'User Account'}, {'option': 'password', 'text': 'Password:', 'type': 'string', 'group': 'User Account'}]
append(obj, parent)[source]
len()[source]
get_by_id(id)[source]

called by the CDS or the MediaServer web

id is the id property of our DIDLLite item

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

should return

  • None when no matching item for that id is found,
  • a BackendItem,
  • or a Deferred
getnextID()[source]
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
_get_all_items(id)

a helper method to get all items as a response to some XBox 360 UPnP Search action probably never be used as the backend will overwrite the wmc_mapping with more appropriate methods

critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
get_url_for_image(gallery2_id)[source]
info(message, *args, **kwargs)
init_completed(*args, **kwargs)

inform Coherence that this backend is ready for announcement this method just accepts any form of arguments as we don’t under which circumstances it is called

log(message, *args, **kwargs)
msg(message, *args, **kwargs)
release()

if anything needs to be cleaned up upon shutdown of this backend, this is the place for it

warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
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

retrieveAlbums(album_gallery2_id, parent)[source]
retrieveItemsForAlbum(album_id, parent)[source]
main()[source]

coherence.backends.gstreamer_renderer (module)

coherence.backends.iradio_storage (module)

class PlaylistStreamProxy(uri)[source]

Bases: coherence.upnp.core.utils.ReverseProxyUriResource, coherence.log.LogAble

proxies audio streams published as M3U playlists (typically the case for shoutcast streams)

logCategory = 'PlaylistStreamProxy'
stream_url = None
requestFinished(result)[source]

self.connection is set in utils.ReverseProxyResource.render

render(request)[source]

Render a request by forwarding it to the proxied server.

COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
delEntity(name)
entityType = <InterfaceClass twisted.web.resource.IResource>
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
getChild(path, request)

Create and return a proxy resource with the same proxy configuration as this one, except that its path also contains the segment given by C{path} at the end.

getChildForRequest(request)
getChildWithDefault(path, request)

Retrieve a static or dynamically generated child resource from me.

First checks if a resource was added manually by putChild, and then call getChild to check for dynamic resources. Only override if you want to affect behaviour of all child lookups, rather than just dynamic ones.

This will check to see if I have a pre-registered child resource of the given name, and call getChild if I do not.

@see: L{IResource.getChildWithDefault}

getDynamicEntity(name, request)
getStaticEntity(name)
info(message, *args, **kwargs)
isLeaf = 0
listDynamicEntities(request=None)
listDynamicNames()
listEntities()
listNames()
listStaticEntities()
listStaticNames()
log(message, *args, **kwargs)
msg(message, *args, **kwargs)
proxyClientFactoryClass

alias of coherence.upnp.core.utils.ProxyClientFactory

putChild(path, child)

Register a static child.

You almost certainly don’t want ‘/’ in your path. If you intended to have the root of a folder, e.g. /foo/, you want path to be ‘’.

@see: L{IResource.putChild}

reallyPutEntity(name, entity)
render_HEAD(request)

Default handling of HEAD method.

I just return self.render_GET(request). When method is HEAD, the framework will handle this correctly.

resetTarget(host, port, path, qs='')
resetUri(uri)
server = None
uri = None
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
class IRadioItem(station_id, title, stream_url, mimetype)[source]

Bases: coherence.backend.BackendItem

logCategory = 'iradio'
replace_by(item)[source]
get_item()[source]

called by the CDS and the MediaServer web should return

  • an UPnP ContentDirectoryServer DIDLLite object
  • or a Deferred
get_path()[source]

called by the MediaServer web should return

  • the filepath where to find the media file that this item does refer to
get_id()[source]
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
get_child_count()

called by the CDS should return

  • the number of its childs - len(childs)
  • or a Deferred
get_children(start=0, end=0)

called by the CDS and the MediaServer web should return

  • a list of its childs[start:end]
  • or a Deferred

if end == 0, the request is for all childs after start - childs[start:]

get_cover()

called by the MediaServer web should return

  • the filepath where to find the album art file

only needed when we have created for that item an albumArtURI property that does point back to us

get_name()

called by the MediaServer web should return

  • the name of the item, it is always expected to be in unicode
info(message, *args, **kwargs)
log(message, *args, **kwargs)
msg(message, *args, **kwargs)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
class IRadioStore(server, **kwargs)[source]

Bases: coherence.backend.AbstractBackendStore

logCategory = 'iradio'
implements = ['MediaServer']
genre_parent_items = {}
append_genre(parent, genre)[source]
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

retrieveItemsForGenre(parent, genres, per_page=1, offset=0, page=0)[source]
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
_get_all_items(id)

a helper method to get all items as a response to some XBox 360 UPnP Search action probably never be used as the backend will overwrite the wmc_mapping with more appropriate methods

append_item(item, storage_id=None)
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
get_by_id(id)

called by the CDS or the MediaServer web

id is the id property of our DIDLLite item

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

should return

  • None when no matching item for that id is found,
  • a BackendItem,
  • or a Deferred
get_root_id()
get_root_item()
getnextID()
info(message, *args, **kwargs)
init_completed(*args, **kwargs)

inform Coherence that this backend is ready for announcement this method just accepts any form of arguments as we don’t under which circumstances it is called

len()
log(message, *args, **kwargs)
msg(message, *args, **kwargs)
release()

if anything needs to be cleaned up upon shutdown of this backend, this is the place for it

remove_item(item)
retrieveGenreList()[source]
set_root_item(item)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)

coherence.backends.itv_storage (module)

class ProxyStream(uri)[source]

Bases: coherence.upnp.core.utils.ReverseProxyUriResource, coherence.log.LogAble

logCategory = 'itv'
stream_url = None
requestFinished(result)[source]

self.connection is set in utils.ReverseProxyResource.render

render(request)[source]

Render a request by forwarding it to the proxied server.

COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
delEntity(name)
entityType = <InterfaceClass twisted.web.resource.IResource>
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
getChild(path, request)

Create and return a proxy resource with the same proxy configuration as this one, except that its path also contains the segment given by C{path} at the end.

getChildForRequest(request)
getChildWithDefault(path, request)

Retrieve a static or dynamically generated child resource from me.

First checks if a resource was added manually by putChild, and then call getChild to check for dynamic resources. Only override if you want to affect behaviour of all child lookups, rather than just dynamic ones.

This will check to see if I have a pre-registered child resource of the given name, and call getChild if I do not.

@see: L{IResource.getChildWithDefault}

getDynamicEntity(name, request)
getStaticEntity(name)
info(message, *args, **kwargs)
isLeaf = 0
listDynamicEntities(request=None)
listDynamicNames()
listEntities()
listNames()
listStaticEntities()
listStaticNames()
log(message, *args, **kwargs)
msg(message, *args, **kwargs)
proxyClientFactoryClass

alias of coherence.upnp.core.utils.ProxyClientFactory

putChild(path, child)

Register a static child.

You almost certainly don’t want ‘/’ in your path. If you intended to have the root of a folder, e.g. /foo/, you want path to be ‘’.

@see: L{IResource.putChild}

reallyPutEntity(name, entity)
render_HEAD(request)

Default handling of HEAD method.

I just return self.render_GET(request). When method is HEAD, the framework will handle this correctly.

resetTarget(host, port, path, qs='')
resetUri(uri)
server = None
uri = None
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
class Container(id, store, parent_id, title)[source]

Bases: coherence.backend.BackendItem

add_child(child)[source]
get_children(start=0, end=0)[source]

called by the CDS and the MediaServer web should return

  • a list of its childs[start:end]
  • or a Deferred

if end == 0, the request is for all childs after start - childs[start:]

get_child_count()[source]

called by the CDS should return

  • the number of its childs - len(childs)
  • or a Deferred
get_path()[source]

called by the MediaServer web should return

  • the filepath where to find the media file that this item does refer to
get_item()[source]

called by the CDS and the MediaServer web should return

  • an UPnP ContentDirectoryServer DIDLLite object
  • or a Deferred
get_name()[source]

called by the MediaServer web should return

  • the name of the item, it is always expected to be in unicode
get_id()[source]
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
get_cover()

called by the MediaServer web should return

  • the filepath where to find the album art file

only needed when we have created for that item an albumArtURI property that does point back to us

info(message, *args, **kwargs)
log(message, *args, **kwargs)
logCategory = 'backend_item'
msg(message, *args, **kwargs)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
class ITVItem(store, id, obj, parent)[source]

Bases: coherence.backend.BackendItem

logCategory = 'itv'
get_item()[source]

called by the CDS and the MediaServer web should return

  • an UPnP ContentDirectoryServer DIDLLite object
  • or a Deferred
get_path()[source]

called by the MediaServer web should return

  • the filepath where to find the media file that this item does refer to
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
get_child_count()

called by the CDS should return

  • the number of its childs - len(childs)
  • or a Deferred
get_children(start=0, end=0)

called by the CDS and the MediaServer web should return

  • a list of its childs[start:end]
  • or a Deferred

if end == 0, the request is for all childs after start - childs[start:]

get_cover()

called by the MediaServer web should return

  • the filepath where to find the album art file

only needed when we have created for that item an albumArtURI property that does point back to us

get_name()

called by the MediaServer web should return

  • the name of the item, it is always expected to be in unicode
info(message, *args, **kwargs)
log(message, *args, **kwargs)
msg(message, *args, **kwargs)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
class ITVStore(server, **kwargs)[source]

Bases: coherence.backend.BackendStore

logCategory = 'itv'
implements = ['MediaServer']
description = ('Shoutcast TV', 'cexposes the list of video streams from Shoutcast TV.', None)
options = [{'option': 'name', 'text': 'Server Name:', 'type': 'string', 'default': 'my media', 'help': 'the name under this MediaServer shall show up with on other UPnP clients'}, {'option': 'version', 'text': 'UPnP Version:', 'type': 'int', 'default': 2, 'enum': (2, 1), 'help': 'the highest UPnP version this MediaServer shall support', 'level': 'advance'}, {'option': 'uuid', 'text': 'UUID Identifier:', 'type': 'string', 'help': 'the unique (UPnP) identifier for this MediaServer, usually automatically set', 'level': 'advance'}, {'option': 'genrelist', 'text': 'Server URL', 'type': 'string', 'default': 'http://www.shoutcast.com/sbin/newtvlister.phtml?service=winamp2&no_compress=1'}]
storeItem(parent, item, id)[source]
appendGenre(genre, parent)[source]
appendFeed(obj, parent)[source]
len()[source]
get_by_id(id)[source]

called by the CDS or the MediaServer web

id is the id property of our DIDLLite item

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

should return

  • None when no matching item for that id is found,
  • a BackendItem,
  • or a Deferred
getnextID()[source]
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

COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
_get_all_items(id)

a helper method to get all items as a response to some XBox 360 UPnP Search action probably never be used as the backend will overwrite the wmc_mapping with more appropriate methods

critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
info(message, *args, **kwargs)
init_completed(*args, **kwargs)

inform Coherence that this backend is ready for announcement this method just accepts any form of arguments as we don’t under which circumstances it is called

log(message, *args, **kwargs)
msg(message, *args, **kwargs)
release()

if anything needs to be cleaned up upon shutdown of this backend, this is the place for it

retrieveList(parent)[source]
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)

coherence.backends.lastfm_storage (module)

INFO lastFM_user Dez 14 17:35:27 Got new sessionid:
‘1488f34a1cbed7c9f4232f8fd563c3bd’ (coherence/backends/lastfm_storage.py:60)
DEBUG lastFM_stream Dez 14 17:35:53 render
<GET /da525474-5357-4d1b-a894-76b1293224c9/1005 HTTP/1.1> (coherence/backends/lastfm_storage.py:148)

command GET rest /user/e0362c757ef49169e9a0f0970cc2d367.mp3 headers {‘icy-metadata’: ‘1’, ‘host’: ‘kingpin5.last.fm’,

‘te’: ‘trailers’, ‘connection’: ‘TE’, ‘user-agent’: ‘gnome-vfs/2.12.0.19 neon/0.24.7’}

ProxyClient handleStatus HTTP/1.1 200 OK ProxyClient handleHeader Content-Type audio/mpeg ProxyClient handleHeader Content-Length 4050441 ProxyClient handleHeader Cache-Control no-cache, must-revalidate DEBUG lastFM_stream Dez 14 17:35:53 render

<GET /da525474-5357-4d1b-a894-76b1293224c9/1005 HTTP/1.1> (coherence/backends/lastfm_storage.py:148)

command GET rest /user/e0362c757ef49169e9a0f0970cc2d367.mp3 headers {‘icy-metadata’: ‘1’, ‘host’: ‘kingpin5.last.fm’,

‘te’: ‘trailers’, ‘connection’: ‘TE’, ‘user-agent’: ‘gnome-vfs/2.12.0.19 neon/0.24.7’}

ProxyClient handleStatus HTTP/1.1 403 Invalid ticket

class LastFMUser(user, passwd)[source]

Bases: coherence.log.LogAble

logCategory = 'lastFM_user'
host = 'ws.audioscrobbler.com'
basepath = '/radio'
sessionid = None
parent = None
getting_tracks = False
tracks = []
user = None
passwd = None
login()[source]
get_tracks()[source]
update(item)[source]
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
info(message, *args, **kwargs)
log(message, *args, **kwargs)
msg(message, *args, **kwargs)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
class LFMProxyStream(uri, parent)[source]

Bases: coherence.upnp.core.utils.ReverseProxyResource, coherence.log.LogAble

logCategory = 'lastFM_stream'
render(request)[source]

Render a request by forwarding it to the proxied server.

COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
delEntity(name)
entityType = <InterfaceClass twisted.web.resource.IResource>
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
getChild(path, request)

Create and return a proxy resource with the same proxy configuration as this one, except that its path also contains the segment given by C{path} at the end.

getChildForRequest(request)
getChildWithDefault(path, request)

Retrieve a static or dynamically generated child resource from me.

First checks if a resource was added manually by putChild, and then call getChild to check for dynamic resources. Only override if you want to affect behaviour of all child lookups, rather than just dynamic ones.

This will check to see if I have a pre-registered child resource of the given name, and call getChild if I do not.

@see: L{IResource.getChildWithDefault}

getDynamicEntity(name, request)
getStaticEntity(name)
info(message, *args, **kwargs)
isLeaf = 0
listDynamicEntities(request=None)
listDynamicNames()
listEntities()
listNames()
listStaticEntities()
listStaticNames()
log(message, *args, **kwargs)
msg(message, *args, **kwargs)
proxyClientFactoryClass

alias of coherence.upnp.core.utils.ProxyClientFactory

putChild(path, child)

Register a static child.

You almost certainly don’t want ‘/’ in your path. If you intended to have the root of a folder, e.g. /foo/, you want path to be ‘’.

@see: L{IResource.putChild}

reallyPutEntity(name, entity)
render_HEAD(request)

Default handling of HEAD method.

I just return self.render_GET(request). When method is HEAD, the framework will handle this correctly.

resetTarget(host, port, path, qs='')
server = None
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
class LastFMItem(id, obj, parent, mimetype, urlbase, UPnPClass, update=False)[source]

Bases: coherence.log.LogAble

logCategory = 'LastFM_item'
remove()[source]
add_child(child, update=False)[source]
remove_child(child)[source]
get_children(start=0, request_count=0)[source]
get_child_count()[source]
get_id()[source]
get_update_id()[source]
get_path()[source]
get_name()[source]
get_parent()[source]
get_item()[source]
get_xml()[source]
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
info(message, *args, **kwargs)
log(message, *args, **kwargs)
msg(message, *args, **kwargs)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
class LastFMStore(server, **kwargs)[source]

Bases: coherence.log.LogAble, coherence.extern.simple_plugin.Plugin

logCategory = 'lastFM_store'
implements = ['MediaServer']
append(obj, parent)[source]
remove(item)[source]
len()[source]
get_by_id(id)[source]
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
getnextID()[source]
info(message, *args, **kwargs)
log(message, *args, **kwargs)
msg(message, *args, **kwargs)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
upnp_init()[source]
main()[source]

coherence.backends.lolcats_storage (module)

This is a Media Backend that allows you to access the cool and cute pictures from lolcats.com. This is mainly meant as a Sample Media Backend to learn how to write a Media Backend.

So. You are still reading which allows me to assume that you want to learn how to write a Media Backend for Coherence. NICE :) .

Once again: This is a SIMPLE Media Backend. It does not contain any big requests, searches or even transcoding. The only thing we want to do in this simple example, is to fetch a rss link on startup, parse it, save it and restart the process one hour later again. Well, on top of this, we also want to provide these informations as a Media Server in the UPnP/DLNA Network of course ;) .

Wow. You are still reading. You must be really interested. Then let’s go.

class LolcatsImage(parent_id, id, title, url)[source]

Bases: coherence.backend.BackendItem

COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
get_child_count()

called by the CDS should return

  • the number of its childs - len(childs)
  • or a Deferred
get_children(start=0, end=0)

called by the CDS and the MediaServer web should return

  • a list of its childs[start:end]
  • or a Deferred

if end == 0, the request is for all childs after start - childs[start:]

get_cover()

called by the MediaServer web should return

  • the filepath where to find the album art file

only needed when we have created for that item an albumArtURI property that does point back to us

get_item()

called by the CDS and the MediaServer web should return

  • an UPnP ContentDirectoryServer DIDLLite object
  • or a Deferred
get_name()

called by the MediaServer web should return

  • the name of the item, it is always expected to be in unicode
get_path()

called by the MediaServer web should return

  • the filepath where to find the media file that this item does refer to
info(message, *args, **kwargs)
log(message, *args, **kwargs)
logCategory = 'backend_item'
msg(message, *args, **kwargs)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
class LolcatsContainer(parent_id, id)[source]

Bases: coherence.backend.BackendItem

get_children(start=0, end=0)[source]

called by the CDS and the MediaServer web should return

  • a list of its childs[start:end]
  • or a Deferred

if end == 0, the request is for all childs after start - childs[start:]

get_child_count()[source]

called by the CDS should return

  • the number of its childs - len(childs)
  • or a Deferred
get_item()[source]

called by the CDS and the MediaServer web should return

  • an UPnP ContentDirectoryServer DIDLLite object
  • or a Deferred
get_name()[source]

called by the MediaServer web should return

  • the name of the item, it is always expected to be in unicode
get_id()[source]
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
get_cover()

called by the MediaServer web should return

  • the filepath where to find the album art file

only needed when we have created for that item an albumArtURI property that does point back to us

get_path()

called by the MediaServer web should return

  • the filepath where to find the media file that this item does refer to
info(message, *args, **kwargs)
log(message, *args, **kwargs)
logCategory = 'backend_item'
msg(message, *args, **kwargs)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
class LolcatsStore(server, *args, **kwargs)[source]

Bases: coherence.backend.BackendStore

implements = ['MediaServer']
rss_url = 'http://feeds.feedburner.com/ICanHasCheezburger?format=xml'
ROOT_ID = 0
get_by_id(id)[source]

called by the CDS or the MediaServer web

id is the id property of our DIDLLite item

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

should return

  • None when no matching item for that id is found,
  • a BackendItem,
  • or a Deferred
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

_update_container(result=None)[source]
update_loop()[source]
update_data()[source]
parse_data(root)[source]
queue_update(error_or_failure)[source]
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
_get_all_items(id)

a helper method to get all items as a response to some XBox 360 UPnP Search action probably never be used as the backend will overwrite the wmc_mapping with more appropriate methods

critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
info(message, *args, **kwargs)
init_completed(*args, **kwargs)

inform Coherence that this backend is ready for announcement this method just accepts any form of arguments as we don’t under which circumstances it is called

log(message, *args, **kwargs)
logCategory = 'backend_store'
msg(message, *args, **kwargs)
release()

if anything needs to be cleaned up upon shutdown of this backend, this is the place for it

warn(message, *args, **kwargs)
warning(message, *args, **kwargs)

coherence.backends.mediadb_storage (module)

coherence.backends.miroguide_storage (module)

class VideoItem(name, description, url, thumbnail_url, store)[source]

Bases: coherence.backend.BackendItem

get_item()[source]

called by the CDS and the MediaServer web should return

  • an UPnP ContentDirectoryServer DIDLLite object
  • or a Deferred
get_path()[source]

called by the MediaServer web should return

  • the filepath where to find the media file that this item does refer to
get_id()[source]
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
get_child_count()

called by the CDS should return

  • the number of its childs - len(childs)
  • or a Deferred
get_children(start=0, end=0)

called by the CDS and the MediaServer web should return

  • a list of its childs[start:end]
  • or a Deferred

if end == 0, the request is for all childs after start - childs[start:]

get_cover()

called by the MediaServer web should return

  • the filepath where to find the album art file

only needed when we have created for that item an albumArtURI property that does point back to us

get_name()

called by the MediaServer web should return

  • the name of the item, it is always expected to be in unicode
info(message, *args, **kwargs)
log(message, *args, **kwargs)
logCategory = 'backend_item'
msg(message, *args, **kwargs)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
class MiroGuideStore(server, **kwargs)[source]

Bases: coherence.backend.AbstractBackendStore

logCategory = 'miroguide_store'
implements = ['MediaServer']
description = ('Miro Guide', 'connects to the MIRO Guide service and exposes the podcasts catalogued by the service. ', None)
options = [{'option': 'name', 'text': 'Server Name:', 'type': 'string', 'default': 'my media', 'help': 'the name under this MediaServer shall show up with on other UPnP clients'}, {'option': 'version', 'text': 'UPnP Version:', 'type': 'int', 'default': 2, 'enum': (2, 1), 'help': 'the highest UPnP version this MediaServer shall support', 'level': 'advance'}, {'option': 'uuid', 'text': 'UUID Identifier:', 'type': 'string', 'help': 'the unique (UPnP) identifier for this MediaServer, usually automatically set', 'level': 'advance'}, {'option': 'language', 'text': 'Language:', 'type': 'string', 'default': 'English'}, {'option': 'refresh', 'text': 'Refresh period', 'type': 'string'}, {'option': 'proxy_mode', 'text': 'Proxy mode:', 'type': 'string', 'enum': ('redirect', 'proxy', 'cache', 'buffered')}, {'option': 'buffer_size', 'text': 'Buffering size:', 'type': 'int'}, {'option': 'cache_directory', 'text': 'Cache directory:', 'type': 'dir', 'group': 'Cache'}, {'option': 'cache_maxsize', 'text': 'Cache max size:', 'type': 'int', 'group': 'Cache'}]
appendCategory(name, category_id, parent)[source]
appendLanguage(name, language_id, parent, sort='name', count=0)[source]
appendChannel(name, channel_id, parent)[source]
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

retrieveChannels(parent, filter, filter_value, per_page=100, page=0, offset=0, count=0, sort='name')[source]
retrieveChannelItems(parent, channel_id)[source]
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
_get_all_items(id)

a helper method to get all items as a response to some XBox 360 UPnP Search action probably never be used as the backend will overwrite the wmc_mapping with more appropriate methods

append_item(item, storage_id=None)
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
get_by_id(id)

called by the CDS or the MediaServer web

id is the id property of our DIDLLite item

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

should return

  • None when no matching item for that id is found,
  • a BackendItem,
  • or a Deferred
get_root_id()
get_root_item()
getnextID()
info(message, *args, **kwargs)
init_completed(*args, **kwargs)

inform Coherence that this backend is ready for announcement this method just accepts any form of arguments as we don’t under which circumstances it is called

len()
log(message, *args, **kwargs)
msg(message, *args, **kwargs)
release()

if anything needs to be cleaned up upon shutdown of this backend, this is the place for it

remove_item(item)
set_root_item(item)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)

coherence.backends.picasa_storage (module)

class PicasaProxy(uri)[source]

Bases: coherence.upnp.core.utils.ReverseProxyUriResource

render(request)[source]

Render a request by forwarding it to the proxied server.

delEntity(name)
entityType = <InterfaceClass twisted.web.resource.IResource>
getChild(path, request)

Create and return a proxy resource with the same proxy configuration as this one, except that its path also contains the segment given by C{path} at the end.

getChildForRequest(request)
getChildWithDefault(path, request)

Retrieve a static or dynamically generated child resource from me.

First checks if a resource was added manually by putChild, and then call getChild to check for dynamic resources. Only override if you want to affect behaviour of all child lookups, rather than just dynamic ones.

This will check to see if I have a pre-registered child resource of the given name, and call getChild if I do not.

@see: L{IResource.getChildWithDefault}

getDynamicEntity(name, request)
getStaticEntity(name)
isLeaf = 0
listDynamicEntities(request=None)
listDynamicNames()
listEntities()
listNames()
listStaticEntities()
listStaticNames()
proxyClientFactoryClass

alias of coherence.upnp.core.utils.ProxyClientFactory

putChild(path, child)

Register a static child.

You almost certainly don’t want ‘/’ in your path. If you intended to have the root of a folder, e.g. /foo/, you want path to be ‘’.

@see: L{IResource.putChild}

reallyPutEntity(name, entity)
render_HEAD(request)

Default handling of HEAD method.

I just return self.render_GET(request). When method is HEAD, the framework will handle this correctly.

resetTarget(host, port, path, qs='')
resetUri(uri)
server = None
uri = None
class PicasaPhotoItem(photo)[source]

Bases: coherence.backend.BackendItem

replace_by(item)[source]
get_item()[source]

called by the CDS and the MediaServer web should return

  • an UPnP ContentDirectoryServer DIDLLite object
  • or a Deferred
get_path()[source]

called by the MediaServer web should return

  • the filepath where to find the media file that this item does refer to
get_id()[source]
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
get_child_count()

called by the CDS should return

  • the number of its childs - len(childs)
  • or a Deferred
get_children(start=0, end=0)

called by the CDS and the MediaServer web should return

  • a list of its childs[start:end]
  • or a Deferred

if end == 0, the request is for all childs after start - childs[start:]

get_cover()

called by the MediaServer web should return

  • the filepath where to find the album art file

only needed when we have created for that item an albumArtURI property that does point back to us

get_name()

called by the MediaServer web should return

  • the name of the item, it is always expected to be in unicode
info(message, *args, **kwargs)
log(message, *args, **kwargs)
logCategory = 'backend_item'
msg(message, *args, **kwargs)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
class PicasaStore(server, **kwargs)[source]

Bases: coherence.backend.AbstractBackendStore

logCategory = 'picasa_store'
implements = ['MediaServer']
description = ('Picasa Web Albums', 'connects to the Picasa Web Albums service and exposes the featured photos and albums for a given user.', None)
options = [{'option': 'name', 'text': 'Server Name:', 'type': 'string', 'default': 'my media', 'help': 'the name under this MediaServer shall show up with on other UPnP clients'}, {'option': 'version', 'text': 'UPnP Version:', 'type': 'int', 'default': 2, 'enum': (2, 1), 'help': 'the highest UPnP version this MediaServer shall support', 'level': 'advance'}, {'option': 'uuid', 'text': 'UUID Identifier:', 'type': 'string', 'help': 'the unique (UPnP) identifier for this MediaServer, usually automatically set', 'level': 'advance'}, {'option': 'refresh', 'text': 'Refresh period', 'type': 'string'}, {'option': 'login', 'text': 'User ID:', 'type': 'string', 'group': 'User Account'}, {'option': 'password', 'text': 'Password:', 'type': 'string', 'group': 'User Account'}]
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

retrieveAlbums(parent=None)[source]
retrieveFeedPhotos(parent=None, feed_uri='')[source]
retrieveAlbumPhotos(parent=None, album_id='')[source]
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
_get_all_items(id)

a helper method to get all items as a response to some XBox 360 UPnP Search action probably never be used as the backend will overwrite the wmc_mapping with more appropriate methods

append_item(item, storage_id=None)
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
get_by_id(id)

called by the CDS or the MediaServer web

id is the id property of our DIDLLite item

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

should return

  • None when no matching item for that id is found,
  • a BackendItem,
  • or a Deferred
get_root_id()
get_root_item()
getnextID()
info(message, *args, **kwargs)
init_completed(*args, **kwargs)

inform Coherence that this backend is ready for announcement this method just accepts any form of arguments as we don’t under which circumstances it is called

len()
log(message, *args, **kwargs)
msg(message, *args, **kwargs)
release()

if anything needs to be cleaned up upon shutdown of this backend, this is the place for it

remove_item(item)
retrieveFeaturedPhotos(parent=None)[source]
set_root_item(item)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)

coherence.backends.playlist_storage (module)

class PlaylistItem(title, stream_url, mimetype, **kwargs)[source]

Bases: coherence.backend.BackendItem

logCategory = 'playlist_store'
get_id()[source]
get_item()[source]

called by the CDS and the MediaServer web should return

  • an UPnP ContentDirectoryServer DIDLLite object
  • or a Deferred
get_url()[source]
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
get_child_count()

called by the CDS should return

  • the number of its childs - len(childs)
  • or a Deferred
get_children(start=0, end=0)

called by the CDS and the MediaServer web should return

  • a list of its childs[start:end]
  • or a Deferred

if end == 0, the request is for all childs after start - childs[start:]

get_cover()

called by the MediaServer web should return

  • the filepath where to find the album art file

only needed when we have created for that item an albumArtURI property that does point back to us

get_name()

called by the MediaServer web should return

  • the name of the item, it is always expected to be in unicode
get_path()

called by the MediaServer web should return

  • the filepath where to find the media file that this item does refer to
info(message, *args, **kwargs)
log(message, *args, **kwargs)
msg(message, *args, **kwargs)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
class PlaylistStore(server, **kwargs)[source]

Bases: coherence.backend.AbstractBackendStore

logCategory = 'playlist_store'
implements = ['MediaServer']
wmc_mapping = {'16': 1000}
description = ('Playlist', 'exposes the list of video/audio streams from a m3u playlist (e.g. web TV listings published by french ISPs such as Free, SFR...).', None)
options = [{'option': 'name', 'text': 'Server Name:', 'type': 'string', 'default': 'my media', 'help': 'the name under this MediaServer shall show up with on other UPnP clients'}, {'option': 'version', 'text': 'UPnP Version:', 'type': 'int', 'default': 2, 'enum': (2, 1), 'help': 'the highest UPnP version this MediaServer shall support', 'level': 'advance'}, {'option': 'uuid', 'text': 'UUID Identifier:', 'type': 'string', 'help': 'the unique (UPnP) identifier for this MediaServer, usually automatically set', 'level': 'advance'}, {'option': 'playlist_url', 'text': 'Playlist file URL:', 'type': 'string', 'help': 'URL to the playlist file (M3U).'}]
playlist_url = None
append(obj, parent)[source]
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

COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
_get_all_items(id)

a helper method to get all items as a response to some XBox 360 UPnP Search action probably never be used as the backend will overwrite the wmc_mapping with more appropriate methods

append_item(item, storage_id=None)
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
get_by_id(id)

called by the CDS or the MediaServer web

id is the id property of our DIDLLite item

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

should return

  • None when no matching item for that id is found,
  • a BackendItem,
  • or a Deferred
get_root_id()
get_root_item()
getnextID()
info(message, *args, **kwargs)
init_completed(*args, **kwargs)

inform Coherence that this backend is ready for announcement this method just accepts any form of arguments as we don’t under which circumstances it is called

len()
log(message, *args, **kwargs)
msg(message, *args, **kwargs)
release()

if anything needs to be cleaned up upon shutdown of this backend, this is the place for it

remove_item(item)
retrievePlaylistItems(url, parent_item)[source]
set_root_item(item)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)

coherence.backends.radiotime_storage (module)

class RadiotimeAudioItem(outline)[source]

Bases: coherence.backend.BackendItem

logCategory = 'radiotime'
replace_by(item)[source]
get_item()[source]

called by the CDS and the MediaServer web should return

  • an UPnP ContentDirectoryServer DIDLLite object
  • or a Deferred
get_path()[source]

called by the MediaServer web should return

  • the filepath where to find the media file that this item does refer to
get_id()[source]
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
get_child_count()

called by the CDS should return

  • the number of its childs - len(childs)
  • or a Deferred
get_children(start=0, end=0)

called by the CDS and the MediaServer web should return

  • a list of its childs[start:end]
  • or a Deferred

if end == 0, the request is for all childs after start - childs[start:]

get_cover()

called by the MediaServer web should return

  • the filepath where to find the album art file

only needed when we have created for that item an albumArtURI property that does point back to us

get_name()

called by the MediaServer web should return

  • the name of the item, it is always expected to be in unicode
info(message, *args, **kwargs)
log(message, *args, **kwargs)
msg(message, *args, **kwargs)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
class RadiotimeStore(server, **kwargs)[source]

Bases: coherence.backend.AbstractBackendStore

logCategory = 'radiotime'
implements = ['MediaServer']
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

retrieveItemsForOPML(parent, url)[source]
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
_get_all_items(id)

a helper method to get all items as a response to some XBox 360 UPnP Search action probably never be used as the backend will overwrite the wmc_mapping with more appropriate methods

append_item(item, storage_id=None)
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
get_by_id(id)

called by the CDS or the MediaServer web

id is the id property of our DIDLLite item

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

should return

  • None when no matching item for that id is found,
  • a BackendItem,
  • or a Deferred
get_root_id()
get_root_item()
getnextID()
info(message, *args, **kwargs)
init_completed(*args, **kwargs)

inform Coherence that this backend is ready for announcement this method just accepts any form of arguments as we don’t under which circumstances it is called

len()
log(message, *args, **kwargs)
msg(message, *args, **kwargs)
release()

if anything needs to be cleaned up upon shutdown of this backend, this is the place for it

remove_item(item)
set_root_item(item)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)

coherence.backends.swr3_storage (module)

class Item(parent, id, title, url)[source]

Bases: coherence.backend.BackendItem

get_item()[source]

called by the CDS and the MediaServer web should return

  • an UPnP ContentDirectoryServer DIDLLite object
  • or a Deferred
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
get_child_count()

called by the CDS should return

  • the number of its childs - len(childs)
  • or a Deferred
get_children(start=0, end=0)

called by the CDS and the MediaServer web should return

  • a list of its childs[start:end]
  • or a Deferred

if end == 0, the request is for all childs after start - childs[start:]

get_cover()

called by the MediaServer web should return

  • the filepath where to find the album art file

only needed when we have created for that item an albumArtURI property that does point back to us

get_name()

called by the MediaServer web should return

  • the name of the item, it is always expected to be in unicode
get_path()

called by the MediaServer web should return

  • the filepath where to find the media file that this item does refer to
info(message, *args, **kwargs)
log(message, *args, **kwargs)
logCategory = 'backend_item'
msg(message, *args, **kwargs)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
class Container(id, store, parent_id, title)[source]

Bases: coherence.backend.BackendItem

add_child(child)[source]
get_children(start=0, end=0)[source]

called by the CDS and the MediaServer web should return

  • a list of its childs[start:end]
  • or a Deferred

if end == 0, the request is for all childs after start - childs[start:]

get_child_count()[source]

called by the CDS should return

  • the number of its childs - len(childs)
  • or a Deferred
get_path()[source]

called by the MediaServer web should return

  • the filepath where to find the media file that this item does refer to
get_item()[source]

called by the CDS and the MediaServer web should return

  • an UPnP ContentDirectoryServer DIDLLite object
  • or a Deferred
get_name()[source]

called by the MediaServer web should return

  • the name of the item, it is always expected to be in unicode
get_id()[source]
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
get_cover()

called by the MediaServer web should return

  • the filepath where to find the album art file

only needed when we have created for that item an albumArtURI property that does point back to us

info(message, *args, **kwargs)
log(message, *args, **kwargs)
logCategory = 'backend_item'
msg(message, *args, **kwargs)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
class SWR3Store(server, *args, **kwargs)[source]

Bases: coherence.backend.BackendStore, coherence.backend.BackendRssMixin

implements = ['MediaServer']
parse_opml()[source]
get_next_id()[source]
get_by_id(id)[source]

called by the CDS or the MediaServer web

id is the id property of our DIDLLite item

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

should return

  • None when no matching item for that id is found,
  • a BackendItem,
  • or a Deferred
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

parse_data(xml_data, container)[source]

extract media info and create BackendItems

COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
_get_all_items(id)

a helper method to get all items as a response to some XBox 360 UPnP Search action probably never be used as the backend will overwrite the wmc_mapping with more appropriate methods

critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
info(message, *args, **kwargs)
init_completed(*args, **kwargs)

inform Coherence that this backend is ready for announcement this method just accepts any form of arguments as we don’t under which circumstances it is called

log(message, *args, **kwargs)
logCategory = 'backend_store'
msg(message, *args, **kwargs)
queue_update(error_or_failure, rss_url, container)
release()

if anything needs to be cleaned up upon shutdown of this backend, this is the place for it

update_data(rss_url, container=None)

creates a deferred chain to retrieve the rdf file, parse and extract the metadata and reschedule itself

warn(message, *args, **kwargs)
warning(message, *args, **kwargs)

coherence.backends.ted_storage (module)

Another simple rss based Media Server, this time for TED.com content

class TedTalk(parent_id, id, title=None, url=None, duration=None, size=None)[source]

Bases: coherence.backend.BackendItem

COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
get_child_count()

called by the CDS should return

  • the number of its childs - len(childs)
  • or a Deferred
get_children(start=0, end=0)

called by the CDS and the MediaServer web should return

  • a list of its childs[start:end]
  • or a Deferred

if end == 0, the request is for all childs after start - childs[start:]

get_cover()

called by the MediaServer web should return

  • the filepath where to find the album art file

only needed when we have created for that item an albumArtURI property that does point back to us

get_item()

called by the CDS and the MediaServer web should return

  • an UPnP ContentDirectoryServer DIDLLite object
  • or a Deferred
get_name()

called by the MediaServer web should return

  • the name of the item, it is always expected to be in unicode
get_path()

called by the MediaServer web should return

  • the filepath where to find the media file that this item does refer to
info(message, *args, **kwargs)
log(message, *args, **kwargs)
logCategory = 'backend_item'
msg(message, *args, **kwargs)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
class TEDStore(server, *args, **kwargs)[source]

Bases: coherence.backends.lolcats_storage.LolcatsStore

implements = ['MediaServer']
rss_url = 'http://feeds.feedburner.com/tedtalks_video?format=xml'
ROOT_ID = 0
get_by_id(id)[source]

called by the CDS or the MediaServer web

id is the id property of our DIDLLite item

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

should return

  • None when no matching item for that id is found,
  • a BackendItem,
  • or a Deferred
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

parse_data(xml_data)[source]
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
_get_all_items(id)

a helper method to get all items as a response to some XBox 360 UPnP Search action probably never be used as the backend will overwrite the wmc_mapping with more appropriate methods

_update_container(result=None)
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
info(message, *args, **kwargs)
init_completed(*args, **kwargs)

inform Coherence that this backend is ready for announcement this method just accepts any form of arguments as we don’t under which circumstances it is called

log(message, *args, **kwargs)
logCategory = 'backend_store'
msg(message, *args, **kwargs)
queue_update(error_or_failure)
release()

if anything needs to be cleaned up upon shutdown of this backend, this is the place for it

update_data()
update_loop()
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)

coherence.backends.test_storage (module)

A MediaServer backend to test Items

Item information can be passed on the commandline or in the config as an XMl fragment

coherence –plugin=backend:TestStore,name:Test, item:<item><location>audio.mp3</location> <mimetype>audio/mpeg</mimetype></item>, item:<item><location>audio.ogg</location> <mimetype>audio/ogg</mimetype></item>

coherence –plugin=”backend:TestStore,name:Test, item:<item><type>gstreamer</type> <pipeline>v4l2src num-buffers=1 ! video/x-raw-yuv,width=640, height=480 ! ffmpegcolorspace ! jpegenc name=enc</pipeline> <mimetype>image/jpeg></mimetype></item>”

“video/x-raw-yuv,width=640,height=480” won’t work here as it is a delimiter
for the plugin string, so if you need things like that in the pipeline,
you need to use a config file

coherence –plugin=”backend:TestStore,name:Test, item:<item><type>process</type> <command>man date</command> <mimetype>text/html</mimetype></item>”

The XML fragment has these elements:

‘type’: file - the item is some file-system object (default)
url - an item pointing to an object off-site gstreamer - the item is actually a GStreamer pipeline process - the items content is created by an external process

‘location’: the filesystem path or an url (mandatory) ‘mimetype’: the mimetype of the item (mandatory) ‘extension’: an optional extension to append to the

url created for the DIDLLite resource data

‘title’: the ‘title’ this item should have (optional) ‘upnp_class’: the DIDLLite class the item shall have,

object.item will be taken as default
‘fourth_field’: value for the 4th field of the protocolInfo phalanx,
default is ‘*’
‘pipeline’: a GStreamer pipeline that has to end with a bin named ‘enc’,
some pipelines do only work properly when we have a glib mainloop running, so coherence needs to be started with -o glib:yes
‘command’: the commandline for an external script to run, its output will
be returned as the items content

In the config file the definition of this backend could look like this:

<plugin active=”yes”>

<backend>TestStore</backend> <name>Test</name> <item>

<location>/tmp/audio.mp3</location> <mimetype>audio/mpeg</mimetype>

</item> <item>

<location>/tmp/audio.ogg</location> <mimetype>audio/ogg</mimetype>

</item>

</plugin>

class ExternalProcessProtocol(caller)[source]

Bases: twisted.internet.protocol.ProcessProtocol

connectionMade()[source]

Called when a connection is made.

This may be considered the initializer of the protocol, because it is called when the connection is completed. For clients, this is called once the connection to the server has been established; for servers, this is called after an accept() call stops blocking and a socket has been received. If you need to send any greeting or initial message, do it here.

outReceived(data)[source]

Some data was received from stdout.

errReceived(data)[source]

Some data was received from stderr.

inConnectionLost()[source]

This will be called when stdin is closed.

outConnectionLost()[source]

This will be called when stdout is closed.

errConnectionLost()[source]

This will be called when stderr is closed.

processEnded(status_object)[source]

Called when the child process exits and all file descriptors associated with it have been closed.

@type reason: L{twisted.python.failure.Failure}

childConnectionLost(childFD)
childDataReceived(childFD, data)
connected = 0
makeConnection(transport)

Make a connection to a transport and a server.

This sets the ‘transport’ attribute of this Protocol, and calls the connectionMade() callback.

processExited(reason)

This will be called when the subprocess exits.

@type reason: L{twisted.python.failure.Failure}

transport = None
class ExternalProcessPipeline(pipeline, mimetype)[source]

Bases: twisted.web.resource.Resource, coherence.log.LogAble

logCategory = 'externalprocess'
addSlash = True
render(request)[source]

Render a given resource. See L{IResource}’s render method.

I delegate to methods of self with the form ‘render_METHOD’ where METHOD is the HTTP that was used to make the request. Examples: render_GET, render_HEAD, render_POST, and so on. Generally you should implement those methods instead of overriding this one.

render_METHOD methods are expected to return a byte string which will be the rendered page, unless the return value is C{server.NOT_DONE_YET}, in which case it is this class’s responsibility to write the results using C{request.write(data)} and then call C{request.finish()}.

Old code that overrides render() directly is likewise expected to return a byte string or NOT_DONE_YET.

@see: L{IResource.render}

COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
delEntity(name)
entityType = <InterfaceClass twisted.web.resource.IResource>
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
getChild(path, request)

Retrieve a ‘child’ resource from me.

Implement this to create dynamic resource generation – resources which are always available may be registered with self.putChild().

This will not be called if the class-level variable ‘isLeaf’ is set in your subclass; instead, the ‘postpath’ attribute of the request will be left as a list of the remaining path elements.

For example, the URL /foo/bar/baz will normally be:

| site.resource.getChild('foo').getChild('bar').getChild('baz').

However, if the resource returned by ‘bar’ has isLeaf set to true, then the getChild call will never be made on it.

Parameters and return value have the same meaning and requirements as those defined by L{IResource.getChildWithDefault}.

getChildForRequest(request)
getChildWithDefault(path, request)

Retrieve a static or dynamically generated child resource from me.

First checks if a resource was added manually by putChild, and then call getChild to check for dynamic resources. Only override if you want to affect behaviour of all child lookups, rather than just dynamic ones.

This will check to see if I have a pre-registered child resource of the given name, and call getChild if I do not.

@see: L{IResource.getChildWithDefault}

getDynamicEntity(name, request)
getStaticEntity(name)
info(message, *args, **kwargs)
isLeaf = 0
listDynamicEntities(request=None)
listDynamicNames()
listEntities()
listNames()
listStaticEntities()
listStaticNames()
log(message, *args, **kwargs)
msg(message, *args, **kwargs)
putChild(path, child)

Register a static child.

You almost certainly don’t want ‘/’ in your path. If you intended to have the root of a folder, e.g. /foo/, you want path to be ‘’.

@see: L{IResource.putChild}

reallyPutEntity(name, entity)
render_HEAD(request)

Default handling of HEAD method.

I just return self.render_GET(request). When method is HEAD, the framework will handle this correctly.

server = None
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
class ExternalProcessProducer(pipeline, request)[source]

Bases: coherence.log.LogAble

logCategory = 'externalprocess'
addSlash = True
write_data(data)[source]
resumeProducing()[source]
pauseProducing()[source]
stopProducing()[source]
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
info(message, *args, **kwargs)
log(message, *args, **kwargs)
msg(message, *args, **kwargs)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
class Item(parent, id, title, location, url)[source]

Bases: coherence.backend.BackendItem

get_item()[source]

called by the CDS and the MediaServer web should return

  • an UPnP ContentDirectoryServer DIDLLite object
  • or a Deferred
get_name()[source]

called by the MediaServer web should return

  • the name of the item, it is always expected to be in unicode
get_path()[source]

called by the MediaServer web should return

  • the filepath where to find the media file that this item does refer to
get_size()[source]
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
get_child_count()

called by the CDS should return

  • the number of its childs - len(childs)
  • or a Deferred
get_children(start=0, end=0)

called by the CDS and the MediaServer web should return

  • a list of its childs[start:end]
  • or a Deferred

if end == 0, the request is for all childs after start - childs[start:]

get_cover()

called by the MediaServer web should return

  • the filepath where to find the album art file

only needed when we have created for that item an albumArtURI property that does point back to us

info(message, *args, **kwargs)
log(message, *args, **kwargs)
logCategory = 'backend_item'
msg(message, *args, **kwargs)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
class ResourceItem(parent, id, title, location, url)[source]

Bases: coherence.backends.test_storage.Item

get_name()[source]

called by the MediaServer web should return

  • the name of the item, it is always expected to be in unicode
get_path()[source]

called by the MediaServer web should return

  • the filepath where to find the media file that this item does refer to
get_size()[source]
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
get_child_count()

called by the CDS should return

  • the number of its childs - len(childs)
  • or a Deferred
get_children(start=0, end=0)

called by the CDS and the MediaServer web should return

  • a list of its childs[start:end]
  • or a Deferred

if end == 0, the request is for all childs after start - childs[start:]

get_cover()

called by the MediaServer web should return

  • the filepath where to find the album art file

only needed when we have created for that item an albumArtURI property that does point back to us

get_item()

called by the CDS and the MediaServer web should return

  • an UPnP ContentDirectoryServer DIDLLite object
  • or a Deferred
info(message, *args, **kwargs)
log(message, *args, **kwargs)
logCategory = 'backend_item'
msg(message, *args, **kwargs)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
class Container(id, store, parent_id, title)[source]

Bases: coherence.backend.BackendItem

add_child(child)[source]
get_children(start=0, end=0)[source]

called by the CDS and the MediaServer web should return

  • a list of its childs[start:end]
  • or a Deferred

if end == 0, the request is for all childs after start - childs[start:]

get_child_count()[source]

called by the CDS should return

  • the number of its childs - len(childs)
  • or a Deferred
get_path()[source]

called by the MediaServer web should return

  • the filepath where to find the media file that this item does refer to
get_item()[source]

called by the CDS and the MediaServer web should return

  • an UPnP ContentDirectoryServer DIDLLite object
  • or a Deferred
get_name()[source]

called by the MediaServer web should return

  • the name of the item, it is always expected to be in unicode
get_id()[source]
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
get_cover()

called by the MediaServer web should return

  • the filepath where to find the album art file

only needed when we have created for that item an albumArtURI property that does point back to us

info(message, *args, **kwargs)
log(message, *args, **kwargs)
logCategory = 'backend_item'
msg(message, *args, **kwargs)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
class TestStore(server, *args, **kwargs)[source]

Bases: coherence.backend.BackendStore

implements = ['MediaServer']
get_upnp_class(name)[source]
get_next_id()[source]
get_by_id(id)[source]

called by the CDS or the MediaServer web

id is the id property of our DIDLLite item

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

should return

  • None when no matching item for that id is found,
  • a BackendItem,
  • or a Deferred
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
_get_all_items(id)

a helper method to get all items as a response to some XBox 360 UPnP Search action probably never be used as the backend will overwrite the wmc_mapping with more appropriate methods

critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
info(message, *args, **kwargs)
init_completed(*args, **kwargs)

inform Coherence that this backend is ready for announcement this method just accepts any form of arguments as we don’t under which circumstances it is called

log(message, *args, **kwargs)
logCategory = 'backend_store'
msg(message, *args, **kwargs)
release()

if anything needs to be cleaned up upon shutdown of this backend, this is the place for it

upnp_init()

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

warn(message, *args, **kwargs)
warning(message, *args, **kwargs)

coherence.backends.tracker_storage (module)

class Container(id, parent_id, name, store=None, children_callback=None, container_class=<class 'coherence.upnp.core.DIDLLite.Container'>)[source]

Bases: coherence.backend.BackendItem

logCategory = 'tracker_store'
add_child(child)[source]
get_children(start=0, end=0)[source]

called by the CDS and the MediaServer web should return

  • a list of its childs[start:end]
  • or a Deferred

if end == 0, the request is for all childs after start - childs[start:]

get_child_count()[source]

called by the CDS should return

  • the number of its childs - len(childs)
  • or a Deferred
get_item()[source]

called by the CDS and the MediaServer web should return

  • an UPnP ContentDirectoryServer DIDLLite object
  • or a Deferred
get_name()[source]

called by the MediaServer web should return

  • the name of the item, it is always expected to be in unicode
get_id()[source]
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
get_cover()

called by the MediaServer web should return

  • the filepath where to find the album art file

only needed when we have created for that item an albumArtURI property that does point back to us

get_path()[source]

called by the MediaServer web should return

  • the filepath where to find the media file that this item does refer to
info(message, *args, **kwargs)
log(message, *args, **kwargs)
msg(message, *args, **kwargs)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
class Artist(store, id, name)[source]

Bases: coherence.backend.BackendItem

logCategory = 'tracker_store'
add_child(child)[source]
sort_children()[source]
get_artist_all_tracks(start=0, request_count=0)[source]
get_children(start=0, end=0)[source]

called by the CDS and the MediaServer web should return

  • a list of its childs[start:end]
  • or a Deferred

if end == 0, the request is for all childs after start - childs[start:]

get_child_count()[source]

called by the CDS should return

  • the number of its childs - len(childs)
  • or a Deferred
get_item(parent_id=102)[source]

called by the CDS and the MediaServer web should return

  • an UPnP ContentDirectoryServer DIDLLite object
  • or a Deferred
get_id()[source]
get_name()[source]

called by the MediaServer web should return

  • the name of the item, it is always expected to be in unicode
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
get_cover()

called by the MediaServer web should return

  • the filepath where to find the album art file

only needed when we have created for that item an albumArtURI property that does point back to us

get_path()

called by the MediaServer web should return

  • the filepath where to find the media file that this item does refer to
info(message, *args, **kwargs)
log(message, *args, **kwargs)
msg(message, *args, **kwargs)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
class Album(store, id, title, artist)[source]

Bases: coherence.backend.BackendItem

logCategory = 'tracker_store'
add_child(child)[source]
get_children(start=0, end=0)[source]

called by the CDS and the MediaServer web should return

  • a list of its childs[start:end]
  • or a Deferred

if end == 0, the request is for all childs after start - childs[start:]

get_child_count()[source]

called by the CDS should return

  • the number of its childs - len(childs)
  • or a Deferred
get_item(parent_id=103)[source]

called by the CDS and the MediaServer web should return

  • an UPnP ContentDirectoryServer DIDLLite object
  • or a Deferred
get_id()[source]
get_name()[source]

called by the MediaServer web should return

  • the name of the item, it is always expected to be in unicode
get_cover()[source]

called by the MediaServer web should return

  • the filepath where to find the album art file

only needed when we have created for that item an albumArtURI property that does point back to us

COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
get_path()

called by the MediaServer web should return

  • the filepath where to find the media file that this item does refer to
info(message, *args, **kwargs)
log(message, *args, **kwargs)
msg(message, *args, **kwargs)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
class Track(store, id, parent_id, file, title, artist, album, genre, duration, track_number, size, mimetype)[source]

Bases: coherence.backend.BackendItem

logCategory = 'tracker_store'
get_children(start=0, end=0)[source]

called by the CDS and the MediaServer web should return

  • a list of its childs[start:end]
  • or a Deferred

if end == 0, the request is for all childs after start - childs[start:]

get_child_count()[source]

called by the CDS should return

  • the number of its childs - len(childs)
  • or a Deferred
get_item(parent_id=None)[source]

called by the CDS and the MediaServer web should return

  • an UPnP ContentDirectoryServer DIDLLite object
  • or a Deferred
get_id()[source]
get_name()[source]

called by the MediaServer web should return

  • the name of the item, it is always expected to be in unicode
get_url()[source]
get_path()[source]

called by the MediaServer web should return

  • the filepath where to find the media file that this item does refer to
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
get_cover()

called by the MediaServer web should return

  • the filepath where to find the album art file

only needed when we have created for that item an albumArtURI property that does point back to us

info(message, *args, **kwargs)
log(message, *args, **kwargs)
msg(message, *args, **kwargs)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
class Video(store, id, parent_id, file, title, duration, size, mimetype)[source]

Bases: coherence.backend.BackendItem

logCategory = 'tracker_store'
get_children(start=0, end=0)[source]

called by the CDS and the MediaServer web should return

  • a list of its childs[start:end]
  • or a Deferred

if end == 0, the request is for all childs after start - childs[start:]

get_child_count()[source]

called by the CDS should return

  • the number of its childs - len(childs)
  • or a Deferred
get_item(parent_id=None)[source]

called by the CDS and the MediaServer web should return

  • an UPnP ContentDirectoryServer DIDLLite object
  • or a Deferred
get_id()[source]
get_name()[source]

called by the MediaServer web should return

  • the name of the item, it is always expected to be in unicode
get_url()[source]
get_path()[source]

called by the MediaServer web should return

  • the filepath where to find the media file that this item does refer to
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
get_cover()

called by the MediaServer web should return

  • the filepath where to find the album art file

only needed when we have created for that item an albumArtURI property that does point back to us

info(message, *args, **kwargs)
log(message, *args, **kwargs)
msg(message, *args, **kwargs)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
class Image(store, id, parent_id, file, title, album, date, width, height, size, mimetype)[source]

Bases: coherence.backend.BackendItem

logCategory = 'tracker_store'
get_children(start=0, end=0)[source]

called by the CDS and the MediaServer web should return

  • a list of its childs[start:end]
  • or a Deferred

if end == 0, the request is for all childs after start - childs[start:]

get_child_count()[source]

called by the CDS should return

  • the number of its childs - len(childs)
  • or a Deferred
get_item(parent_id=None)[source]

called by the CDS and the MediaServer web should return

  • an UPnP ContentDirectoryServer DIDLLite object
  • or a Deferred
get_id()[source]
get_name()[source]

called by the MediaServer web should return

  • the name of the item, it is always expected to be in unicode
get_url()[source]
get_path()[source]

called by the MediaServer web should return

  • the filepath where to find the media file that this item does refer to
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
get_cover()

called by the MediaServer web should return

  • the filepath where to find the album art file

only needed when we have created for that item an albumArtURI property that does point back to us

info(message, *args, **kwargs)
log(message, *args, **kwargs)
msg(message, *args, **kwargs)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
class TrackerStore(server, **kwargs)[source]

Bases: coherence.backend.BackendStore

this is a backend to Meta Tracker http://www.gnome.org/projects/tracker/index.html

implements = ['MediaServer']
logCategory = 'tracker_store'
get_by_id(id)[source]

called by the CDS or the MediaServer web

id is the id property of our DIDLLite item

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

should return

  • None when no matching item for that id is found,
  • a BackendItem,
  • or a Deferred
get_videos()[source]
get_images()[source]
get_tracks()[source]
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
_get_all_items(id)

a helper method to get all items as a response to some XBox 360 UPnP Search action probably never be used as the backend will overwrite the wmc_mapping with more appropriate methods

critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
info(message, *args, **kwargs)
init_completed(*args, **kwargs)

inform Coherence that this backend is ready for announcement this method just accepts any form of arguments as we don’t under which circumstances it is called

log(message, *args, **kwargs)
msg(message, *args, **kwargs)
release()

if anything needs to be cleaned up upon shutdown of this backend, this is the place for it

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

warn(message, *args, **kwargs)
warning(message, *args, **kwargs)

coherence.backends.twitch_storage (module)

A backend to access twitch.tv streams.

To enable personalized features (e.g. ‘Following’ streams), add ‘access_token’ key into your config file.

  1. To get access token copy and paste the following into your browser:
https://api.twitch.tv/kraken/oauth2/authorize?response_type=token& client_id=37684tuwyxmogmtduz6lz0jdtf0acob& redirect_uri=http://localhost&scope=user_read

2. After authorization you will be redirected to http://localhost with access token in fragment part, e.g.

http://localhost/#access_token=<YOUR_ACCESS_TOKEN_IS_HERE>&scope=user_read
  1. Copy the token and paste in TwitchStore section of your config file:
access_token = <YOUR_ACCESS_TOKEN (step 2)>
class LiveStreamerProxyResource(url, stream_id, content_type='video/mpeg')[source]

Bases: twisted.web.resource.Resource, coherence.log.LogAble

logCategory = 'twitch_store'
render_GET(request)[source]
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
delEntity(name)
entityType = <InterfaceClass twisted.web.resource.IResource>
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
getChild(path, request)

Retrieve a ‘child’ resource from me.

Implement this to create dynamic resource generation – resources which are always available may be registered with self.putChild().

This will not be called if the class-level variable ‘isLeaf’ is set in your subclass; instead, the ‘postpath’ attribute of the request will be left as a list of the remaining path elements.

For example, the URL /foo/bar/baz will normally be:

| site.resource.getChild('foo').getChild('bar').getChild('baz').

However, if the resource returned by ‘bar’ has isLeaf set to true, then the getChild call will never be made on it.

Parameters and return value have the same meaning and requirements as those defined by L{IResource.getChildWithDefault}.

getChildForRequest(request)
getChildWithDefault(path, request)

Retrieve a static or dynamically generated child resource from me.

First checks if a resource was added manually by putChild, and then call getChild to check for dynamic resources. Only override if you want to affect behaviour of all child lookups, rather than just dynamic ones.

This will check to see if I have a pre-registered child resource of the given name, and call getChild if I do not.

@see: L{IResource.getChildWithDefault}

getDynamicEntity(name, request)
getStaticEntity(name)
info(message, *args, **kwargs)
isLeaf = 0
listDynamicEntities(request=None)
listDynamicNames()
listEntities()
listNames()
listStaticEntities()
listStaticNames()
log(message, *args, **kwargs)
msg(message, *args, **kwargs)
putChild(path, child)

Register a static child.

You almost certainly don’t want ‘/’ in your path. If you intended to have the root of a folder, e.g. /foo/, you want path to be ‘’.

@see: L{IResource.putChild}

reallyPutEntity(name, entity)
render(request)

Render a given resource. See L{IResource}’s render method.

I delegate to methods of self with the form ‘render_METHOD’ where METHOD is the HTTP that was used to make the request. Examples: render_GET, render_HEAD, render_POST, and so on. Generally you should implement those methods instead of overriding this one.

render_METHOD methods are expected to return a byte string which will be the rendered page, unless the return value is C{server.NOT_DONE_YET}, in which case it is this class’s responsibility to write the results using C{request.write(data)} and then call C{request.finish()}.

Old code that overrides render() directly is likewise expected to return a byte string or NOT_DONE_YET.

@see: L{IResource.render}

render_HEAD(request)

Default handling of HEAD method.

I just return self.render_GET(request). When method is HEAD, the framework will handle this correctly.

server = None
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
class TwitchLazyContainer(parent, title, limit=None, **kwargs)[source]

Bases: coherence.backend.LazyContainer

logCategory = 'twitch_store'
result_handler(result, **kwargs)[source]
_retrieve_children(parent=None, **kwargs)[source]
_got_page(result)[source]
_got_error(error)[source]
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
add_child(child, external_id=None, update=True)
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
end_children_retrieval_campaign(success=True)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
get_child_count()

called by the CDS should return

  • the number of its childs - len(childs)
  • or a Deferred
get_children(start=0, request_count=0)

called by the CDS and the MediaServer web should return

  • a list of its childs[start:end]
  • or a Deferred

if end == 0, the request is for all childs after start - childs[start:]

get_cover()

called by the MediaServer web should return

  • the filepath where to find the album art file

only needed when we have created for that item an albumArtURI property that does point back to us

get_id()
get_item()

called by the CDS and the MediaServer web should return

  • an UPnP ContentDirectoryServer DIDLLite object
  • or a Deferred
get_name()

called by the MediaServer web should return

  • the name of the item, it is always expected to be in unicode
get_path()

called by the MediaServer web should return

  • the filepath where to find the media file that this item does refer to
get_update_id()
info(message, *args, **kwargs)
log(message, *args, **kwargs)
msg(message, *args, **kwargs)
register_child(child, external_id=None)
remove_child(child, external_id=None, update=True)
replace_by(item)
retrieve_all_children(start=0, request_count=0)
retrieve_children(start=0, page=0)
start_children_retrieval_campaign()
update_children(new_children, old_children)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
class GamesContainer(parent, title='Games', description=None, limit=None, children_limit=None, **kwargs)[source]

Bases: coherence.backends.twitch_storage.TwitchLazyContainer

result_handler(result, **kwargs)[source]
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
_got_error(error)
_got_page(result)
_retrieve_children(parent=None, **kwargs)
add_child(child, external_id=None, update=True)
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
end_children_retrieval_campaign(success=True)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
get_child_count()

called by the CDS should return

  • the number of its childs - len(childs)
  • or a Deferred
get_children(start=0, request_count=0)

called by the CDS and the MediaServer web should return

  • a list of its childs[start:end]
  • or a Deferred

if end == 0, the request is for all childs after start - childs[start:]

get_cover()

called by the MediaServer web should return

  • the filepath where to find the album art file

only needed when we have created for that item an albumArtURI property that does point back to us

get_id()
get_item()

called by the CDS and the MediaServer web should return

  • an UPnP ContentDirectoryServer DIDLLite object
  • or a Deferred
get_name()

called by the MediaServer web should return

  • the name of the item, it is always expected to be in unicode
get_path()

called by the MediaServer web should return

  • the filepath where to find the media file that this item does refer to
get_update_id()
info(message, *args, **kwargs)
log(message, *args, **kwargs)
logCategory = 'twitch_store'
msg(message, *args, **kwargs)
register_child(child, external_id=None)
remove_child(child, external_id=None, update=True)
replace_by(item)
retrieve_all_children(start=0, request_count=0)
retrieve_children(start=0, page=0)
start_children_retrieval_campaign()
update_children(new_children, old_children)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
class StreamsContainer(parent, title, viewers=0, channels=0, streams_url='%s/streams/', cover_url=None, **kwargs)[source]

Bases: coherence.backends.twitch_storage.TwitchLazyContainer

URL = '%s/streams/'
result_handler(result, **kwargs)[source]
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
_got_error(error)
_got_page(result)
_retrieve_children(parent=None, **kwargs)
add_child(child, external_id=None, update=True)
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
end_children_retrieval_campaign(success=True)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
get_child_count()

called by the CDS should return

  • the number of its childs - len(childs)
  • or a Deferred
get_children(start=0, request_count=0)

called by the CDS and the MediaServer web should return

  • a list of its childs[start:end]
  • or a Deferred

if end == 0, the request is for all childs after start - childs[start:]

get_cover()

called by the MediaServer web should return

  • the filepath where to find the album art file

only needed when we have created for that item an albumArtURI property that does point back to us

get_id()
get_item()

called by the CDS and the MediaServer web should return

  • an UPnP ContentDirectoryServer DIDLLite object
  • or a Deferred
get_name()

called by the MediaServer web should return

  • the name of the item, it is always expected to be in unicode
get_path()

called by the MediaServer web should return

  • the filepath where to find the media file that this item does refer to
get_update_id()
info(message, *args, **kwargs)
log(message, *args, **kwargs)
logCategory = 'twitch_store'
msg(message, *args, **kwargs)
register_child(child, external_id=None)
remove_child(child, external_id=None, update=True)
replace_by(item)
retrieve_all_children(start=0, request_count=0)
retrieve_children(start=0, page=0)
start_children_retrieval_campaign()
update_children(new_children, old_children)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
class TwitchStreamItem(title, url, status=None, viewers=0, created_at=None, preview_url=None)[source]

Bases: coherence.backend.BackendItem

logCategory = 'twitch_store'
get_item()[source]

called by the CDS and the MediaServer web should return

  • an UPnP ContentDirectoryServer DIDLLite object
  • or a Deferred
get_id()[source]
get_url()[source]
replace_by(item)[source]
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
get_child_count()

called by the CDS should return

  • the number of its childs - len(childs)
  • or a Deferred
get_children(start=0, end=0)

called by the CDS and the MediaServer web should return

  • a list of its childs[start:end]
  • or a Deferred

if end == 0, the request is for all childs after start - childs[start:]

get_cover()

called by the MediaServer web should return

  • the filepath where to find the album art file

only needed when we have created for that item an albumArtURI property that does point back to us

get_name()

called by the MediaServer web should return

  • the name of the item, it is always expected to be in unicode
get_path()

called by the MediaServer web should return

  • the filepath where to find the media file that this item does refer to
info(message, *args, **kwargs)
log(message, *args, **kwargs)
msg(message, *args, **kwargs)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
class TwitchStore(server, **kwargs)[source]

Bases: coherence.backend.AbstractBackendStore

logCategory = 'twitch_store'
implements = ['MediaServer']
wmc_mapping = {'16': 1000}
description = ('twitch.tv', 'twitch.tv', None)
options = [{'option': 'name', 'text': 'Server Name:', 'type': 'string', 'default': 'twitch.tv', 'help': 'the name under this MediaServer shall show up with on other UPnP clients'}, {'option': 'access_token', 'text': 'OAuth Access Token:', 'type': 'string', 'default': '', 'help': 'access token to show personalized list of followed streams'}, {'option': 'version', 'text': 'UPnP Version:', 'type': 'int', 'default': 2, 'enum': (2, 1), 'help': 'the highest UPnP version this MediaServer shall support', 'level': 'advance'}, {'option': 'uuid', 'text': 'UUID Identifier:', 'type': 'string', 'default': 'twitch_tv', 'help': 'the unique (UPnP) identifier for this MediaServer', 'level': 'advance'}]
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

COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
_get_all_items(id)

a helper method to get all items as a response to some XBox 360 UPnP Search action probably never be used as the backend will overwrite the wmc_mapping with more appropriate methods

append_item(item, storage_id=None)
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
get_by_id(id)

called by the CDS or the MediaServer web

id is the id property of our DIDLLite item

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

should return

  • None when no matching item for that id is found,
  • a BackendItem,
  • or a Deferred
get_root_id()
get_root_item()
getnextID()
info(message, *args, **kwargs)
init_completed(*args, **kwargs)

inform Coherence that this backend is ready for announcement this method just accepts any form of arguments as we don’t under which circumstances it is called

len()
log(message, *args, **kwargs)
msg(message, *args, **kwargs)
release()

if anything needs to be cleaned up upon shutdown of this backend, this is the place for it

remove_item(item)
set_root_item(item)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
sort_by_viewers(x, y)[source]
json_loads(data)[source]

coherence.backends.yamj_storage (module)

class MovieItem(movie, store, title=None, url=None)[source]

Bases: coherence.backend.BackendItem

get_item()[source]

called by the CDS and the MediaServer web should return

  • an UPnP ContentDirectoryServer DIDLLite object
  • or a Deferred
get_path()[source]

called by the MediaServer web should return

  • the filepath where to find the media file that this item does refer to
get_id()[source]
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
get_child_count()

called by the CDS should return

  • the number of its childs - len(childs)
  • or a Deferred
get_children(start=0, end=0)

called by the CDS and the MediaServer web should return

  • a list of its childs[start:end]
  • or a Deferred

if end == 0, the request is for all childs after start - childs[start:]

get_cover()

called by the MediaServer web should return

  • the filepath where to find the album art file

only needed when we have created for that item an albumArtURI property that does point back to us

get_name()

called by the MediaServer web should return

  • the name of the item, it is always expected to be in unicode
info(message, *args, **kwargs)
log(message, *args, **kwargs)
logCategory = 'backend_item'
msg(message, *args, **kwargs)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
class YamjStore(server, **kwargs)[source]

Bases: coherence.backend.AbstractBackendStore

logCategory = 'yamj_store'
implements = ['MediaServer']
description = ('YAMJ', 'exposes the movie/TV series data files and metadata from a given YAMJ (Yet Another Movie Jukebox) library.', None)
options = [{'option': 'name', 'text': 'Server Name:', 'type': 'string', 'default': 'my media', 'help': 'the name under this MediaServer shall show up with on other UPnP clients'}, {'option': 'version', 'text': 'UPnP Version:', 'type': 'int', 'default': 2, 'enum': (2, 1), 'help': 'the highest UPnP version this MediaServer shall support', 'level': 'advance'}, {'option': 'uuid', 'text': 'UUID Identifier:', 'type': 'string', 'help': 'the unique (UPnP) identifier for this MediaServer, usually automatically set', 'level': 'advance'}, {'option': 'refresh', 'text': 'Refresh period', 'type': 'string'}, {'option': 'yamj_url', 'text': 'Library URL:', 'type': 'string', 'help': 'URL to the library root directory.'}]
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

COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
_get_all_items(id)

a helper method to get all items as a response to some XBox 360 UPnP Search action probably never be used as the backend will overwrite the wmc_mapping with more appropriate methods

append_item(item, storage_id=None)
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
get_by_id(id)

called by the CDS or the MediaServer web

id is the id property of our DIDLLite item

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

should return

  • None when no matching item for that id is found,
  • a BackendItem,
  • or a Deferred
get_root_id()
get_root_item()
getnextID()
info(message, *args, **kwargs)
init_completed(*args, **kwargs)

inform Coherence that this backend is ready for announcement this method just accepts any form of arguments as we don’t under which circumstances it is called

len()
log(message, *args, **kwargs)
msg(message, *args, **kwargs)
release()

if anything needs to be cleaned up upon shutdown of this backend, this is the place for it

remove_item(item)
retrieveCategories(parent)[source]
set_root_item(item)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
retrieveIndexMovies(parent, name, root_name, per_page=10, page=0, offset=0)[source]

coherence.backends.youtube_storage (module)

class TestVideoProxy(uri, id, proxy_mode, cache_directory, cache_maxsize=100000000, buffer_size=2000000, fct=None, **kwargs)[source]

Bases: coherence.upnp.core.utils.ReverseProxyUriResource, coherence.log.LogAble

logCategory = 'internetVideoProxy'
requestFinished(result)[source]

self.connection is set in utils.ReverseProxyResource.render

render(request)[source]

Render a request by forwarding it to the proxied server.

followRedirects(request)[source]
proxyURL(request)[source]
getMimetype()[source]
renderFile(request, filepath)[source]
renderBufferFile(request, filepath, buffer_size)[source]
downloadFinished(result)[source]
gotDownloadError(error, request)[source]
downloadFile(request, filepath, callback, *args)[source]
checkCacheSize()[source]
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
delEntity(name)
entityType = <InterfaceClass twisted.web.resource.IResource>
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
getChild(path, request)

Create and return a proxy resource with the same proxy configuration as this one, except that its path also contains the segment given by C{path} at the end.

getChildForRequest(request)
getChildWithDefault(path, request)

Retrieve a static or dynamically generated child resource from me.

First checks if a resource was added manually by putChild, and then call getChild to check for dynamic resources. Only override if you want to affect behaviour of all child lookups, rather than just dynamic ones.

This will check to see if I have a pre-registered child resource of the given name, and call getChild if I do not.

@see: L{IResource.getChildWithDefault}

getDynamicEntity(name, request)
getStaticEntity(name)
info(message, *args, **kwargs)
isLeaf = 0
listDynamicEntities(request=None)
listDynamicNames()
listEntities()
listNames()
listStaticEntities()
listStaticNames()
log(message, *args, **kwargs)
msg(message, *args, **kwargs)
proxyClientFactoryClass

alias of coherence.upnp.core.utils.ProxyClientFactory

putChild(path, child)

Register a static child.

You almost certainly don’t want ‘/’ in your path. If you intended to have the root of a folder, e.g. /foo/, you want path to be ‘’.

@see: L{IResource.putChild}

reallyPutEntity(name, entity)
render_HEAD(request)

Default handling of HEAD method.

I just return self.render_GET(request). When method is HEAD, the framework will handle this correctly.

resetTarget(host, port, path, qs='')
resetUri(uri)
server = None
uri = None
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
class YoutubeVideoItem(external_id, title, url, mimetype, entry, store)[source]

Bases: coherence.backend.BackendItem

get_item()[source]

called by the CDS and the MediaServer web should return

  • an UPnP ContentDirectoryServer DIDLLite object
  • or a Deferred
get_path()[source]

called by the MediaServer web should return

  • the filepath where to find the media file that this item does refer to
get_id()[source]
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
get_child_count()

called by the CDS should return

  • the number of its childs - len(childs)
  • or a Deferred
get_children(start=0, end=0)

called by the CDS and the MediaServer web should return

  • a list of its childs[start:end]
  • or a Deferred

if end == 0, the request is for all childs after start - childs[start:]

get_cover()

called by the MediaServer web should return

  • the filepath where to find the album art file

only needed when we have created for that item an albumArtURI property that does point back to us

get_name()

called by the MediaServer web should return

  • the name of the item, it is always expected to be in unicode
info(message, *args, **kwargs)
log(message, *args, **kwargs)
logCategory = 'backend_item'
msg(message, *args, **kwargs)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)
class YouTubeStore(server, **kwargs)[source]

Bases: coherence.backend.AbstractBackendStore

logCategory = 'youtube_store'
implements = ['MediaServer']
description = ('Youtube', 'connects to the YouTube service and exposes the standard feeds (public) and the uploads/favorites/playlists/subscriptions of a given user.', None)
options = [{'option': 'name', 'text': 'Server Name:', 'type': 'string', 'default': 'my media', 'help': 'the name under this MediaServer shall show up with on other UPnP clients'}, {'option': 'version', 'text': 'UPnP Version:', 'type': 'int', 'default': 2, 'enum': (2, 1), 'help': 'the highest UPnP version this MediaServer shall support', 'level': 'advance'}, {'option': 'uuid', 'text': 'UUID Identifier:', 'type': 'string', 'help': 'the unique (UPnP) identifier for this MediaServer, usually automatically set', 'level': 'advance'}, {'option': 'refresh', 'text': 'Refresh period', 'type': 'string'}, {'option': 'login', 'text': 'User ID:', 'type': 'string', 'group': 'User Account'}, {'option': 'password', 'text': 'Password:', 'type': 'string', 'group': 'User Account'}, {'option': 'location', 'text': 'Locale:', 'type': 'string'}, {'option': 'quality', 'text': 'Video quality:', 'type': 'string', 'default': 'sd', 'enum': ('sd', 'hd')}, {'option': 'standard_feeds', 'text': 'Include standard feeds:', 'type': 'bool', 'default': True}, {'option': 'proxy_mode', 'text': 'Proxy mode:', 'type': 'string', 'enum': ('redirect', 'proxy', 'cache', 'buffered')}, {'option': 'buffer_size', 'text': 'Buffering size:', 'type': 'int'}, {'option': 'cache_directory', 'text': 'Cache directory:', 'type': 'dir', 'group': 'Cache'}, {'option': 'cache_maxsize', 'text': 'Cache max size:', 'type': 'int', 'group': 'Cache'}]
appendFeed(name, feed_uri, parent)[source]
appendVideoEntry(entry, parent)[source]
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

retrieveFeedItems(parent=None, feed_uri='')[source]
retrievePlaylistFeedItems(parent, playlist_id)[source]
retrieveSubscriptionFeedItems(parent, uri)[source]
retrievePlaylistFeeds(parent)[source]
COLOR_FORMAT = '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'
FORMAT = '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'
_Loggable__logger = None
_get_all_items(id)

a helper method to get all items as a response to some XBox 360 UPnP Search action probably never be used as the backend will overwrite the wmc_mapping with more appropriate methods

append_item(item, storage_id=None)
critical(message, *args, **kwargs)
debug(message, *args, **kwargs)
error(message, *args, **kwargs)
exception(message, *args, **kwargs)
fatal(message, *args, **kwargs)
get_by_id(id)

called by the CDS or the MediaServer web

id is the id property of our DIDLLite item

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

should return

  • None when no matching item for that id is found,
  • a BackendItem,
  • or a Deferred
get_root_id()
get_root_item()
getnextID()
info(message, *args, **kwargs)
init_completed(*args, **kwargs)

inform Coherence that this backend is ready for announcement this method just accepts any form of arguments as we don’t under which circumstances it is called

len()
log(message, *args, **kwargs)
msg(message, *args, **kwargs)
release()

if anything needs to be cleaned up upon shutdown of this backend, this is the place for it

remove_item(item)
retrieveSubscriptionFeeds(parent)[source]
set_root_item(item)
warn(message, *args, **kwargs)
warning(message, *args, **kwargs)