From ff73f768f01bda95b6d53f4969a6cc2cb86fabc7 Mon Sep 17 00:00:00 2001 From: Johan Andersson Date: Tue, 15 Jan 2013 17:20:56 +0100 Subject: [PATCH] tv4play: adding support for tv4.se --- svtplay_dl.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/svtplay_dl.py b/svtplay_dl.py index e00cca0..56d3fc2 100755 --- a/svtplay_dl.py +++ b/svtplay_dl.py @@ -889,15 +889,24 @@ class Viaplay(): class Tv4play(): def handle(self, url): - return "tv4play.se" in url + return ("tv4play.se" in url) or ("tv4.se" in url) def get(self, options, url): parse = urlparse(url) - try: - vid = parse_qs(parse[4])["video_id"][0] - except KeyError: - log.error("Can't find video file") - sys.exit(2) + if "tv4play.se" in url: + try: + vid = parse_qs(parse[4])["video_id"][0] + except KeyError: + log.error("Can't find video file") + sys.exit(2) + else: + match = re.search("-(\d+)$", url) + if match: + vid = match.group(1) + else: + log.error("Can't find video file") + sys.exit(2) + url = "http://premium.tv4play.se/api/web/asset/%s/play" % vid data = get_http_data(url) xml = ET.XML(data)