From d9fb6ebc60afc294ea61b5b14d05e7dc98be47b7 Mon Sep 17 00:00:00 2001 From: Johan Andersson Date: Wed, 26 Nov 2014 15:59:38 +0100 Subject: [PATCH] nrk: http-rewrite --- lib/svtplay_dl/service/nrk.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/svtplay_dl/service/nrk.py b/lib/svtplay_dl/service/nrk.py index b9b5be6..bc1350c 100644 --- a/lib/svtplay_dl/service/nrk.py +++ b/lib/svtplay_dl/service/nrk.py @@ -6,7 +6,7 @@ import json import copy from svtplay_dl.service import Service, OpenGraphThumbMixin -from svtplay_dl.utils import get_http_data +from svtplay_dl.utils import get_http_data, HTTPError from svtplay_dl.utils.urllib import urlparse from svtplay_dl.fetcher.hds import hdsparse from svtplay_dl.fetcher.hls import HLS, hlsparse @@ -17,8 +17,12 @@ class Nrk(Service, OpenGraphThumbMixin): supported_domains = ['nrk.no', 'tv.nrk.no'] def get(self, options): - data = self.get_urldata() - match = re.search("data-subtitlesurl = \"(/.*)\"", data) + try: + match = re.search("data-subtitlesurl = \"(/.*)\"", self.get_urldata()) + except HTTPError: + log.error("Can't get the page") + return + if match: parse = urlparse(self.url) suburl = "%s://%s%s" % (parse.scheme, parse.netloc, match.group(1)) @@ -27,16 +31,16 @@ class Nrk(Service, OpenGraphThumbMixin): if options.force_subtitle: return - match = re.search(r'data-media="(.*manifest.f4m)"', data) + match = re.search(r'data-media="(.*manifest.f4m)"', self.get_urldata()) if match: manifest_url = match.group(1) else: - match = re.search(r'data-video-id="(\d+)"', data) + match = re.search(r'data-video-id="(\d+)"', self.get_urldata()) if match is None: log.error("Can't find video id.") return vid = match.group(1) - match = re.search(r"PS_VIDEO_API_URL : '([^']*)',", data) + match = re.search(r"PS_VIDEO_API_URL : '([^']*)',", self.get_urldata()) if match is None: log.error("Can't find server address with media info") return