~ubuntu-branches/ubuntu/precise/coherence/precise

« back to all changes in this revision

Viewing changes to coherence/backends/fs_storage.py

  • Committer: Bazaar Package Importer
  • Author(s): Charlie Smotherman
  • Date: 2010-01-02 10:57:15 UTC
  • mfrom: (1.1.7 upstream) (3.2.8 sid)
  • Revision ID: james.westby@ubuntu.com-20100102105715-sghzl2nw4lr5b1ob
Tags: 0.6.6.2-1
*  New  upstream release, summary of changes:
    - adding all necessary files to MANIFEST.in, to compensate for the
      gone 'auto-include-all-files-under-version-control' setuptools
      feature.
    - rearranging genre and genres attribute in DIDLLite - thx Caleb  
    - fix face_path typo, fixes #275.   

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
mimetypes.add_type('video/mp4', '.mp4')
22
22
mimetypes.add_type('video/mpegts', '.ts')
23
23
mimetypes.add_type('video/divx', '.divx')
 
24
mimetypes.add_type('video/divx', '.avi')
 
25
mimetypes.add_type('video/x-matroska', '.mkv')
24
26
 
25
27
from urlparse import urlsplit
26
28
 
89
91
        self.child_count = 0
90
92
        self.children = []
91
93
        self.sorted = False
 
94
        self.caption = None
92
95
 
93
96
 
94
97
        if mimetype in ['directory','root']:
168
171
                                     'application/ogg','audio/ogg',
169
172
                                     'audio/x-wav',
170
173
                                     'audio/x-m4a',
 
174
                                     'audio/flac',
171
175
                                     'application/x-flac'):
172
176
                    dlna_pn = 'DLNA.ORG_PN=LPCM'
173
177
                    dlna_tags = simple_dlna_tags[:]
230
234
                            self.item.attachments = {}
231
235
                        self.item.attachments[hash_from_path] = utils.StaticFile(urllib.quote(thumbnail))
232
236
 
 
237
            if self.mimetype.startswith('video/'):
 
238
                path = self.get_path()
 
239
                caption,_ =  os.path.splitext(path)
 
240
                caption = caption + '.srt'
 
241
                if os.path.exists(caption):
 
242
                    hash_from_path = str(id(caption))
 
243
                    mimetype = 'smi/caption'
 
244
                    new_res = Resource(self.url+'?attachment='+hash_from_path,
 
245
                        'http-get:*:%s:%s' % (mimetype, '*'))
 
246
                    new_res.size = os.path.getsize(caption)
 
247
                    self.caption = new_res.data
 
248
                    self.item.res.append(new_res)
 
249
                    if not hasattr(self.item, 'attachments'):
 
250
                        self.item.attachments = {}
 
251
                    self.item.attachments[hash_from_path] = utils.StaticFile(urllib.quote(caption))
233
252
 
234
253
            try:
235
254
                # FIXME: getmtime is deprecated in Twisted 2.6
403
422
 
404
423
    implements = ['MediaServer']
405
424
 
 
425
    description = """MediaServer exporting files from the file-system"""
 
426
 
 
427
    options = [{'option':'name','type':'string','default':'my media','help': 'the name under this MediaServer shall show up with on other UPnP clients'},
 
428
               {'option':'version','type':'int','default':2,'enum': (2,1),'help': 'the highest UPnP version this MediaServer shall support','level':'advance'},
 
429
               {'option':'uuid','type':'string','help':'the unique (UPnP) identifier for this MediaServer, usually automatically set','level':'advance'},
 
430
               {'option':'content','type':'string','default':xdg_content(),'help':'the path(s) this MediaServer shall export'},
 
431
               {'option':'ignore_patterns','type':'string','help':'list of regex patterns, matching filenames will be ignored'},
 
432
               {'option':'enable_inotify','type':'string','default':'yes','help':'enable real-time monitoring of the content folders'},
 
433
               {'option':'enable_destroy','type':'string','default':'no','help':'enable deleting a file via an UPnP method'},
 
434
               {'option':'import_folder','type':'string','help':'The path to store files imported via an UPnP method, if empty the Import method is disabled'}
 
435
              ]
 
436
 
 
437
 
406
438
    def __init__(self, server, **kwargs):
407
439
        BackendStore.__init__(self,server,**kwargs)
408
440
        self.next_id = 1000
428
460
 
429
461
        self.inotify = None
430
462
 
431
 
        if haz_inotify == True:
432
 
            try:
433
 
                self.inotify = INotify()
434
 
            except Exception,msg:
435
 
                self.info("%s" %msg)
 
463
        if kwargs.get('enable_inotify','yes') == 'yes':
 
464
            if haz_inotify == True:
 
465
                try:
 
466
                    self.inotify = INotify()
 
467
                except Exception,msg:
 
468
                    self.info("%s" %msg)
 
469
            else:
 
470
                self.info("%s" %no_inotify_reason)
436
471
        else:
437
 
            self.info("%s" %no_inotify_reason)
 
472
            self.info("FSStore content auto-update disabled upon user request")
438
473
 
439
474
        if kwargs.get('enable_destroy','no') == 'yes':
440
475
            self.upnp_DestroyObject = self.hidden_upnp_DestroyObject
741
776
                         'http-get:*:video/mpeg:*',
742
777
                         'internal:%s:video/avi:*' % self.server.coherence.hostname,
743
778
                         'http-get:*:video/avi:*',
 
779
                         'internal:%s:video/divx:*' % self.server.coherence.hostname,
 
780
                         'http-get:*:video/divx:*',
744
781
                         'internal:%s:video/quicktime:*' % self.server.coherence.hostname,
745
782
                         'http-get:*:video/quicktime:*',
746
783
                         'internal:%s:image/gif:*' % self.server.coherence.hostname,