<commit_before># 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.log import log
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('="(https://www.expressen.se/tvspelare[^"]+)"', data)
        if not match:
            log.error("Can't find video id")
            return
        url = decode_html_entities(match.group(1))
        data = self.http.request("get", url)

        match = re.search("window.Player.settings = ({.*});", data.text)
        if not match:
            log.error("Can't find json info.")

        dataj = json.loads(match.group(1))
        if "streams" in dataj:
            if "iPad" in dataj["streams"]:
                streams = hlsparse(self.config, self.http.request("get", dataj["streams"]["iPad"]),
                                   dataj["streams"]["iPad"], output=self.output)
                for n in list(streams.keys()):
                    yield streams[n]
            if "hashHls" in dataj["streams"]:
                streams = hlsparse(self.config, self.http.request("get", dataj["streams"]["hashHls"]),
                                   dataj["streams"]["hashHls"], output=self.output)
                for n in list(streams.keys()):
                    yield streams[n]<commit_msg>expressen: fixed an issue we cant find the id<commit_after># 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]
{'fraction_non_alphanumeric': 0.1364870104691741, 'fraction_numerical': 0.005040713454827452, 'mean_word_length': 2.6083916083916083, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 1, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7570747', 'n_tokens_mistral': 822, 'n_tokens_neox': 812, 'n_words': 182}