From bded5e89904895aa3837c813ccc759f63b21338e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Tronel?= Date: Sat, 6 Jan 2024 16:15:47 +0100 Subject: [PATCH] Utilisation d'une session. --- panasonic.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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)