Browse Source

make the mime-type fixup a function..

[git-p4: depot-paths = "//depot/": change = 1276]
main
John-Mark Gurney 16 years ago
parent
commit
f3495ee5da
1 changed files with 33 additions and 31 deletions
  1. +33
    -31
      pymeds.py

+ 33
- 31
pymeds.py View File

@@ -87,6 +87,38 @@ class PyMedS(service.MultiService):
def startService(self):
service.MultiService.startService(self)

def fixupmimetypes()
# Purely to ensure some sane mime-types. On MacOSX I need these.
# XXX - There isn't any easier way to get to the mime-type dict
# that I know of.
medianode = static.File('pymediaserv')
medianode.contentTypes.update( {
# From: http://support.microsoft.com/kb/288102
'.asf': 'video/x-ms-asf',
'.asx': 'video/x-ms-asf',
'.wma': 'audio/x-ms-wma',
'.wax': 'audio/x-ms-wax',
'.wmv': 'video/x-ms-wmv',
'.wvx': 'video/x-ms-wvx',
'.wm': 'video/x-ms-wm',
'.wmx': 'video/x-ms-wmx',

# From: http://www.matroska.org/technical/specs/notes.html
'.mkv': 'video/x-matroska',
'.mka': 'audio/x-matroska',

#'.ts': 'video/mp2t',
'.ts': 'video/mpeg', # we may want this instead of mp2t
'.m2t': 'video/mpeg',
'.m2ts': 'video/mpeg',
'.mp4': 'video/mp4',
#'.mp4': 'video/mpeg',
'.dat': 'video/mpeg', # VCD tracks
'.ogm': 'application/ogg',
'.vob': 'video/mpeg',
#'.m4a': 'audio/mp4', # D-Link can't seem to play AAC files.
})

def makeService(config):
listenAddr = config['addr']
listenPort = config['port']
@@ -146,37 +178,7 @@ def makeService(config):
root.putChild('content', content)


# Purely to ensure some sane mime-types. On MacOSX I need these.
# XXX - There isn't any easier way to get to the mime-type dict
# that I know of.
medianode = static.File('pymediaserv')
medianode.contentTypes.update( {
# From: http://support.microsoft.com/kb/288102
'.asf': 'video/x-ms-asf',
'.asx': 'video/x-ms-asf',
'.wma': 'audio/x-ms-wma',
'.wax': 'audio/x-ms-wax',
'.wmv': 'video/x-ms-wmv',
'.wvx': 'video/x-ms-wvx',
'.wm': 'video/x-ms-wm',
'.wmx': 'video/x-ms-wmx',

# From: http://www.matroska.org/technical/specs/notes.html
'.mkv': 'video/x-matroska',
'.mka': 'audio/x-matroska',

#'.ts': 'video/mp2t',
'.ts': 'video/mpeg', # we may want this instead of mp2t
'.m2t': 'video/mpeg',
'.m2ts': 'video/mpeg',
'.mp4': 'video/mp4',
#'.mp4': 'video/mpeg',
'.dat': 'video/mpeg', # VCD tracks
'.ogm': 'application/ogg',
'.vob': 'video/mpeg',
#'.m4a': 'audio/mp4', # D-Link can't seem to play AAC files.
})
del medianode
fixupmimetypes()

site = server.Site(root)
internet.TCPServer(listenPort, site).setServiceParent(serv)


Loading…
Cancel
Save