From 3fa00d18be166697f9a353ab9e71e5fdc7edfd64 Mon Sep 17 00:00:00 2001 From: Johan Andersson Date: Mon, 22 Dec 2014 11:02:03 +0100 Subject: [PATCH] Handle error from get_http_data --- lib/svtplay_dl/service/justin.py | 3 +++ lib/svtplay_dl/service/oppetarkiv.py | 3 +++ lib/svtplay_dl/service/svtplay.py | 3 +++ lib/svtplay_dl/service/tv4play.py | 3 +++ 4 files changed, 12 insertions(+) diff --git a/lib/svtplay_dl/service/justin.py b/lib/svtplay_dl/service/justin.py index 94ec3a8..df405c7 100644 --- a/lib/svtplay_dl/service/justin.py +++ b/lib/svtplay_dl/service/justin.py @@ -67,6 +67,9 @@ class Justin(Service): url = "http://api.justin.tv/api/broadcast/by_%s/%s.xml?onsite=true" % ( vidtype, vid) error, data = get_http_data(url) + if error: + log.error("Cant get api page") + return xml = ET.XML(data) url = xml.find("archive").find("video_file_url").text diff --git a/lib/svtplay_dl/service/oppetarkiv.py b/lib/svtplay_dl/service/oppetarkiv.py index 895d67b..245c449 100644 --- a/lib/svtplay_dl/service/oppetarkiv.py +++ b/lib/svtplay_dl/service/oppetarkiv.py @@ -13,6 +13,9 @@ class OppetArkiv(Svtplay): def find_all_episodes(self, options): page = 1 error, data = self.get_urldata() + if error: + log.error("Cant get web page") + return match = re.search(r'"http://www.oppetarkiv.se/etikett/titel/([^"/]+)', data) if match is None: match = re.search(r'"http://www.oppetarkiv.se/etikett/titel/([^"/]+)', self.url) diff --git a/lib/svtplay_dl/service/svtplay.py b/lib/svtplay_dl/service/svtplay.py index 453511e..de231d3 100644 --- a/lib/svtplay_dl/service/svtplay.py +++ b/lib/svtplay_dl/service/svtplay.py @@ -113,6 +113,9 @@ class Svtplay(Service, OpenGraphThumbMixin): log.error("Couldn't retrieve episode list") return error, data = get_http_data(match.group(1)) + if error: + log.error("Cant get rss page") + return xml = ET.XML(data) episodes = [x.text for x in xml.findall(".//item/link")] diff --git a/lib/svtplay_dl/service/tv4play.py b/lib/svtplay_dl/service/tv4play.py index a30187e..801dd9d 100644 --- a/lib/svtplay_dl/service/tv4play.py +++ b/lib/svtplay_dl/service/tv4play.py @@ -155,6 +155,9 @@ class Tv4play(Service, OpenGraphThumbMixin): if not re.search("%", show): show = quote_plus(show) error, data = get_http_data("http://webapi.tv4play.se/play/video_assets?type=episode&is_live=false&platform=web&node_nids=%s&per_page=99999" % show) + if error: + log.error("Can't get api page") + return jsondata = json.loads(data) episodes = [] n = 1