<commit_before>from __future__ import print_function
import re

from streamlink.plugin import Plugin
from streamlink.plugin.api import http
from streamlink.plugin.api import validate
from streamlink.stream import HLSStream


class Kanal7(Plugin):
    url_re = re.compile(r"https?://(?:www.)?kanal7.com/canli-izle")
    data_re = re.compile(r'''videoPlayer.setup\(\{\s*file:\s*"(http[^"]*?)"''', re.DOTALL)

    @classmethod
    def can_handle_url(cls, url):
        return cls.url_re.match(url) is not None

    def _get_streams(self):
        res = http.get(self.url)
        data_m = self.data_re.search(res.text)
        if data_m:
            stream_url = data_m.group(1)
            self.logger.debug("Found stream: {}", stream_url)
            yield "live", HLSStream(self.session, stream_url)
<commit_msg>plugins.kanal7: fixed page change in kanal7 live stream (#348)<commit_after>from __future__ import print_function
import re

from streamlink.plugin import Plugin
from streamlink.plugin.api import http
from streamlink.plugin.api import validate
from streamlink.stream import HLSStream


class Kanal7(Plugin):
    url_re = re.compile(r"https?://(?:www.)?kanal7.com/canli-izle")
    iframe_re = re.compile(r'iframe .*?src="(http://[^"]*?)"')
    stream_re = re.compile(r'source .*?src=*"(http[^"]*?)"')

    @classmethod
    def can_handle_url(cls, url):
        return cls.url_re.match(url) is not None

    def _get_streams(self):
        res = http.get(self.url)
        # find iframe url
        # open iframe page and extract m3u8 url
        iframe = self.iframe_re.search(res.text)
        iframe_url = iframe and iframe.group(1)
        if iframe_url:
            self.logger.debug("Found iframe: {}", iframe_url)
            ires = http.get(iframe_url)
            stream_m = self.stream_re.search(ires.text)
            stream_url = stream_m and stream_m.group(1)
            if stream_url:
                yield "live", HLSStream(self.session, stream_url)
        else:
            self.logger.error("Could not find iframe, has the page layout changed?")

{'fraction_non_alphanumeric': 0.12481927710843374, 'fraction_numerical': 0.006746987951807229, 'mean_word_length': 3.0310679611650486, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '4801966', 'n_tokens_mistral': 706, 'n_tokens_neox': 676, 'n_words': 153}