Last active
February 6, 2018 15:17
-
-
Save YtvwlD/1da1fbee3eb250f178be957f9303c33e to your computer and use it in GitHub Desktop.
Puts Maurudor.de to a Chromecast.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import pychromecast | |
from pychromecast.controllers.media import MediaController | |
from sys import argv | |
from random import random | |
from time import sleep | |
print("Searching for devices...") | |
casts = pychromecast.get_chromecasts() | |
if len(argv) != 2: | |
print("Specify the Chromecast to use. Chromecasts found: {}".format([cc.device.friendly_name for cc in casts])) | |
exit() | |
print("Connecting to {}...".format(argv[1])) | |
cast = next(cc for cc in casts if cc.device.friendly_name == argv[1]) | |
if not cast: | |
print("Didn't find the specified device. Chromecasts found: {}".format(list(casts.keys()))) | |
mc = MediaController() | |
cast.register_handler(mc) | |
print("Connected. To stop, press ^C.") | |
try: | |
while True: | |
mc.play_media("https://maurudor.de/?{}".format(random()), "Image/jpg") | |
sleep(20) | |
except KeyboardInterrupt: | |
print("Exiting...") | |
cast.quit_app() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment