diff --git a/panasonic.py b/panasonic.py index 433b4b3..124b82c 100755 --- a/panasonic.py +++ b/panasonic.py @@ -234,10 +234,11 @@ def downloadMovie(url, outputFileName, duration): exit(-1) outputFD = output.fileno() + session = sessions.Session() sample = 2. headers = {'TimeSeekRange.dlna.org': 'npt=0.000-%.03f' % sample} - r = requests.get(url, headers=headers) + r = session.get(url, headers=headers) if r.status_code != 200: logger.error('Impossible to download first %f seconds: %d' % (sample,r.status_code)) exit(-1) @@ -269,7 +270,8 @@ def downloadMovie(url, outputFileName, duration): pb = tqdm(total=estimatedLength, unit='bytes', desc='Download', unit_scale=True, unit_divisor=1024) nbiters = 0 - with requests.get(url, stream=True) as r: + + with session.get(url, stream=True) as r: chunks = r.iter_content(chunk_size = 100000) for chunk in chunks: output.write(chunk)