本文整理汇总了Python中streamlink.plugin.api.validate.all函数的典型用法代码示例。如果您正苦于以下问题:Python all函数的具体用法?Python all怎么用?Python all使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了all函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: spec
_room_id_re = re.compile(r'"roomId":(?P<room_id>\d+),')
_room_id_alt_re = re.compile(r'content="showroom:///room\?room_id=(?P<room_id>\d+)"')
_room_id_lookup_failure_log = 'Failed to find room_id for {0} using {1} regex'
_api_status_url = 'https://www.showroom-live.com/room/is_live?room_id={room_id}'
_api_stream_url = 'https://www.showroom-live.com/api/live/streaming_url?room_id={room_id}'
_api_stream_schema = validate.Schema(
validate.any({
"streaming_url_list": validate.all([
{
"url": validate.text,
validate.optional("stream_name"): validate.text,
"id": int,
"label": validate.text,
"is_default": int,
"type": validate.text,
"quality": int,
}
])
},
{}
)
)
# the "low latency" streams are rtmp, the others are hls
_rtmp_quality_lookup = {
"オリジナル画質": "high",
"オリジナル画質(低遅延)": "high",
"original spec(low latency)": "high",
示例2: Livestation
LOGIN_POST_URL = "http://www.livestation.com/en/sessions.json"
_csrf_token_re = re.compile("<meta content=\"([^\"]+)\" name=\"csrf-token\"")
_hls_playlist_re = re.compile("<meta content=\"([^\"]+.m3u8)\" property=\"og:video\" />")
_url_re = re.compile("http(s)?://(\w+\.)?livestation.com")
_csrf_token_schema = validate.Schema(
validate.transform(_csrf_token_re.search),
validate.any(None, validate.get(1))
)
_hls_playlist_schema = validate.Schema(
validate.transform(_hls_playlist_re.search),
validate.any(
None,
validate.all(
validate.get(1),
validate.url(scheme="http", path=validate.endswith(".m3u8"))
)
)
)
_login_schema = validate.Schema({
"email": validate.text,
validate.optional("errors"): validate.all(
{
"base": [validate.text]
},
validate.get("base"),
)
})
class Livestation(Plugin):
示例3: Periscope
from streamlink.plugin import Plugin
from streamlink.plugin.api import http, validate
from streamlink.stream import HLSStream
STREAM_INFO_URL = "https://api.periscope.tv/api/v2/getAccessPublic"
STATUS_GONE = 410
STATUS_UNAVAILABLE = (STATUS_GONE,)
_url_re = re.compile(r"http(s)?://(www\.)?(periscope|pscp)\.tv/[^/]+/(?P<broadcast_id>[\w\-\=]+)")
_stream_schema = validate.Schema(
validate.any(
None,
validate.union({
"hls_url": validate.all(
{"hls_url": validate.url(scheme="http")},
validate.get("hls_url")
),
}),
validate.union({
"replay_url": validate.all(
{"replay_url": validate.url(scheme="http")},
validate.get("replay_url")
),
}),
),
)
class Periscope(Plugin):
@classmethod
def can_handle_url(cls, url):
示例4: Weeb
"{0} minutes. Try again in {1} minutes"
)
BLOCK_TYPE_VIEWING_LIMIT = 1
BLOCK_TYPE_NO_SLOTS = 11
_url_re = re.compile(r"http(s)?://(\w+\.)?weeb.tv/(channel|online)/(?P<channel>[^/&?]+)")
_schema = validate.Schema(
dict,
validate.map(lambda k, v: (PARAMS_KEY_MAP.get(k, k), v)),
validate.any(
{
"status": validate.transform(int),
"rtmp": validate.url(scheme="rtmp"),
"playpath": validate.text,
"multibitrate": validate.all(
validate.transform(int),
validate.transform(bool)
),
"block_type": validate.transform(int),
validate.optional("token"): validate.text,
validate.optional("block_time"): validate.text,
validate.optional("reconnect_time"): validate.text,
},
{
"status": validate.transform(int),
},
)
)
class Weeb(Plugin):
@classmethod
示例5:
scheme="http",
path=validate.endswith(".m3u8")
),
}, None)
},
validate.optional("playerUri"): validate.text,
validate.optional("viewerPlusSwfUrl"): validate.url(scheme="http"),
validate.optional("lsPlayerSwfUrl"): validate.text,
validate.optional("hdPlayerSwfUrl"): validate.text
})
_smil_schema = validate.Schema(validate.union({
"http_base": validate.all(
validate.xml_find("{http://www.w3.org/2001/SMIL20/Language}head/"
"{http://www.w3.org/2001/SMIL20/Language}meta"
"[@name='httpBase']"),
validate.xml_element(attrib={
"content": validate.text
}),
validate.get("content")
),
"videos": validate.all(
validate.xml_findall("{http://www.w3.org/2001/SMIL20/Language}body/"
"{http://www.w3.org/2001/SMIL20/Language}switch/"
"{http://www.w3.org/2001/SMIL20/Language}video"),
[
validate.all(
validate.xml_element(attrib={
"src": validate.text,
"system-bitrate": validate.all(
validate.text,
validate.transform(int)
示例6:
_api_schema = validate.Schema({
"error": bool,
validate.optional("code"): validate.text,
validate.optional("message"): validate.text,
validate.optional("data"): object,
})
_media_schema = validate.Schema(
{
"stream_data": validate.any(
None,
{
"streams": validate.all(
[{
"quality": validate.any(validate.text, None),
"url": validate.url(
scheme="http",
path=validate.endswith(".m3u8")
),
validate.optional("video_encode_id"): validate.text
}]
)
}
)
},
validate.get("stream_data")
)
_login_schema = validate.Schema({
"auth": validate.text,
"expires": validate.all(
validate.text,
validate.transform(parse_timestamp)
),
示例7:
formats = {}
if not formatsmap:
return formats
for format in formatsmap.split(","):
s = format.split("/")
(w, h) = s[1].split("x")
formats[int(s[0])] = "{0}p".format(h)
return formats
_config_schema = validate.Schema(
{
validate.optional("fmt_list"): validate.all(
validate.text,
validate.transform(parse_fmt_list)
),
validate.optional("url_encoded_fmt_stream_map"): validate.all(
validate.text,
validate.transform(parse_stream_map),
[{
"itag": validate.all(
validate.text,
validate.transform(int)
),
"quality": validate.text,
"url": validate.url(scheme="http"),
validate.optional("s"): validate.text,
validate.optional("stereo3d"): validate.all(
validate.text,
validate.transform(int),
示例8: NRK
"devicetype=desktop&"
"preferred-player-odm=hlslink&"
"preferred-player-live=hlslink"
)
_id_re = re.compile(r"/(?:program|direkte|serie/[^/]+)/([^/]+)")
_url_re = re.compile(r"https?://(tv|radio).nrk.no/")
_api_baseurl_re = re.compile(r'''apiBaseUrl:\s*["'](?P<baseurl>[^"']+)["']''')
_schema = validate.Schema(
validate.transform(_api_baseurl_re.search),
validate.any(
None,
validate.all(
validate.get("baseurl"),
validate.url(
scheme="http"
)
)
)
)
_mediaelement_schema = validate.Schema({
"mediaUrl": validate.url(
scheme="http",
path=validate.endswith(".m3u8")
)
})
class NRK(Plugin):
@classmethod
示例9:
import re
from streamlink.plugin import Plugin
from streamlink.plugin.api import http, validate
from streamlink.stream import RTMPStream
_url_re = re.compile("http(s)?://(\w+.)?beam.pro/(?P<channel>[^/]+)")
CHANNEL_INFO = "https://beam.pro/api/v1/channels/{0}"
CHANNEL_MANIFEST = "https://beam.pro/api/v1/channels/{0}/manifest.smil"
_assets_schema = validate.Schema(
validate.union({
"base": validate.all(
validate.xml_find("./head/meta"),
validate.get("base"),
validate.url(scheme="rtmp")
),
"videos": validate.all(
validate.xml_findall(".//video"),
[
validate.union({
"src": validate.all(
validate.get("src"),
validate.text
),
"height": validate.all(
validate.get("height"),
validate.text,
validate.transform(int)
)
示例10: Huya
from streamlink.plugin.api import http, validate
from streamlink.stream import HLSStream
from streamlink.plugin.api import useragents
from streamlink.utils import update_scheme
HUYA_URL = "http://m.huya.com/%s"
_url_re = re.compile(r'http(s)?://(www\.)?huya.com/(?P<channel>[^/]+)', re.VERBOSE)
_hls_re = re.compile(r'^\s*<video\s+id="html5player-video"\s+src="(?P<url>[^"]+)"', re.MULTILINE)
_hls_schema = validate.Schema(
validate.all(
validate.transform(_hls_re.search),
validate.any(
None,
validate.all(
validate.get('url'),
validate.transform(str)
)
)
)
)
class Huya(Plugin):
@classmethod
def can_handle_url(self, url):
return _url_re.match(url)
def _get_streams(self):
match = _url_re.match(self.url)
channel = match.group("channel")
示例11:
"<embed width=\"486\" height=\"326\" flashvars=\"([^\"]+)\""
)
_live_schema = validate.Schema({
"streams": [{
"name": validate.text,
"quality": validate.text,
"url": validate.url(scheme="rtmp")
}]
})
_schema = validate.Schema(
validate.union({
"export_url": validate.all(
validate.transform(_live_export_re.search),
validate.any(
None,
validate.get(1),
)
),
"video_flashvars": validate.all(
validate.transform(_video_flashvars_re.search),
validate.any(
None,
validate.all(
validate.get(1),
validate.transform(parse_query),
{
"_111pix_serverURL": validate.url(scheme="rtmp"),
"en_flash_providerName": validate.text
}
)
示例12: SeeMePlay
from streamlink.stream import HLSStream, HTTPStream
_url_re = re.compile(r"http(s)?://(\w+\.)?seemeplay.ru/")
_player_re = re.compile(r"""
SMP.(channel|video).player.init\({
\s+file:\s+"([^"]+)"
""", re.VERBOSE)
_schema = validate.Schema(
validate.transform(_player_re.search),
validate.any(
None,
validate.union({
"type": validate.get(1),
"url": validate.all(
validate.get(2),
validate.url(scheme="http"),
),
})
)
)
class SeeMePlay(Plugin):
@classmethod
def can_handle_url(cls, url):
return _url_re.match(url)
def _get_streams(self):
res = http.get(self.url, schema=_schema)
if not res:
return
示例13: Aftonbladet
_embed_re = re.compile(r"<iframe src=\"(http://tv.aftonbladet.se[^\"]+)\"")
_aptoma_id_re = re.compile(r"<div id=\"drvideo\".+data-aptomaId=\"([^\"]+)\"")
_live_re = re.compile(r"data-isLive=\"true\"")
_url_re = re.compile(r"http(s)?://(\w+.)?.aftonbladet.se")
_video_schema = validate.Schema(
{
"formats": validate.all(
{
validate.text: {
validate.text: validate.all(
dict,
validate.filter(lambda k, v: k in STREAM_FORMATS),
{
validate.text: [{
"address": validate.text,
"filename": validate.text,
"path": validate.text
}]
},
)
}
},
validate.filter(lambda k, v: k in STREAM_TYPES)
)
}
)
class Aftonbladet(Plugin):
@classmethod
def can_handle_url(cls, url):
示例14: http
http(s)?://(\w+\.)?aliez.tv
(?:
/live/[^/]+
)?
(?:
/video/\d+/[^/]+
)?
""", re.VERBOSE)
_file_re = re.compile("\"?file\"?:\s+['\"]([^'\"]+)['\"]")
_swf_url_re = re.compile("swfobject.embedSWF\(\"([^\"]+)\",")
_schema = validate.Schema(
validate.union({
"urls": validate.all(
validate.transform(_file_re.findall),
validate.map(unquote),
[validate.url()]
),
"swf": validate.all(
validate.transform(_swf_url_re.search),
validate.any(
None,
validate.all(
validate.get(1),
validate.url(
scheme="http",
path=validate.endswith("swf")
)
)
)
)
示例15:
douyu.com/
(?:
show/(?P<vid>[^/&?]+)|
(?P<channel>[^/&?]+)
)
""", re.VERBOSE)
_room_id_re = re.compile(r'"room_id\\*"\s*:\s*(\d+),')
_room_id_alt_re = re.compile(r'data-onlineid=(\d+)')
_room_id_schema = validate.Schema(
validate.all(
validate.transform(_room_id_re.search),
validate.any(
None,
validate.all(
validate.get(1),
validate.transform(int)
)
)
)
)
_room_id_alt_schema = validate.Schema(
validate.all(
validate.transform(_room_id_alt_re.search),
validate.any(
None,
validate.all(
validate.get(1),
validate.transform(int)
)