How to use the catt.stream_info.StreamInfo function in catt

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_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
def setup_cast(device_name, video_url=None, controller=None, ytdl_options=None, action=None, prep=None):
    cast, cc_info = get_cast(device_name)
    cast_type = cc_info.cast_type
    stream = StreamInfo(video_url, device_info=cc_info, ytdl_options=ytdl_options) if video_url else None

    if controller:
        app = get_app(controller, cast_type, strict=True)
    elif prep == "app":
        if stream:
            if stream.is_local_file:
                app = get_app("default")
            else:
                app = get_app(stream.extractor, cast_type, show_warning=True)
        else:
            app = get_app("default")
    else:
        # cast.app_id can be None, in the case of an inactive audio device.
        if cast.app_id:
            app = get_app(cast.app_id, cast_type)
        else:
github skorokithakis / catt / catt / api.py View on Github external
def play_url(self, url: str, resolve: bool = False, block: bool = False) -> None:
        """
        Initiate playback of content.

        :param url: Network location of content.
        :param resolve: Try to resolve location of content stream with Youtube-dl.
                        If this is not set, it is assumed that the url points directly to the stream.
        :param block: Block until playback has stopped,
                      either by end of content being reached, or by interruption.
        """

        if resolve:
            stream = StreamInfo(url)
            url = stream.video_url
        self.controller.prep_app()
        self.controller.play_media_url(url)

        if self.controller.wait_for(["PLAYING"], timeout=10):
            if block:
                self.controller.wait_for(["UNKNOWN", "IDLE"])
        else:
            raise APIError("Playback failed")