Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def setup(self):
if self.isPluginActivated:
return
shell = self.get_property("shell")
player = shell.get_property("shell-player")
self.shell = shell
self.player = player
self.db = shell.get_property("db")
self.chromecast = pychromecast.get_chromecast(friendly_name=Prefs.chromecastName)
self.chromecast.wait()
# self.chromecastPlayer = self.chromecast.media_controller
self.chromecastListeners = ChromecastListeners.ChromecastListeners(self.chromecast)
self.shell_cb_ids = (
self.player.connect('playing-song-changed', self.chromecastListeners.song_changed_cb),
self.player.connect('playing-changed', self.chromecastListeners.player_changed_cb)
)
self.draw_sidebar()
model = self.get_property("query-model")
playing_entry = player.get_playing_entry()
# If the current playing entry is not in the playing source's
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)
def server(device):
global cast
global device_name
print('>> trying to connect to {}'.format(device))
device_name = device
cast = pychromecast.get_chromecast(friendly_name=device)
if cast is None:
click.echo("Couldn't find device '{}'".format(device))
sys.exit(-1)
print(repr(cast))
print('connected, starting up...')
app.run('0.0.0.0', 8183)
def get_chromecast():
""" create an instance of the chromecast device """
cast = pychromecast.get_chromecast()
time.sleep(1)
print
print cast.device
print
print cast.status
print
print cast.media_controller.status
print
return cast
def run(self):
chromecast = self.parent.chromecast
device = pychromecast.get_chromecast(friendly_name=chromecast)
interface = get_interface()
guess = self.parent.guess(self.parent.get_video_path())
device.play_media("http://%s:%s" % (interface, self.parent.port),
guess['mimetype'])
while True:
sleep(1)
def play(url):
while True:
try:
cast = pychromecast.get_chromecast()
while not cast.is_idle:
cast.quit_app()
time.sleep(1)
time.sleep(1)
cast.play_media(url, "video/mp4")
except socket.error as e:
if e.errno != errno.EFAULT:
raise
except ssl.SSLError as e:
pass
else:
break
control_loop(cast.media_controller)
cast.quit_app()
cur.execute("SELECT * FROM saved_chromecasts WHERE `friendly_name` = \""+ str(escaped) +"\" LIMIT 1 ;")
print cur.fetchall()
for row in cur.fetchall():
if row[1] == chromecastList[x]:
exists = True
else:
exists = False
if not exists == True:
print escaped + " was added."
cur.execute("INSERT INTO `saved_chromecasts` (`friendly_name`) VALUES (`"+ str(escaped) + "`);")
cast = pychromecast.get_chromecast(friendly_name="Jordan's Chromecast")
while True:
dbConnect()
time.sleep(2)
def _get_chromecast(self, name):
# compatibility
try:
return pychromecast.get_chromecast(friendly_name=self.cast_to)
except AttributeError:
return self._chromecasts_by_name[name]