本文整理汇总了Python中streamlink.plugin.api.http.post函数的典型用法代码示例。如果您正苦于以下问题:Python post函数的具体用法?Python post怎么用?Python post使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了post函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _get_live_streams
def _get_live_streams(self, lang, path):
"""
Get the live stream in a particular language
:param lang:
:param path:
:return:
"""
res = http.get(self._live_api_url.format(lang, path))
live_res = http.json(res)['default']['uid']
post_data = '{"channel_url":"/api/channels/%s/"}' % live_res
try:
stream_data = http.json(http.post(self._stream_get_url, data=post_data))['stream_url']
except BaseException:
stream_data = http.json(http.post(self._stream_get_url, data=post_data))['channel_url']
return HLSStream.parse_variant_playlist(self.session, stream_data)
开发者ID:justastranger,项目名称:Twitchy,代码行数:15,代码来源:olympicchannel.py
示例2: _get_streams
def _get_streams(self):
match = _url_re.match(self.url)
username = match.group("username")
CSRFToken = str(uuid.uuid4().hex.upper()[0:32])
headers = {
"Content-Type": "application/x-www-form-urlencoded",
"X-CSRFToken": CSRFToken,
"X-Requested-With": "XMLHttpRequest",
"Referer": self.url,
}
cookies = {
"csrftoken": CSRFToken,
}
post_data = "room_slug={0}&bandwidth=high".format(username)
res = http.post(API_HLS, headers=headers, cookies=cookies, data=post_data)
data = http.json(res, schema=_post_schema)
if data["success"] is True and data["room_status"] == "public":
for s in HLSStream.parse_variant_playlist(self.session, data["url"]).items():
yield s
开发者ID:amadu80,项目名称:repository.xvbmc,代码行数:25,代码来源:chaturbate.py
示例3: from_player_key
def from_player_key(cls, session, player_id, player_key, video_id, url=None):
amf_message = AMFMessage("com.brightcove.experience.ExperienceRuntimeFacade.getDataForExperience",
"/1",
[
''.join(["{0:02x}".format(random.randint(0, 255)) for _ in range(20)]), # random id
ViewerExperienceRequest(experienceId=int(player_id),
URL=url or "",
playerKey=player_key,
deliveryType=float('nan'),
TTLToken="",
contentOverrides=[ContentOverride(
featuredRefId=None,
contentRefIds=None,
contentId=int(video_id)
)])
])
amf_packet = AMFPacket(version=3)
amf_packet.messages.append(amf_message)
res = http.post(cls.amf_broker,
headers={"Content-Type": "application/x-amf"},
data=amf_packet.serialize(),
params=dict(playerKey=player_key),
raise_for_status=False)
data = AMFPacket.deserialize(BytesIO(res.content))
result = data.messages[0].value
bp = cls(session=session, account_id=int(result.publisherId))
return bp.get_streams(video_id)
开发者ID:amadu80,项目名称:repository.xvbmc,代码行数:28,代码来源:brightcove.py
示例4: _get_streams
def _get_streams(self):
if self.get_option("email") and self.get_option("password"):
if not self.authenticate(self.get_option("email"), self.get_option("password")):
self.logger.warning("Failed to login as {0}".format(self.get_option("email")))
# find the list of channels from the html in the page
self.url = self.url.replace("https", "http") # https redirects to http
res = http.get(self.url)
if "enter your postcode" in res.text:
self.logger.info("Setting your postcode to: {0}. "
"This can be changed in the settings on tvplayer.com", self.dummy_postcode)
res = http.post(self.update_url,
data=dict(postcode=self.dummy_postcode),
params=dict(return_url=self.url))
stream_attrs = self._get_stream_attrs(res)
if stream_attrs:
stream_data = self._get_stream_data(**stream_attrs)
if stream_data:
if stream_data.get("drmToken"):
self.logger.error("This stream is protected by DRM can cannot be played")
return
else:
return HLSStream.parse_variant_playlist(self.session, stream_data["stream"])
else:
if "need to login" in res.text:
self.logger.error(
"You need to login using --tvplayer-email/--tvplayer-password to view this stream")
开发者ID:justastranger,项目名称:Twitchy,代码行数:30,代码来源:tvplayer.py
示例5: _post_api
def _post_api(self, api, payload, schema):
res = http.post(api, json=payload)
data = http.json(res, schema=schema)
if data["result"] == "success":
post_data = data["reply"]
return post_data
开发者ID:justastranger,项目名称:Twitchy,代码行数:7,代码来源:garena.py
示例6: _get_streams
def _get_streams(self):
match = _url_re.match(self.url)
channel = match.group("channel")
http.headers.update({'User-Agent': useragents.CHROME})
payload = '{"liveStreamID": "%s"}' % (channel)
res = http.post(API_URL, data=payload)
status = _status_re.search(res.text)
if not status:
self.logger.info("Stream currently unavailable.")
return
http_url = _rtmp_re.search(res.text).group(1)
http_url = http_url.replace("http:", "https:")
yield "live", HTTPStream(self.session, http_url)
if 'pull-rtmp' in http_url:
url = http_url.replace("https:", "rtmp:").replace(".flv", "")
stream = RTMPStream(self.session, {
"rtmp": url,
"live": True
})
yield "live", stream
if 'wansu-' in http_url:
url = http_url.replace(".flv", "/playlist.m3u8")
for stream in HLSStream.parse_variant_playlist(self.session, url).items():
yield stream
else:
url = http_url.replace(".flv", ".m3u8")
yield "live", HLSStream(self.session, url)
开发者ID:amadu80,项目名称:repository.xvbmc,代码行数:32,代码来源:app17.py
示例7: authenticate
def authenticate(self, username, password):
res = http.get(self.login_url)
match = self.login_token_re.search(res.text)
token = match and match.group(1)
res2 = http.post(self.login_url, data=dict(email=username, password=password, token=token),
allow_redirects=False)
# there is a 302 redirect on a successful login
return res2.status_code == 302
开发者ID:justastranger,项目名称:Twitchy,代码行数:8,代码来源:tvplayer.py
示例8: _get_streams
def _get_streams(self):
# fetch requested url and find playlist info
response = http.get(self.url)
info = _find_playlist_info(response)
if not info:
# playlist info not found, let's try to find player url
player_url = _find_player_url(response)
if not player_url:
raise PluginError('Cannot find playlist info or player url!')
# get player url and try to find playlist info in it
response = http.get(player_url)
info = _find_playlist_info(response)
if not info:
raise PluginError('Cannot find playlist info in the player url!')
data = {
'playlist[0][type]': info['type'],
'playlist[0][id]': info['id'],
'requestUrl': '/ivysilani/embed/iFramePlayerCT24.php',
'requestSource': 'iVysilani',
'type': 'html'
}
headers = {
'x-addr': '127.0.0.1',
}
# fetch playlist url
response = http.post(
'http://www.ceskatelevize.cz/ivysilani/ajax/get-client-playlist',
data=data,
headers=headers
)
json_data = http.json(response, schema=_playlist_url_schema)
if json_data['url'] == "error_region":
self.logger.error("This stream is not available in your territory")
return
# fetch playlist
response = http.post(json_data['url'])
json_data = http.json(response, schema=_playlist_schema)
playlist = json_data['playlist'][0]['streamUrls']['main']
return HLSStream.parse_variant_playlist(self.session, playlist)
开发者ID:justastranger,项目名称:Twitchy,代码行数:45,代码来源:ceskatelevize.py
示例9: _get_stream_url
def _get_stream_url(self, video_id, vtype="video"):
res = http.post(self.stream_api_url, data={
"id": video_id,
"type": vtype,
"format": "json"
}, headers={
"User-Agent": useragents.IPHONE_6
})
data = http.json(res)
return data.get("path")
开发者ID:amadu80,项目名称:repository.xvbmc,代码行数:10,代码来源:ufctv.py
示例10: _get_hls_key
def _get_hls_key(self, broadcast, username):
headers = {
"Referer": self.url
}
data = {
"bj_id": username,
"broad_no": broadcast
}
res = http.post(HLS_KEY_URL, data=data, headers=headers)
return http.json(res)
开发者ID:justastranger,项目名称:Twitchy,代码行数:11,代码来源:afreeca.py
示例11: _login
def _login(self, username, password):
res = http.post(self.auth_url, data={
"username": username,
"password": password,
"cookielink": False
})
login_status = http.xml(res, schema=self.auth_schema)
self.logger.debug("Login status for {0}: {1}", username, login_status)
if login_status == "loginlocked":
self.logger.error("The account {0} has been locked, the password needs to be reset")
return login_status == "loginsuccess"
开发者ID:amadu80,项目名称:repository.xvbmc,代码行数:11,代码来源:ufctv.py
示例12: _get_streams
def _get_streams(self):
url_channel_name = self._url_re.match(self.url).group(1)
# Handle VODs first, since their "channel name" is different
if url_channel_name.endswith(".flv"):
self.logger.debug("Possible VOD stream...")
page = http.get(self.url)
vod_streams = self._get_vod_stream(page)
if vod_streams:
for s in vod_streams.items():
yield s
return
else:
self.logger.warning("Probably a VOD stream but no VOD found?")
ci = http.get(self.CHANNEL_API_URL.format(channel=url_channel_name), raise_for_status=False)
if ci.status_code == 404:
self.logger.error("The channel {0} does not exist".format(url_channel_name))
return
channel_api_json = json.loads(ci.text)
if channel_api_json["online"] != True:
self.logger.error("The channel {0} is currently offline".format(url_channel_name))
return
server = None
token = "public"
channel = channel_api_json["name"]
# Extract preferred edge server and available techs from the undocumented channel API
channel_server_res = http.post(self.VIDEO_API_URL, data={"loadbalancinginfo": channel})
info_json = json.loads(channel_server_res.text)
pref = info_json["preferedEdge"]
for i in info_json["edges"]:
if i["id"] == pref:
server = i["ep"]
break
self.logger.debug("Using load balancing server {0} : {1} for channel {2}",
pref,
server,
channel)
for i in info_json["techs"]:
if i["label"] == "HLS":
for s in self._create_hls_stream(server, channel, token).items():
yield s
elif i["label"] == "RTMP Flash":
stream = self._create_flash_stream(server, channel, token)
yield "live", stream
开发者ID:justastranger,项目名称:Twitchy,代码行数:51,代码来源:picarto.py
示例13: _get_streams
def _get_streams(self):
match = _url_re.match(self.url)
channel_name = match.group("channel")
form = {
"cid": channel_name,
"watchTime": 0,
"firstConnect": 1,
"ip": "NaN"
}
res = http.post(API_URL, data=form, headers=HEADERS)
params = parse_query(res.text, schema=_schema)
if params["status"] <= 0:
return
if params["block_type"] != 0:
if params["block_type"] == BLOCK_TYPE_VIEWING_LIMIT:
msg = BLOCKED_MSG_FORMAT.format(
params.get("block_time", "UNKNOWN"),
params.get("reconnect_time", "UNKNOWN")
)
raise PluginError(msg)
elif params["block_type"] == BLOCK_TYPE_NO_SLOTS:
raise PluginError("No free slots available")
else:
raise PluginError("Blocked for unknown reasons")
if "token" not in params:
raise PluginError("Server seems busy, retry again later")
streams = {}
stream_names = ["sd"]
if params["multibitrate"]:
stream_names += ["hd"]
for stream_name in stream_names:
playpath = params["playpath"]
if stream_name == "hd":
playpath += "HI"
stream = RTMPStream(self.session, {
"rtmp": "{0}/{1}".format(params["rtmp"], playpath),
"pageUrl": self.url,
"swfVfy": SWF_URL,
"weeb": params["token"],
"live": True
})
streams[stream_name] = stream
return streams
开发者ID:amadu80,项目名称:repository.xvbmc,代码行数:51,代码来源:weeb.py
示例14: login
def login(self, email, password):
self.logger.debug("Attempting to log in as {0}", email)
res = http.post(self.login_url,
data=dict(email=email, password=password),
allow_redirects=False,
raise_for_status=False)
loc = res.headers.get("Location", "")
if "geoblocked" in loc.lower():
self.logger.error("AnimeLab is not available in your territory")
elif res.status_code >= 400:
self.logger.error("Failed to login to AnimeLab, check your email/password combination")
else:
return True
return False
开发者ID:amadu80,项目名称:repository.xvbmc,代码行数:15,代码来源:animelab.py
示例15: get_token
def get_token(self, **config):
pdata = dict(arg1=base64.b64encode("www.ellobo106.com".encode("utf8")),
arg2=base64.b64encode(self.time.encode("utf8")))
headers = {
"User-Agent": useragents.FIREFOX,
"Referer": self.url,
"X-Requested-With": "XMLHttpRequest",
"Content-Type": "application/x-www-form-urlencoded"
}
res = http.post(self.token_url.format(deviceId=self.device_id, **config),
data=pdata, headers=headers)
data = http.json(res)
return data["token"]
开发者ID:amadu80,项目名称:repository.xvbmc,代码行数:15,代码来源:streann.py
示例16: _get_stream_data
def _get_stream_data(self, resource, channel_id, token, service=1):
# Get the context info (validation token and platform)
self.logger.debug("Getting stream information for resource={0}".format(resource))
context_res = http.get(self.context_url, params={"resource": resource,
"gen": token})
context_data = http.json(context_res, schema=self.context_schema)
self.logger.debug("Context data: {0}", str(context_data))
# get the stream urls
res = http.post(self.api_url, data=dict(
service=service,
id=channel_id,
validate=context_data["validate"],
token=context_data.get("token"),
platform=context_data["platform"]["key"]),
raise_for_status=False)
return http.json(res, schema=self.stream_schema)
开发者ID:justastranger,项目名称:Twitchy,代码行数:18,代码来源:tvplayer.py
示例17: _get_stream_url
def _get_stream_url(self, video_id, vtype):
try:
res = http.post(self.stream_api_url.format(self._domain), data={
"id": video_id,
"type": vtype,
"format": "json"
}, headers={
"User-Agent": useragents.IPHONE_6
})
except Exception as e:
if "400 Client Error" in str(e):
self.logger.error("Login required")
return
else:
raise e
data = http.json(res)
return data.get("path")
开发者ID:justastranger,项目名称:Twitchy,代码行数:18,代码来源:neulion.py
示例18: login
def login(self, email, password):
"""
Login to the schoolism account and return the users account
:param email: (str) email for account
:param password: (str) password for account
:return: (str) users email
"""
if self.options.get("email") and self.options.get("password"):
res = http.post(self.login_url, data={"email": email,
"password": password,
"redirect": None,
"submit": "Login"})
if res.cookies.get("password") and res.cookies.get("email"):
return res.cookies.get("email")
else:
self.logger.error("Failed to login to Schoolism, incorrect email/password combination")
else:
self.logger.error("An email and password are required to access Schoolism streams")
开发者ID:amadu80,项目名称:repository.xvbmc,代码行数:19,代码来源:schoolism.py
示例19: get_stream_url
def get_stream_url(self, data):
"""
Get the hls_url from the post request
:param data: dict with "gcp" and "ogn"
:return: hls_url
"""
try:
res = http.post(self.gate_url, headers=self.headers, data=data)
except Exception as e:
if "403" in str(e):
self.logger.error("This Video is Not Available in Your Country.")
raise NoStreamsError(self.url)
r_data = parse_json(res.text)
hls_url = r_data.get("stream")
suffix = r_data.get("suffix")
if hls_url is None and suffix:
hls_url = self.create_hls_url(suffix)
return hls_url
开发者ID:justastranger,项目名称:Twitchy,代码行数:20,代码来源:mitele.py
示例20: _get_streams
def _get_streams(self):
match = self.url_re.match(self.url)
res = http.post(self.flashvars_url,
data=dict(
broadcaster=match.group("broadcaster") or "Verm",
stream_id=match.group("channel_id") or match.group("highlight_id")))
flashvars = http.json(res, schema=self.flashvars_schema)
if flashvars.get("pereakaurl"):
url = self.pereakaurl.format(flashvars.get("pereakaurl").strip("/"))
return HLSStream.parse_variant_playlist(self.session, url)
elif flashvars.get("akaurl"):
url = self.akaurl.format(flashvars.get("akaurl").strip("/"))
return HLSStream.parse_variant_playlist(self.session, url)
elif flashvars.get("stream"):
self.logger.error("OctoStreams are not currently supported")
开发者ID:justastranger,项目名称:Twitchy,代码行数:20,代码来源:dingittv.py
注:本文中的streamlink.plugin.api.http.post函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论