<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
import copy

from svtplay_dl.service import Service
from svtplay_dl.utils import decode_html_entities
from svtplay_dl.error import ServiceError
from svtplay_dl.fetcher.hls import HLS, hlsparse

class Aftonbladet(Service):
    supported_domains = ['tv.aftonbladet.se']

    def get(self, options):
        data = self.get_urldata()

        if self.exclude(options):
            return

        match = re.search('data-aptomaId="([-0-9a-z]+)"', data)
        if not match:
            match = re.search('data-player-config="([^"]+)"', data)
            if not match:
                yield ServiceError("Can't find video info")
                return
            janson = json.loads(decode_html_entities(match.group(1)))
            videoId = janson["videoId"]
        else:
            videoId = match.group(1)
            match = re.search(r'data-isLive="(\w+)"', data)
            if not match:
                yield ServiceError("Can't find live info")
                return
            if match.group(1) == "true":
                options.live = True

        if not options.live:
            dataurl = "http://aftonbladet-play-metadata.cdn.drvideo.aptoma.no/video/%s.json" % videoId
            data = self.http.request("get", dataurl).content
            data = json.loads(data)
            videoId = data["videoId"]

        streamsurl = "http://aftonbladet-play-static-ext.cdn.drvideo.aptoma.no/actions/video/?id=%s&formats&callback=" % videoId
        data = self.http.request("get", streamsurl).content
        streams = json.loads(data)
        hlsstreams = streams["formats"]["hls"]
        if "level3" in hlsstreams.keys():
            hls = hlsstreams["level3"]
        else:
            hls = hlsstreams["akamai"]
        if "csmil" in hls.keys():
            hls = hls["csmil"][0]<commit_msg>aftonbladet: use text instead of content<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
import copy

from svtplay_dl.service import Service
from svtplay_dl.utils import decode_html_entities
from svtplay_dl.error import ServiceError
from svtplay_dl.fetcher.hls import HLS, hlsparse

class Aftonbladet(Service):
    supported_domains = ['tv.aftonbladet.se']

    def get(self, options):
        data = self.get_urldata()

        if self.exclude(options):
            return

        match = re.search('data-aptomaId="([-0-9a-z]+)"', data)
        if not match:
            match = re.search('data-player-config="([^"]+)"', data)
            if not match:
                yield ServiceError("Can't find video info")
                return
            janson = json.loads(decode_html_entities(match.group(1)))
            videoId = janson["videoId"]
        else:
            videoId = match.group(1)
            match = re.search(r'data-isLive="(\w+)"', data)
            if not match:
                yield ServiceError("Can't find live info")
                return
            if match.group(1) == "true":
                options.live = True

        if not options.live:
            dataurl = "http://aftonbladet-play-metadata.cdn.drvideo.aptoma.no/video/%s.json" % videoId
            data = self.http.request("get", dataurl).text
            data = json.loads(data)
            videoId = data["videoId"]

        streamsurl = "http://aftonbladet-play-static-ext.cdn.drvideo.aptoma.no/actions/video/?id=%s&formats&callback=" % videoId
        data = self.http.request("get", streamsurl).text
        streams = json.loads(data)
        hlsstreams = streams["formats"]["hls"]
        if "level3" in hlsstreams.keys():
            hls = hlsstreams["level3"]
        else:
            hls = hlsstreams["akamai"]
        if "csmil" in hls.keys():
            hls = hls["csmil"][0]
{'fraction_non_alphanumeric': 0.13284597932946812, 'fraction_numerical': 0.0065540710864633225, 'mean_word_length': 2.231270358306189, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6703477', 'n_tokens_mistral': 1284, 'n_tokens_neox': 1263, 'n_words': 258}