How to use catt - 10 common examples

To help you get started, we’ve selected a few catt examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github skorokithakis / catt / tests / test_catt.py View on Github external
def test_cache(self):
        cache = Cache()
        cache.set_data("name", CCInfo("192.168.0.6", 8009, "Fake Factory Inc.", "Fakecast", "fake"))
        self.assertEqual(
            cache.get_data("name").all_info,
            {
                "ip": "192.168.0.6",
                "port": 8009,
                "manufacturer": "Fake Factory Inc.",
                "model_name": "Fakecast",
                "cast_type": "fake",
            },
        )

        cache.clear()
        cache = Cache()
        self.assertEqual(cache.get_data("name"), None)
        cache.clear()
github skorokithakis / catt / tests / test_catt.py View on Github external
def test_cache(self):
        cache = Cache()
        cache.set_data("name", CCInfo("192.168.0.6", 8009, "Fake Factory Inc.", "Fakecast", "fake"))
        self.assertEqual(
            cache.get_data("name").all_info,
            {
                "ip": "192.168.0.6",
                "port": 8009,
                "manufacturer": "Fake Factory Inc.",
                "model_name": "Fakecast",
                "cast_type": "fake",
            },
        )

        cache.clear()
        cache = Cache()
        self.assertEqual(cache.get_data("name"), None)
        cache.clear()
github skorokithakis / catt / tests / test_catt.py View on Github external
def test_cache(self):
        cache = Cache()
        cache.set_data("name", CCInfo("192.168.0.6", 8009, "Fake Factory Inc.", "Fakecast", "fake"))
        self.assertEqual(
            cache.get_data("name").all_info,
            {
                "ip": "192.168.0.6",
                "port": 8009,
                "manufacturer": "Fake Factory Inc.",
                "model_name": "Fakecast",
                "cast_type": "fake",
            },
        )

        cache.clear()
        cache = Cache()
        self.assertEqual(cache.get_data("name"), None)
        cache.clear()
github skorokithakis / catt / tests / test_catt.py View on Github external
def test_stream_info_youtube_video(self):
        stream = StreamInfo("https://www.youtube.com/watch?v=VZMfhtKa-wo")
        self.assertIn("https://", stream.video_url)
        self.assertEqual(stream.video_id, "VZMfhtKa-wo")
        self.assertTrue(stream.is_remote_file)
        self.assertEqual(stream.extractor, "youtube")
github skorokithakis / catt / tests / test_catt.py View on Github external
def test_stream_info_other_video(self):
        stream = StreamInfo("https://www.twitch.tv/buddha/clip/OutstandingSquareMallardBudStar")
        self.assertIn("https://", stream.video_url)
        self.assertEqual(stream.video_id, "471296669")
        self.assertTrue(stream.is_remote_file)
        self.assertEqual(stream.extractor, "twitch")
github skorokithakis / catt / tests / test_catt.py View on Github external
def test_stream_info_youtube_playlist(self):
        stream = StreamInfo("https://www.youtube.com/playlist?list=PL9Z0stL3aRykWNoVQW96JFIkelka_93Sc")
        self.assertIsNone(stream.video_url)
        self.assertEqual(stream.playlist_id, "PL9Z0stL3aRykWNoVQW96JFIkelka_93Sc")
        self.assertTrue(stream.is_playlist)
        self.assertEqual(stream.extractor, "youtube")
github skorokithakis / catt / catt / controllers.py View on Github external
cast = get_chromecast_with_ip(device, DEFAULT_PORT)
        if not cast:
            msg = "No device found at {}".format(device)
            raise CastError(msg)
        cc_info = CCInfo(cast.host, cast.port, None, None, cast.cast_type)
    else:
        cache = Cache()
        cc_info = cache.get_data(device)

        if cc_info:
            cast = get_chromecast_with_ip(cc_info.ip, cc_info.port)
        if not cast:
            cast = get_chromecast(device)
            if not cast:
                msg = 'Specified device "{}" not found'.format(device) if device else "No devices found"
                raise CastError(msg)
            cc_info = CCInfo(cast.host, cast.port, cast.device.manufacturer, cast.model_name, cast.cast_type)
            cache.set_data(cast.name, cc_info)

    cast.wait()
    return (cast, cc_info)
github skorokithakis / catt / catt / api.py View on Github external
def _create_cast(self) -> None:
        self._cast = get_chromecast_with_ip(self.ip_addr) if self.ip_addr else get_chromecast(self.name)
        if not self._cast:
            raise CastError("Device could not be found")
        self._cast.wait()

        self.name = self._cast.name
        self.ip_addr = self._cast.host
        self.uuid = self._cast.uuid
github skorokithakis / catt / catt / controllers.py View on Github external
:param device: Can be an ip-address or a name.
    :type device: str
    :returns: Chromecast object for use in a CastController,
              and CCInfo object for use in setup_cast and StreamInfo
    :rtype: (pychromecast.Chromecast, CCInfo)
    """

    cast = None

    if device and is_ipaddress(device):
        cast = get_chromecast_with_ip(device, DEFAULT_PORT)
        if not cast:
            msg = "No device found at {}".format(device)
            raise CastError(msg)
        cc_info = CCInfo(cast.host, cast.port, None, None, cast.cast_type)
    else:
        cache = Cache()
        cc_info = cache.get_data(device)

        if cc_info:
            cast = get_chromecast_with_ip(cc_info.ip, cc_info.port)
        if not cast:
            cast = get_chromecast(device)
            if not cast:
                msg = 'Specified device "{}" not found'.format(device) if device else "No devices found"
                raise CastError(msg)
            cc_info = CCInfo(cast.host, cast.port, cast.device.manufacturer, cast.model_name, cast.cast_type)
            cache.set_data(cast.name, cc_info)

    cast.wait()
    return (cast, cc_info)
github skorokithakis / catt / catt / controllers.py View on Github external
if not cast:
            msg = "No device found at {}".format(device)
            raise CastError(msg)
        cc_info = CCInfo(cast.host, cast.port, None, None, cast.cast_type)
    else:
        cache = Cache()
        cc_info = cache.get_data(device)

        if cc_info:
            cast = get_chromecast_with_ip(cc_info.ip, cc_info.port)
        if not cast:
            cast = get_chromecast(device)
            if not cast:
                msg = 'Specified device "{}" not found'.format(device) if device else "No devices found"
                raise CastError(msg)
            cc_info = CCInfo(cast.host, cast.port, cast.device.manufacturer, cast.model_name, cast.cast_type)
            cache.set_data(cast.name, cc_info)

    cast.wait()
    return (cast, cc_info)