<commit_before># ex:ts=4:sw=4:sts=4:et
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-

# pylint has issues with urlparse: "some types could not be inferred"
# pylint: disable=E1103

from __future__ import absolute_import
import json
import re
import copy

from svtplay_dl.utils.urllib import quote_plus
from svtplay_dl.service import Service, OpenGraphThumbMixin
from svtplay_dl.fetcher.http import HTTP
from svtplay_dl.error import ServiceError

class Sr(Service, OpenGraphThumbMixin):
    supported_domains = ['sverigesradio.se']

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

        if self.exclude(options):
            yield ServiceError("Excluding video")
            return

        match = re.search(r'href="(/sida/[\.\/=a-z0-9&;\?]+playaudio=\d+)"', data)
        if not match:
            yield ServiceError("Can't find audio info")
            return
        path = quote_plus(match.group(1))
        dataurl = "http://sverigesradio.se/sida/ajax/getplayerinfo?url=%s&isios=false&playertype=html5" % path
        data = self.http.request("get", dataurl).content
        playerinfo = json.loads(data)["playerInfo"]
        for i in playerinfo["AudioSources"]:
            url = i["Url"]
            if not url.startswith('http'):
                url = 'http:%s' % url
            yield HTTP(copy.copy(options), url, i["Quality"]/1000)

<commit_msg>sr: this should be text<commit_after># ex:ts=4:sw=4:sts=4:et
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-

# pylint has issues with urlparse: "some types could not be inferred"
# pylint: disable=E1103

from __future__ import absolute_import
import json
import re
import copy

from svtplay_dl.utils.urllib import quote_plus
from svtplay_dl.service import Service, OpenGraphThumbMixin
from svtplay_dl.fetcher.http import HTTP
from svtplay_dl.error import ServiceError

class Sr(Service, OpenGraphThumbMixin):
    supported_domains = ['sverigesradio.se']

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

        if self.exclude(options):
            yield ServiceError("Excluding video")
            return

        match = re.search(r'href="(/sida/[\.\/=a-z0-9&;\?]+playaudio=\d+)"', data)
        if not match:
            yield ServiceError("Can't find audio info")
            return
        path = quote_plus(match.group(1))
        dataurl = "http://sverigesradio.se/sida/ajax/getplayerinfo?url=%s&isios=false&playertype=html5" % path
        data = self.http.request("get", dataurl).text
        playerinfo = json.loads(data)["playerInfo"]
        for i in playerinfo["AudioSources"]:
            url = i["Url"]
            if not url.startswith('http'):
                url = 'http:%s' % url
            yield HTTP(copy.copy(options), url, i["Quality"]/1000)


{'fraction_non_alphanumeric': 0.1292517006802721, 'fraction_numerical': 0.01217329036877909, 'mean_word_length': 2.9743954480796586, 'pattern_counts': {'":': 0, '<': 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': '7193303', 'n_tokens_mistral': 928, 'n_tokens_neox': 890, 'n_words': 208}