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/expressen.py
2018-11-18 12:36:18 +01:00

30 lines
946 B
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
import json
from svtplay_dl.service import Service
from svtplay_dl.error import ServiceError
from svtplay_dl.fetcher.hls import hlsparse
from svtplay_dl.utils.text import decode_html_entities
class Expressen(Service):
supported_domains = ['expressen.se']
def get(self):
data = self.get_urldata()
match = re.search('data-article-data="([^"]+)"', data)
if not match:
yield ServiceError("Cant find video file info")
return
data = decode_html_entities(match.group(1))
janson = json.loads(data)
self.config.set("live", janson["isLive"])
streams = hlsparse(self.config, self.http.request("get", janson["stream"]), janson["stream"], output=self.output)
for n in list(streams.keys()):
yield streams[n]