當前位置: 首頁>>代碼示例>>Python>>正文


Python plugin.Plugin類代碼示例

本文整理匯總了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
開發者ID:sheldon0531,項目名稱:streamlink,代碼行數:8,代碼來源:showroom.py

示例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
開發者ID:coder-alpha,項目名稱:CcloudTv.bundle,代碼行數:9,代碼來源:ruv.py

示例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
開發者ID:coder-alpha,項目名稱:CcloudTv.bundle,代碼行數:10,代碼來源:youtube.py

示例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
開發者ID:coder-alpha,項目名稱:CcloudTv.bundle,代碼行數:12,代碼來源:ustreamtv.py

示例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()
開發者ID:coder-alpha,項目名稱:CcloudTv.bundle,代碼行數:13,代碼來源:twitch.py

示例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
開發者ID:sheldon0531,項目名稱:streamlink,代碼行數:15,代碼來源:youtube.py

示例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"))]
        )
開發者ID:sheldon0531,項目名稱:streamlink,代碼行數:15,代碼來源:test_plugin.py

示例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)
開發者ID:sheldon0531,項目名稱:streamlink,代碼行數:16,代碼來源:test_plugin.py

示例9: stream_weight

    def stream_weight(cls, stream):
        if stream == "source":
            weight = 1080
        else:
            weight, group = Plugin.stream_weight(stream)

        return weight, "azubutv"
開發者ID:coder-alpha,項目名稱:CcloudTv.bundle,代碼行數:7,代碼來源:azubutv.py

示例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)
開發者ID:coder-alpha,項目名稱:CcloudTv.bundle,代碼行數:9,代碼來源:bliptv.py

示例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)
開發者ID:sheldon0531,項目名稱:streamlink,代碼行數:18,代碼來源:test_plugin.py

示例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, [])
開發者ID:sheldon0531,項目名稱:streamlink,代碼行數:22,代碼來源:test_plugin.py

示例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"))]
        )
開發者ID:sheldon0531,項目名稱:streamlink,代碼行數:24,代碼來源:test_plugin.py

示例14: stream_weight

    def stream_weight(cls, key):
        weight = QUALITY_WEIGHTS.get(key)
        if weight:
            return weight, "zdf_mediathek"

        return Plugin.stream_weight(key)
開發者ID:sheldon0531,項目名稱:streamlink,代碼行數:6,代碼來源:zdf_mediathek.py

示例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)
開發者ID:sheldon0531,項目名稱:streamlink,代碼行數:4,代碼來源:rtve.py


注:本文中的streamlink.plugin.Plugin類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。