From c7373854f9805b0b7dd067422a13a483aea988e9 Mon Sep 17 00:00:00 2001 From: Johan Andersson Date: Sun, 4 Oct 2015 17:41:11 +0200 Subject: [PATCH] HLS: handle 403 error when the playlist is geoblocked --- lib/svtplay_dl/fetcher/hls.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/svtplay_dl/fetcher/hls.py b/lib/svtplay_dl/fetcher/hls.py index 7da4658..1d4260d 100644 --- a/lib/svtplay_dl/fetcher/hls.py +++ b/lib/svtplay_dl/fetcher/hls.py @@ -9,7 +9,7 @@ import copy from svtplay_dl.output import progressbar, progress_stream, ETA, output from svtplay_dl.log import log from svtplay_dl.utils.urllib import urlparse -from svtplay_dl.error import UIException +from svtplay_dl.error import UIException, ServiceError from svtplay_dl.fetcher import VideoRetriever @@ -43,9 +43,13 @@ def _get_full_url(url, srcurl): def hlsparse(options, res, url): - files = (parsem3u(res.text))[1] streams = {} + if res.status_code == 403: + streams[0] = ServiceError("Can't read HDS playlist. permission denied") + return streams + files = (parsem3u(res.text))[1] + for i in files: bitrate = float(i[1]["BANDWIDTH"])/1000 streams[int(bitrate)] = HLS(copy.copy(options), _get_full_url(i[0], url), bitrate, cookies=res.cookies)