Package elisa :: Package plugins :: Package good :: Package media_db :: Module elisa_media
[hide private]
[frames] | no frames]

Source Code for Module elisa.plugins.good.media_db.elisa_media

 1  # -*- coding: utf-8 -*- 
 2  # Elisa - Home multimedia server 
 3  # Copyright (C) 2006-2008 Fluendo Embedded S.L. (www.fluendo.com). 
 4  # All rights reserved. 
 5  # 
 6  # This file is available under one of two license agreements. 
 7  # 
 8  # This file is licensed under the GPL version 3. 
 9  # See "LICENSE.GPL" in the root of this distribution including a special 
10  # exception to use Elisa with Fluendo's plugins. 
11  # 
12  # The GPL part of Elisa is also available under a commercial licensing 
13  # agreement from Fluendo. 
14  # See "LICENSE.Elisa" in the root directory of this distribution package 
15  # for details on that license. 
16   
17  """ 
18  MediaProvider that can access to Elisa's media db 
19  """ 
20   
21   
22  __maintainer__ = 'Lionel Martin <lionel@fluendo.com>' 
23   
24  from elisa.base_components.media_provider import MediaProvider 
25  from elisa.core.media_uri import MediaUri 
26  from elisa.core import common 
27  from elisa.core.utils import deferred_action 
28   
29  from twisted.internet import defer, threads 
30   
31   
32 -class ElisaMedia(MediaProvider):
33 """ 34 This class implements elisa metadata-like fs support 35 """ 36
37 - def __init__(self):
40
42 return []
43
45 return { 'elisa': 0 }
46
47 - def _blocking_get_media_type(self, uri):
48 # ElisaMedia always deal with virtual directories 49 return { 'file_type' : 'directory', 'mime_type' : '' }
50
51 - def is_directory(self, uri):
52 return self._def_action.insert_action(0, self._blocking_has_children_with_types, uri, ('audio'))
53 54
55 - def has_children_with_types(self, uri, media_types):
56 return self._def_action.insert_action(0, self._blocking_has_children_with_types, uri, media_types)
57
58 - def _blocking_has_children_with_types(self, uri, media_types):
59 if 'directory' in media_types or 'audio' in media_types: 60 db = common.application.media_manager.media_db 61 return db.has_children(uri) 62 63 return False
64
65 - def _blocking_get_direct_children(self, uri, children_with_info):
66 db = common.application.media_manager.media_db 67 list_of_children = db.get_uris_by_meta_uri(uri, children_with_info) 68 return children_with_info
69 70
71 - def get_direct_children(self, uri, children_with_info):
72 return self._def_action.insert_action(0, self._blocking_get_direct_children, 73 uri, children_with_info)
74 75
76 - def next_location(self, uri, root=None):
77 return self._def_action.insert_action(0, self._blocking_next_location, uri, root)
78
79 - def _blocking_next_location(self, uri, root):
80 db = common.application.media_manager.media_db 81 return db.get_next_location(uri, root)
82
83 - def uri_is_monitorable(self, uri):
84 return False
85