fetcher: use task loop for regular fetches
[hls-player:hls-player.git] / HLS / __init__.py
1 # -*- Mode: Python -*-
2 # vi:si:et:sw=4:sts=4:ts=4
3 #
4 # Copyright (C) 2009-2010 Fluendo, S.L. (www.fluendo.com).
5 # Copyright (C) 2009-2010 Marc-Andre Lureau <marcandre.lureau@gmail.com>
6
7 # This file may be distributed and/or modified under the terms of
8 # the GNU General Public License version 2 as published by
9 # the Free Software Foundation.
10 # This file is distributed without any warranty; without even the implied
11 # warranty of merchantability or fitness for a particular purpose.
12 # See "LICENSE" in the source distribution for more information.
13
14 import os
15 import urlparse
16
17 __version_info__ = (0,2,0)
18 __version__ = '.'.join(map(str,__version_info__))
19
20
21 def make_url(base_url, url):
22     if urlparse.urlsplit(url).scheme == '':
23         url = urlparse.urljoin(base_url, url)
24     if 'HLS_PLAYER_SHIFT_PORT' in os.environ.keys():
25         shift = int(os.environ['HLS_PLAYER_SHIFT_PORT'])
26         p = urlparse.urlparse(url)
27         loc = p.netloc
28         if loc.find(":") != -1:
29             loc, port = loc.split(':')
30             port = int(port) + shift
31             loc = loc + ":" + str(port)
32         elif p.scheme == "http":
33             port = 80 + shift
34             loc = loc + ":" + str(shift)
35         p = urlparse.ParseResult(scheme=p.scheme,
36                                  netloc=loc,
37                                  path=p.path,
38                                  params=p.params,
39                                  query=p.query,
40                                  fragment=p.fragment)
41         url = urlparse.urlunparse(p)
42     return url