rendered paste bodyIndex: elisa/core/cache_manager.py
===================================================================
--- elisa/core/cache_manager.py (rvision 1202)
+++ elisa/core/cache_manager.py (copie de travail)
@@ -235,7 +235,32 @@
if not conn:
conn = self.get_db_connection()
if type(media_node_id) == int:
- node = conn.get_media_node_with_id(media_node_id)
+ if media_node_id == 0: #handle special case for Coherence
+ medias = conn.get_medias()
+ child_list = []
+ for media in medias:
+ node_dict = {'id': media.id,
+ 'parent_id': 0,
+ 'name': media.short_name, # penser a retourner
+ 'mimetype': 'directory',
+ 'size': 0,
+ 'children': [self.get_media_node_with_id(n, conn)
+ for n in conn.get_nodes(media)],
+ 'location': media.uri
+ }
+ child_list.append(node_dict)
+ full_dict = {'id': 0,
+ 'parent_id': 0,
+ 'name': 'root',
+ 'mimetype': 'directory',
+ 'size': 0,
+ 'children': child_list,
+ 'location': media.uri
+ }
+ print "FULL DICT: ", full_dict
+ return full_dict
+ else:
+ node = conn.get_media_node_with_id(media_node_id)
else:
node = media_node_id
if node is not None:
@@ -243,21 +268,33 @@
if parent:
parent_id = parent.id
else:
+ print "PARENT ID IS 0"
parent_id = 0
children = conn.get_nodes(node)
if node.typ == '':
mimetype = 'directory'
else:
mimetype = '%s/' % node.format
+
+ #get the plugin that will handle http://
+ plugins = common.get_plugin_manager().get_singleton_plugins()
+ location = ''
+ for i in plugins:
+ if ('http' in i.provides):
+ location = '%s:%s' % (i.get_host_address(), i.get_server_port())
+ break
+ if location == '':
+ location = node.uri
+
node_dict = {'id': node.id,
'parent_id': parent_id,
'name': node.short_name,
'mimetype': mimetype,
'size': 0,
- 'children': [self.get_media_node_with_id(n, conn)
- for n in children],
- 'location': node.uri
+ 'children': [self.get_media_node_with_id(n, conn) for n in children],
+ 'location': location + '/data/upnp/' + str(node.id)
}
+
return node_dict
remote_get_media_node_with_id = get_media_node_with_id