From a5de20a41dc85d211f6b10853b8c3f39e1f802f6 Mon Sep 17 00:00:00 2001 From: Johan Andersson Date: Mon, 18 Aug 2014 22:21:44 +0200 Subject: [PATCH] vg: support for vgtv.no --- lib/svtplay_dl/service/vg.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/lib/svtplay_dl/service/vg.py b/lib/svtplay_dl/service/vg.py index 5b5e9f6..f518688 100644 --- a/lib/svtplay_dl/service/vg.py +++ b/lib/svtplay_dl/service/vg.py @@ -3,27 +3,39 @@ import re import sys import json import copy +import os from svtplay_dl.service import Service, OpenGraphThumbMixin from svtplay_dl.utils.urllib import urlparse -from svtplay_dl.utils import get_http_data +from svtplay_dl.utils import get_http_data, filenamify from svtplay_dl.fetcher.http import HTTP from svtplay_dl.fetcher.hds import hdsparse from svtplay_dl.fetcher.hls import HLS, hlsparse from svtplay_dl.log import log class Vg(Service, OpenGraphThumbMixin): - supported_domains = ['vg.no'] + supported_domains = ['vg.no', 'vgtv.no'] def get(self, options): match = re.search(r'data-videoid="([^"]+)"', self.get_urldata()) if not match: - log.error("Can't find video id") - sys.exit(2) + parse = urlparse(self.url) + match = re.search(r'video/(\d+)/', parse.fragment) + if not match: + log.error("Can't find video id") + sys.exit(2) videoid = match.group(1) data = get_http_data("http://svp.vg.no/svp/api/v1/vgtv/assets/%s?appName=vgtv-website" % videoid) jsondata = json.loads(data) + if options.output_auto: + directory = os.path.dirname(options.output) + title = "%s" % jsondata["title"] + title = filenamify(title) + if len(directory): + options.output = "%s/%s" % (directory, title) + else: + options.output = title if "hds" in jsondata["streamUrls"]: parse = urlparse(jsondata["streamUrls"]["hds"]) manifest = "%s://%s%s?%s&hdcore=3.3.0" % (parse.scheme, parse.netloc, parse.path, parse.query)