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')
25
27
from urlparse import urlsplit
230
234
self.item.attachments = {}
231
235
self.item.attachments[hash_from_path] = utils.StaticFile(urllib.quote(thumbnail))
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))
235
254
# FIXME: getmtime is deprecated in Twisted 2.6
404
423
implements = ['MediaServer']
425
description = """MediaServer exporting files from the file-system"""
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'}
406
438
def __init__(self, server, **kwargs):
407
439
BackendStore.__init__(self,server,**kwargs)
408
440
self.next_id = 1000
429
461
self.inotify = None
431
if haz_inotify == True:
433
self.inotify = INotify()
434
except Exception,msg:
463
if kwargs.get('enable_inotify','yes') == 'yes':
464
if haz_inotify == True:
466
self.inotify = INotify()
467
except Exception,msg:
470
self.info("%s" %no_inotify_reason)
437
self.info("%s" %no_inotify_reason)
472
self.info("FSStore content auto-update disabled upon user request")
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,