How to use the pychromecast.controllers.youtube.YouTubeController function in PyChromecast

To help you get started, we’ve selected a few PyChromecast 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 Tsjippy / ChromecastPlugin / plugin.py View on Github external
def RestartYoutube(q,uri,videoid,seektime = None):
	try:
		ip=uri.split(":")[0]
		port=int(uri.split(":")[1])
		cc = pychromecast.Chromecast(ip,port)
		Mc=cc.media_controller
		cc.wait()
		yt = YouTubeController()
		cc.register_handler(yt)
		yt.play_video(videoid)
		Mc.block_until_active()
		while Mc.status.player_state != 'PLAYING':
			time.sleep(0.1)
		Mc.seek(seektime)
		time.sleep(2)
		cc.disconnect()
		q.put("Done")
	except Exception as e:
		q.put('Error on line {}'.format(sys.exc_info()[-1].tb_lineno)+" Error is: " +str(e))
github thedaynos / fantasyDraftHighlights / draftvid.py View on Github external
import re, requests,json
from config import *


#initialize chromecast
if chromeCast:
    import pychromecast
    from pychromecast.controllers.youtube import YouTubeController
    chromecasts=pychromecast.get_chromecasts()
    try:
        cast = next(cc for cc in chromecasts if cc.device.friendly_name==chromeCastName)
        cast.wait()
        ytc=YouTubeController()
        cast.register_handler(ytc)
        print ("\n\nConnected to: "+chromeCastName+"!")
    except StopIteration:
        print ("\n\n"+chromeCastName+" not found, vids will be displayed on this screen")
        chromeCast=False

#set up system variables for specific drafting sites
if "sleeper" in site.lower():
    import time
    site="sleeper"
    sApi="https://api.sleeper.app/v1/draft/"+str(boardNum)+"/picks"
    from vDictSleeper import vDictSleeper as vDict
elif "clicky" in site.lower():
    site="clicky"
    from vDictClicky import vDictClicky as vDict
elif "basmith7" in site.lower():
github guirem / plugin-googlecast / resources / pychromecast / examples / youtube_example.py View on Github external
)
args = parser.parse_args()

if args.show_debug:
    logging.basicConfig(level=logging.DEBUG)

chromecasts = pychromecast.get_listed_chromecasts(friendly_names=[args.cast])
if not chromecasts:
    print('No chromecast with name "{}" discovered'.format(args.cast))
    sys.exit(1)

cast = chromecasts[0]
# Start socket client's worker thread and wait for initial status update
cast.wait()

yt = YouTubeController()
cast.register_handler(yt)
yt.play_video(VIDEO_ID)
github ElevenPaths / HomePWN / modules / chromecast / send-video-youtube-v2.py View on Github external
def run(self):
        if not self.args["rhost"] and not self.args["name"]:
            print_info("Show options, it's necessary to configure onename or rhost")
            return
        if str(self.args["timeout"]) == "None":
            self.args["timeout"] = 6
        try:
            chromecasts = pychromecast.get_chromecasts(timeout=self.args["timeout"])
            cast = next(cc for cc in chromecasts if (cc.device.friendly_name == self.args["name"] or cc.host == self.args["rhost"]))
            cast.wait()
            print_info("Device found, sending video")
        except:
            print_error("Device no found")
            return

        yt = YouTubeController()
        cast.register_handler(yt)
        yt.play_video(self.args["video"])
        print_ok("Done!")
github BlackLight / platypush / platypush / plugins / media / chromecast.py View on Github external
from pychromecast.controllers.youtube import YouTubeController
        if not chromecast:
            chromecast = self.chromecast

        post_event(MediaPlayRequestEvent, resource=resource, device=chromecast)
        cast = self.get_chromecast(chromecast)

        mc = cast.media_controller
        yt = self._get_youtube_url(resource)

        if yt:
            self.logger.info('Playing YouTube video {} on {}'.format(
                yt, chromecast))

            hndl = YouTubeController()
            cast.register_handler(hndl)
            hndl.update_screen_id()
            return hndl.play_video(yt)

        resource = self._get_resource(resource)

        if resource.startswith('magnet:?'):
            player_args = {'chromecast': chromecast}
            return get_plugin('media.webtorrent').play(resource,
                                                       player='chromecast',
                                                       **player_args)

        if not content_type:
            content_type = get_mime_type(resource)

        if not content_type:
github skorokithakis / catt / catt / controllers.py View on Github external
def __init__(self, cast, app, prep=None):
        self._controller = YouTubeController()
        super(YoutubeCastController, self).__init__(cast, app, prep=prep)
        self.info_type = "id"
        self.save_capability = "partial"
        self.playlist_capability = "complete"
github balloob / pychromecast / pychromecast / controllers / youtube.py View on Github external
def __init__(self):
        super(YouTubeController, self).__init__(YOUTUBE_NAMESPACE, APP_YOUTUBE)
        self.status_update_event = threading.Event()
        self._screen_id = None
        self._session = None