本文整理汇总了Python中streamlink.plugin.Plugin类的典型用法代码示例。如果您正苦于以下问题:Python Plugin类的具体用法?Python Plugin怎么用?Python Plugin使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Plugin类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, url):
Plugin.__init__(self, url)
self._headers = {
'Referer': self.url,
'User-Agent': useragents.FIREFOX
}
self._room_id = None
self._stream_urls = None
示例2: __init__
def __init__(self, url):
Plugin.__init__(self, url)
live_match = _live_url_re.match(url)
if live_match:
self.live = True
self.channel_path = live_match.group("channel_path")
else:
self.live = False
示例3: stream_weight
def stream_weight(cls, stream):
match = re.match("(\w+)_3d", stream)
if match:
weight, group = Plugin.stream_weight(match.group(1))
weight -= 1
group = "youtube_3d"
else:
weight, group = Plugin.stream_weight(stream)
return weight, group
示例4: stream_weight
def stream_weight(cls, stream):
match = re.match("mobile_(\w+)", stream)
if match:
weight, group = Plugin.stream_weight(match.group(1))
weight -= 1
group = "mobile_ustream"
elif stream == "recorded":
weight, group = 720, "ustream"
else:
weight, group = Plugin.stream_weight(stream)
return weight, group
示例5: __init__
def __init__(self, url):
Plugin.__init__(self, url)
match = _url_re.match(url).groupdict()
self.channel = match.get("channel").lower()
self.subdomain = match.get("subdomain")
self.video_type = match.get("video_type")
self.video_id = match.get("video_id")
parsed = urlparse(url)
self.params = parse_query(parsed.query)
self.api = TwitchAPI(beta=self.subdomain == "beta")
self.usher = UsherService()
示例6: stream_weight
def stream_weight(cls, stream):
match_3d = re.match(r"(\w+)_3d", stream)
match_hfr = re.match(r"(\d+p)(\d+)", stream)
if match_3d:
weight, group = Plugin.stream_weight(match_3d.group(1))
weight -= 1
group = "youtube_3d"
elif match_hfr:
weight, group = Plugin.stream_weight(match_hfr.group(1))
weight += 1
group = "high_frame_rate"
else:
weight, group = Plugin.stream_weight(stream)
return weight, group
示例7: test_cookie_store_load
def test_cookie_store_load(self):
session = Mock()
session.http.cookies = requests.cookies.RequestsCookieJar()
Plugin.bind(session, 'tests.test_plugin')
Plugin.cache = Mock()
Plugin.cache.get_all.return_value = {
"__cookie:test-name:test.se:80:/": self._create_cookie_dict("test-name", "test-value", None)
}
plugin = Plugin("http://test.se")
self.assertSequenceEqual(
list(map(self._cookie_to_dict, session.http.cookies)),
[self._cookie_to_dict(requests.cookies.create_cookie("test-name", "test-value", domain="test.se"))]
)
示例8: test_cookie_store_save
def test_cookie_store_save(self):
session = Mock()
session.http.cookies = [
requests.cookies.create_cookie("test-name", "test-value", domain="test.se")
]
Plugin.bind(session, 'tests.test_plugin')
Plugin.cache = Mock()
Plugin.cache.get_all.return_value = {}
plugin = Plugin("http://test.se")
plugin.save_cookies(default_expires=3600)
Plugin.cache.set.assert_called_with("__cookie:test-name:test.se:80:/",
self._create_cookie_dict("test-name", "test-value", None),
3600)
示例9: stream_weight
def stream_weight(cls, stream):
if stream == "source":
weight = 1080
else:
weight, group = Plugin.stream_weight(stream)
return weight, "azubutv"
示例10: stream_weight
def stream_weight(cls, key):
match_ultra = QUALITY_WEIGHTS_ULTRA.match(key)
if match_ultra:
ultra_level = int(match_ultra.group('level'))
return 1080 * (ultra_level + 1), "bliptv"
weight = QUALITY_WEIGHTS.get(key)
if weight:
return weight, "bliptv"
return Plugin.stream_weight(key)
示例11: test_cookie_store_save_expires
def test_cookie_store_save_expires(self):
with freezegun.freeze_time(datetime.datetime(2018, 1, 1)):
session = Mock()
session.http.cookies = [
requests.cookies.create_cookie("test-name", "test-value", domain="test.se", expires=time.time() + 3600,
rest={'HttpOnly': None})
]
Plugin.bind(session, 'tests.test_plugin')
Plugin.cache = Mock()
Plugin.cache.get_all.return_value = {}
plugin = Plugin("http://test.se")
plugin.save_cookies(default_expires=60)
Plugin.cache.set.assert_called_with("__cookie:test-name:test.se:80:/",
self._create_cookie_dict("test-name", "test-value", 1514768400),
3600)
示例12: test_cookie_store_clear
def test_cookie_store_clear(self):
session = Mock()
session.http.cookies = requests.cookies.RequestsCookieJar()
Plugin.bind(session, 'tests.test_plugin')
Plugin.cache = Mock()
Plugin.cache.get_all.return_value = {
"__cookie:test-name:test.se:80:/": self._create_cookie_dict("test-name", "test-value", None),
"__cookie:test-name2:test.se:80:/": self._create_cookie_dict("test-name2", "test-value2", None)
}
plugin = Plugin("http://test.se")
# non-empty cookiejar
self.assertTrue(len(session.http.cookies.get_dict()) > 0)
plugin.clear_cookies()
self.assertSequenceEqual(
Plugin.cache.set.mock_calls,
[call("__cookie:test-name:test.se:80:/", None, 0),
call("__cookie:test-name2:test.se:80:/", None, 0)])
self.assertSequenceEqual(session.http.cookies, [])
示例13: test_cookie_store_clear_filter
def test_cookie_store_clear_filter(self):
session = Mock()
session.http.cookies = requests.cookies.RequestsCookieJar()
Plugin.bind(session, 'tests.test_plugin')
Plugin.cache = Mock()
Plugin.cache.get_all.return_value = {
"__cookie:test-name:test.se:80:/": self._create_cookie_dict("test-name", "test-value", None),
"__cookie:test-name2:test.se:80:/": self._create_cookie_dict("test-name2", "test-value2", None)
}
plugin = Plugin("http://test.se")
# non-empty cookiejar
self.assertTrue(len(session.http.cookies.get_dict()) > 0)
plugin.clear_cookies(lambda c: c.name.endswith("2"))
self.assertSequenceEqual(
Plugin.cache.set.mock_calls,
[call("__cookie:test-name2:test.se:80:/", None, 0)])
self.assertSequenceEqual(
list(map(self._cookie_to_dict, session.http.cookies)),
[self._cookie_to_dict(requests.cookies.create_cookie("test-name", "test-value", domain="test.se"))]
)
示例14: stream_weight
def stream_weight(cls, key):
weight = QUALITY_WEIGHTS.get(key)
if weight:
return weight, "zdf_mediathek"
return Plugin.stream_weight(key)
示例15: __init__
def __init__(self, url):
Plugin.__init__(self, url)
self.session.http.headers = {"User-Agent": useragents.SAFARI_8}
self.zclient = ZTNRClient(self.secret_key, self.session)