diff --git a/FSStorage.py b/FSStorage.py index 6d2225d..7915714 100644 --- a/FSStorage.py +++ b/FSStorage.py @@ -12,6 +12,7 @@ import itertools import os import sets import stat +import urlparse from DIDLLite import Container, StorageFolder, Item, VideoItem, AudioItem, TextItem, ImageItem, Resource, ResourceList from twisted.web import resource, server, static @@ -198,7 +199,7 @@ class FSItem(FSObject, Item): kwargs['content'] = DynamicTrans(self.FSpath, static.File(self.FSpath, mimetype)) Item.__init__(self, *args, **kwargs) - self.url = '%s/%s' % (self.cd.urlbase, self.id) + self.url = urlparse.urljoin(self.cd.urlbase, self.id) self.mimetype = mimetype self.checkUpdate() diff --git a/ZipStorage.py b/ZipStorage.py index 649268a..413b47b 100644 --- a/ZipStorage.py +++ b/ZipStorage.py @@ -8,6 +8,8 @@ import itertools import os.path import sets import time +import urlparse + import iterzipfile zipfile = iterzipfile import itertarfile @@ -170,7 +172,7 @@ class ZipFile(ZipItem, Item): kwargs['content'] = ZipResource(self.zf, self.name, self.mimetype) Item.__init__(self, *args, **kwargs) - self.url = '%s/%s' % (self.cd.urlbase, self.id) + self.url = urlparse.urljoin(self.cd.urlbase, self.id) self.res = Resource(self.url, 'http-get:*:%s:*' % self.mimetype) self.res.size = self.zi.file_size diff --git a/dvd.py b/dvd.py index ffe9e0d..e176e4f 100644 --- a/dvd.py +++ b/dvd.py @@ -10,6 +10,7 @@ default_audio_lang = 'en' import itertools import os import sets +import urlparse import sys sys.path.append('mpegts') @@ -114,7 +115,7 @@ class DVDChapter(VideoItem): p = audio.pos: audiofilter(i, 0x80 + p)) VideoItem.__init__(self, *args, **kwargs) - self.url = '%s/%s' % (self.cd.urlbase, self.id) + self.url = urlparse.urljoin(self.cd.urlbase, self.id) self.res = Resource(self.url, 'http-get:*:video/mpeg:*') #self.res.size = self.chapter.size @@ -132,7 +133,7 @@ class DVDTitle(StorageFolder): p = audio.pos: audiofilter(itertools.chain(*dt), 0x80 + p)) StorageFolder.__init__(self, *args, **kwargs) - self.url = '%s/%s' % (self.cd.urlbase, self.id) + self.url = urlparse.urljoin(self.cd.urlbase, self.id) self.res = Resource(self.url, 'http-get:*:video/mpeg:*') # mapping from path to objectID diff --git a/mpegtsmod.py b/mpegtsmod.py index 7d07688..e65380f 100644 --- a/mpegtsmod.py +++ b/mpegtsmod.py @@ -13,6 +13,7 @@ import itertools import os import sets import struct +import urlparse import sys mpegtspath = 'mpegts' @@ -293,7 +294,7 @@ class MPEGTS(FSObject, VideoItem): VideoItem.__init__(self, *args, **kwargs) FSObject.__init__(self, path) - self.url = '%s/%s' % (self.cd.urlbase, self.id) + self.url = urlparse.urljoin(self.cd.urlbase, self.id) self.res = Resource(self.url, 'http-get:*:video/mpeg:*') def doUpdate(self): diff --git a/pymeds.py b/pymeds.py index 3fa426a..1bf3414 100755 --- a/pymeds.py +++ b/pymeds.py @@ -106,7 +106,10 @@ def makeService(config): if uuid is None: uuid = generateuuid() - urlbase = 'http://%s:%d/' % (listenAddr, listenPort) + # XXX - may cause troubles if people aren't using urljoin, add a / to + # the first empty string arg to troubleshoot + urlbase = urlparse.urlunparse(('http', '%s:%s' % (listenAddr, + listenPort), '', '', '', '')) # Create SOAP server and content server from twisted.web import server, resource, static diff --git a/shoutcast.py b/shoutcast.py index 81c097d..7d87d91 100644 --- a/shoutcast.py +++ b/shoutcast.py @@ -15,6 +15,7 @@ import ConfigParser import StringIO import os.path import random +import urlparse import traceback @@ -284,11 +285,11 @@ class ShoutStation(AudioItem): kwargs['content'] = ShoutProxy(self.station['PLS_URL'], self.station['MimeType'].encode('ascii')) AudioItem.__init__(self, *args, **kwargs) - self.url = '%s/%s' % (self.cd.urlbase, self.id) + self.url = urlparse.urljoin(self.cd.urlbase, self.id) self.res = Resource(self.url, 'http-get:*:%s:*' % \ self.station['MimeType'].encode('ascii')) - #self.res = Resource(self.url + '/pcm', 'http-get:*:%s:*' % \ - # 'audio/x-wav') + #self.res = Resource(urlparse.urljoin(self.url, 'pcm'), + # 'http-get:*:%s:*' % 'audio/x-wav') self.bitrate = self.station['Bitrate'] * 128 # 1024k / 8bit class ShoutGenre(MusicGenre):