How to use the pychromecast.get_chromecasts_as_dict 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 ironman5366 / W.I.L.L / plugins / chromecast.py View on Github external
def cast_main(leader, sentence, *args, **kwargs):
    log.info("In cast")
    def cast(chromecast):
        #cast = pychromecast.get_chromecast(friendly_name=chromecast)
        #cast.wait()
        if leader == "netflix" or sentence.split(" ")[1] == "netflix" or "netflix" in args["ents"].keys().lower():
            log.info("Sentence is {0}".format(sentence))
            netflix(sentence, args)
    known_chromecasts = config.load_config("chromecasts")
    log.info("Known chromecasts are {0}".format(str(known_chromecasts)))
    chromecasts_available = pychromecast.get_chromecasts_as_dict().keys()
    chromecast_name = None
    for chromecast in chromecasts_available:
        if isinstance(known_chromecasts, list):
            if chromecast in known_chromecasts:
                chromecast_name = chromecast
        elif isinstance(known_chromecasts, str):
            if chromecast == known_chromecasts:
                chromecast_name = chromecast

        else:
            return "Error: unrecognized chromecast conifg {0}".format(str(known_chromecasts))
    if chromecast_name:
        cast(chromecast_name)
    else:
        chromecast_choice = easygui.buttonbox(title="Chromecasts Found", msg="Please choose a chromecast", choices=chromecasts_available)
        if chromecast_choice:
github diequeiroz / start-chromecast-CLI / startcast / __init__.py View on Github external
def main():
    parser = set_options()
    options = get_options(parser)
    if options.get("ACTION") == "list":
        for key, value in pychromecast.get_chromecasts_as_dict().items():
            print "%s \t %s" % (key, value.host)
    else:
        cast = pychromecast.get_chromecast(friendly_name=options.get("CHROMECAST_FRIENDLY_NAME"))
        cast.wait()
        if cast and cast.status:
            if cast.status.is_stand_by or options.get("FORCE"): 
                cast.quit_app()
                cast.start_app(options.get("APP_ID"))
                print "Starting application %s on %s" % (options.get("APP_ID"), options.get("CHROMECAST_FRIENDLY_NAME"))
                exit(0)
            
            else:
                print "Chromecast %s is busy!" % options.get("CHROMECAST_FRIENDLY_NAME")
                
        else:
            print "No chromecast found with friendly name %s" % options.get("CHROMECAST_FRIENDLY_NAME")
github ains / aircast / src / cast.py View on Github external
def __init__(self, stream_url):
        self.stream_url = stream_url

        logger.info("Searching for Chromecast devices...")
        chromecast_list = pychromecast.get_chromecasts_as_dict().keys()
        logger.debug("Found Chromecasts: %s", chromecast_list)

        if not chromecast_list:
            raise RuntimeError("Unable to find a Chromecast on the local network.")

        chromecast_name = chromecast_list[0]
        if len(chromecast_list) > 1:
            logger.warn("Multiple Chromecast devices detected, using defaulting to Chromecast '%s'", chromecast_name)

        logger.info("Connecting to Chromecast '%s'", chromecast_name)
        self.chromecast = pychromecast.get_chromecast(
            friendly_name=chromecast_name)
        self.chromecast.wait()
        logger.info("Connected to Chromecast '%s'", chromecast_name)
github touchandgo-devs / touchandgo / touchandgo / output.py View on Github external
def select_chromecast(cls):
        name = None
        chromecasts = pychromecast.get_chromecasts_as_dict().keys()

        if not chromecasts:
            return

        if len(chromecasts) > 1:
            term = Terminal()

            print(term.clear())
            print(term.bold("Touchandgo\n"))
            print(term.red("Chromecasts Availables"))
            for i, cc_name in enumerate(chromecasts, 1):
                option = term.cyan("%s) " % i)
                option += cc_name
                print(option)

            input_text = "Select which chromecast you want to cast (1-%d): " % \
github Pizzaface / Alexa-Chromecast-Skill / chromecastPlayVideo.py View on Github external
def setup(chromecast_name):
	chromecastList = list(pychromecast.get_chromecasts_as_dict().keys())
	if chromecastList == []:
		print "Shit, we didn't find any Chromecasts..."
		setup(chromecast_name)
	else:
		print "Found ChromeCast: " + str(chromecastList)
	chromecast_name = str(chromecast_name).decode('string_escape')
	
	cast = pychromecast.get_chromecast(friendly_name=chromecast_name)
github andia89 / chromecast-player / player.py View on Github external
def get_active_chromecasts(self):
        casts = list(pyc.get_chromecasts_as_dict().keys())
        self.chromecasts = list(casts)
        return self.chromecasts