1
0
mirror of https://github.com/spaam/svtplay-dl.git synced 2024-11-24 12:15:40 +01:00
svtplay-dl/lib/svtplay_dl/service/nrk.py
2014-01-26 01:27:45 +01:00

36 lines
1.3 KiB
Python

# ex:ts=4:sw=4:sts=4:et
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
from __future__ import absolute_import
import re
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
class Nrk(Service):
supported_domains = ['nrk.no', 'tv.nrk.no']
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 options.hls:
manifest_url = manifest_url.replace("/z/", "/i/").replace("manifest.f4m", "master.m3u8")
download_hls(options, manifest_url)
else:
manifest_url = "%s?hdcore=2.8.0&g=hejsan" % manifest_url
download_hds(options, manifest_url)
def get_subtitle(self, options):
data = get_http_data(self.url)
match = re.search("data-subtitlesurl = \"(/.*)\"", data)
if match:
parse = urlparse(self.url)
subtitle = "%s://%s%s" % (parse.scheme, parse.netloc, match.group(1))
data = get_http_data(subtitle)
subtitle_tt(options, data)