Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
from streamlink.stream import HLSStream, DASHStream
from streamlink.utils import parse_json, update_scheme, search_dict
log = logging.getLogger(__name__)
class AtresPlayer(Plugin):
url_re = re.compile(r"https?://(?:www.)?atresplayer.com/")
state_re = re.compile(r"""window.__PRELOADED_STATE__\s*=\s*({.*?});""", re.DOTALL)
channel_id_schema = validate.Schema(
validate.transform(state_re.search),
validate.any(
None,
validate.all(
validate.get(1),
validate.transform(parse_json),
validate.transform(partial(search_dict, key="urlVideo"))
)
)
)
stream_schema = validate.Schema(
validate.transform(parse_json),
{"sources": [
validate.all({
"src": validate.url(),
validate.optional("type"): validate.text
})
]}, validate.get("sources"))
@classmethod
def can_handle_url(cls, url):
from streamlink.plugin import Plugin
from streamlink.plugin.api import validate
from streamlink.stream import HLSStream, HTTPStream, RTMPStream
from streamlink.utils import parse_json
from streamlink.plugins.common_jwplayer import _js_to_json
class TV5Monde(Plugin):
_url_re = re.compile(r'http://(.+\.)?(tv|tivi)5monde(plus(afrique)?)?\.com')
_videos_re = re.compile(r'"?(?:files|sources)"?:\s*(?P\[.+?\])')
_videos_embed_re = re.compile(r'(?:file:\s*|src=)"(?P.+?\.mp4|.+?/embed/.+?)"')
_videos_schema = validate.Schema(
validate.transform(_js_to_json),
validate.transform(parse_json),
validate.all([
validate.any(
validate.Schema(
{'url': validate.url()},
validate.get('url')
),
validate.Schema(
{'file': validate.url()},
validate.get('file')
),
)
])
)
@classmethod
def can_handle_url(cls, url):
validate.transform(lambda x: list(enumerate(x, 1))),
[
validate.all(
validate.union({
"i": validate.get(0),
"begin": validate.all(
validate.get(1),
validate.getattr("attrib"),
validate.get("begin"),
validate.transform(lambda s: s.replace(".", ","))
),
"end": validate.all(
validate.get(1),
validate.getattr("attrib"),
validate.get("end"),
validate.transform(lambda s: s.replace(".", ","))
),
"text": validate.all(
validate.get(1),
validate.transform(lambda x: '\n'.join([s.strip() for s in x.itertext()]))
)
}),
validate.transform(
lambda d: "{i}\n{begin} --> {end}\n{text}\n".format(**d)
)
)
],
validate.transform(lambda s: '\n'.join(s))
)
])
]
)
from streamlink.plugin.api import useragents, validate
from streamlink.stream import HLSStream
from streamlink.utils import parse_json, update_scheme
class IDF1(Plugin):
DACAST_API_URL = 'https://json.dacast.com/b/{}/{}/{}'
DACAST_TOKEN_URL = 'https://services.dacast.com/token/i/b/{}/{}/{}'
_url_re = re.compile(r'https?://www\.idf1\.fr/(videos/[^/]+/[^/]+\.html|live\b)')
_video_id_re = re.compile(r"dacast\('(?P\d+)_(?P[a-z]+)_(?P\d+)', 'replay_content', data\);")
_video_id_alt_re = re.compile(r'
import re
from streamlink.plugin import Plugin
from streamlink.plugin.api import validate
from streamlink.stream import HLSStream
class TV8(Plugin):
"""
Support for the live stream on www.tv8.com.tr
"""
url_re = re.compile(r"https?://www.tv8.com.tr/canli-yayin")
player_config_re = re.compile(r'''file:\s*"(.*?)"''')
player_config_schema = validate.Schema(
validate.transform(player_config_re.search),
validate.any(
None,
validate.all(
validate.get(1),
validate.url()
)
)
)
@classmethod
def can_handle_url(cls, url):
return cls.url_re.match(url) is not None
def _get_streams(self):
res = self.session.http.get(self.url)
stream_url = self.player_config_schema.validate(res.text)
_url_re = re.compile(r'https?://(?:www\.)?(?:rtbf\.be/auvio/.*\?l?id=(?P[0-9]+)#?|rtbfradioplayer\.be/radio/liveradio/.+)')
_stream_size_re = re.compile(r'https?://.+-(?P\d+p?)\..+?$')
_video_player_re = re.compile(r'.+?)".*?', re.DOTALL)
_video_stream_data_re = re.compile(r'
from streamlink.plugin.api import validate
from streamlink.stream import HLSStream
from streamlink.utils import parse_json
class TV360(Plugin):
url_re = re.compile(r"https?://(?:www.)?tv360.com.tr/CanliYayin")
data_re = re.compile(r'''div.*?data-tp=(?P<q>["'])(?P<data>.*?)(?P=q)''', re.DOTALL)
_js_to_json = partial(re.compile(r"""(\w+):(["']|\d+,|true|false)""").sub, r'"\1":\2')
data_schema = validate.Schema(
validate.transform(data_re.search),
validate.any(
None,
validate.all(
validate.get("data"),
validate.transform(_js_to_json),
validate.transform(lambda x: x.replace("'", '"')),
validate.transform(parse_json),
{
"tp_type": "hls4",
"tp_file": validate.url(),
}
)
)
)
@classmethod
def can_handle_url(cls, url):
return cls.url_re.match(url) is not None
def _get_streams(self):
res = self.session.http.get(self.url)</data></q>
import re
from functools import partial
from streamlink.plugin.api import validate
from streamlink.plugin.api.utils import parse_json
__all__ = ["parse_playlist"]
_playlist_re = re.compile(r"\(?\{.*playlist: (\[.*\]),.*?\}\)?;", re.DOTALL)
_js_to_json = partial(re.compile(r"(\w+):\s").sub, r'"\1":')
_playlist_schema = validate.Schema(
validate.transform(_playlist_re.search),
validate.any(
None,
validate.all(
validate.get(1),
validate.transform(_js_to_json),
validate.transform(parse_json),
[{
"sources": [{
"file": validate.text,
validate.optional("label"): validate.text
}]
}]
)
)
)
from streamlink.plugin.api import validate
from streamlink.plugin.api.utils import parse_json
__all__ = ["parse_playlist"]
_playlist_re = re.compile(r"\(?\{.*playlist: (\[.*\]),.*?\}\)?;", re.DOTALL)
_js_to_json = partial(re.compile(r"(\w+):\s").sub, r'"\1":')
_playlist_schema = validate.Schema(
validate.transform(_playlist_re.search),
validate.any(
None,
validate.all(
validate.get(1),
validate.transform(_js_to_json),
validate.transform(parse_json),
[{
"sources": [{
"file": validate.text,
validate.optional("label"): validate.text
}]
}]
)
)
)
def parse_playlist(res):
"""Attempts to parse a JWPlayer playlist in a HTTP response body."""
return _playlist_schema.validate(res.text)