Skip to content

Commit 8b29003

Browse files
author
Martin Panter
committed
Move addition of media file and manifest.f4m to higher level
1 parent 2ea1e8d commit 8b29003

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

iview/fetch.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,16 +228,16 @@ def fetch(self, *, dest_file, **kw):
228228

229229
class HdsFetcher:
230230
def __init__(self, file, auth):
231-
self.url = urljoin(auth['server'], auth['path'])
232-
self.file = file
231+
base = urljoin(auth['server'], auth['path'])
232+
self.url = urljoin(base, file + '/manifest.f4m')
233233
self.tokenhd = auth.get('tokenhd')
234234

235235
def fetch(self, *, frontend, execvp, quiet, **kw):
236236
if frontend is None:
237237
call = hds_open_file
238238
else:
239239
call = HdsThread
240-
return call(self.url, self.file, self.tokenhd,
240+
return call(self.url, self.tokenhd,
241241
frontend=frontend,
242242
player=config.akamaihd_player,
243243
key=config.akamaihd_key, **kw)

iview/hds.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import urllib.request
2626
from .utils import PersistentConnectionHandler, http_get
2727
from sys import stderr
28-
from urllib.parse import urljoin, urlencode, quote_plus
28+
from urllib.parse import urljoin, urlencode, quote_plus, urlsplit
2929
import io
3030
from .utils import xml_text_elements
3131
from . import flvlib
@@ -503,12 +503,15 @@ def progress_update(frontend, flv, time, duration):
503503
time, duration, size / 1e6))
504504
stderr.flush()
505505

506-
def manifest_url(url, file, hdnea=None):
506+
def manifest_url(url, hdnea=None):
507507
query = [("hdcore", "")] # Produces 403 Forbidden without this
508508
if hdnea:
509509
query.append(("hdnea", hdnea))
510-
file += "/manifest.f4m?" + urlencode(query)
511-
return urljoin(url, file)
510+
query = urlencode(query)
511+
base_query = urlsplit(url).query
512+
if base_query:
513+
query = base_query + "&" + query
514+
return urljoin(url, "?" + query)
512515

513516
def get_manifest(url, session):
514517
"""Downloads the manifest specified by the URL and parses it

test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ def common(self, exception):
380380
self.assertRaises(exception, iview.comm.get_auth)
381381

382382
self.assertRaises(exception, hds.fetch,
383-
"http://localhost/", "media path", "hdnea", dest_file=None)
383+
"http://localhost/", "hdnea", dest_file=None)
384384

385385
@contextmanager
386386
def substattr(obj, attr, *value):

0 commit comments

Comments
 (0)