1
0
mirror of https://github.com/spaam/svtplay-dl.git synced 2024-11-27 21:54:17 +01:00

nrk: better support for nrk.no

This commit is contained in:
Johan Andersson 2014-01-26 01:50:54 +01:00
parent 7c1320c366
commit ef3834dcfb

View File

@ -2,12 +2,15 @@
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
from __future__ import absolute_import
import re
import sys
import json
from svtplay_dl.service import Service
from svtplay_dl.utils import get_http_data, subtitle_tt
from svtplay_dl.utils.urllib import urlparse
from svtplay_dl.fetcher.hds import download_hds
from svtplay_dl.fetcher.hls import download_hls
from svtplay_dl.log import log
class Nrk(Service):
supported_domains = ['nrk.no', 'tv.nrk.no']
@ -15,7 +18,22 @@ class Nrk(Service):
def get(self, options):
data = get_http_data(self.url)
match = re.search(r'data-media="(.*manifest.f4m)"', data)
manifest_url = match.group(1)
if match:
manifest_url = match.group(1)
else:
match = re.search(r'data-video-id="(\d+)"', data)
if match is None:
log.error("Can't find video id.")
sys.exit(2)
vid = match.group(1)
match = re.search(r"PS_VIDEO_API_URL : '([^']*)',", data)
if match is None:
log.error("Can't find server address with media info")
sys.exit(2)
dataurl = "%smediaelement/%s" % (match.group(1), vid)
data = json.loads(get_http_data(dataurl))
manifest_url = data["mediaUrl"]
options.live = data["isLive"]
if options.hls:
manifest_url = manifest_url.replace("/z/", "/i/").replace("manifest.f4m", "master.m3u8")
download_hls(options, manifest_url)