def inp_cc(self): while True: try: pickle.dump(self.index, self.tf) self.tf.close() self.cast_to = self.cclist[int(self.index)][1] print(' ') print(colors.options('Casting to:') + ' ' + colors.success(self.cast_to)) print(' ') except TypeError: print(colors.options('Casting to:') + ' ' + colors.success(self.cast_to.player_name)) except IndexError: checkmktmp() self.tf = open('/tmp/mkchromecast.tmp', 'wb') self.sel_cc() continue break
def input_device(self, write_to_pickle=True): while True: try: if write_to_pickle: pickle.dump(self.index, self.tf) self.tf.close() self.cast_to = self.cclist[int(self.index)][1] print(' ') print(colors.options('Casting to:') + ' ' + colors.success(self.cast_to)) print(' ') except TypeError: print(colors.options('Casting to:') + ' ' + colors.success(self.cast_to.player_name)) except IndexError: checkmktmp() self.tf = open('/tmp/mkchromecast.tmp', 'wb') self.select_device() continue break
def input_device(self, write_to_pickle=True): while True: try: if write_to_pickle: pickle.dump(self.index, self.tf) self.tf.close() self.cast_to = self.cclist[int(self.index)][1] print(" ") print( colors.options("Casting to:") + " " + colors.success(self.cast_to)) print(" ") except TypeError: print( colors.options("Casting to:") + " " + colors.success(self.cast_to.player_name)) except IndexError: checkmktmp() self.tf = open("/tmp/mkchromecast.tmp", "wb") self.select_device() continue break
def stop_cast(self): if self.stopped is False: pass if (self.cast is not None or self.stopped is True or self.pcastfailed is True): try: self.cast.quit_app() except AttributeError: # This is for sonos. The thing is that if we are at this point, # user requested an stop or cast failed. self.cast.stop() self.reset_audio() try: self.kill_child() except psutil.NoSuchProcess: pass checkmktmp() self.search_cast() # This is to retry when stopping and # pychromecast.error.NotConnected raises. if chromecast: while True: try: self.cast.quit_app() except pychromecast.error.NotConnected: continue except AttributeError: # This is for sonos. The thing is that if we are at this # point, user requested an stop or cast failed. self.cast.stop() break self.stopped = True self.read_config() if platform == 'Darwin' and self.notifications == 'enabled': if self.pcastfailed is True: stop = [ './notifier/terminal-notifier.app/Contents/MacOS/terminal-notifier', '-group', 'cast', '-title', 'Mkchromecast', '-message', 'Streaming Process Failed. Try Again...' ] else: stop = [ './notifier/terminal-notifier.app/Contents/MacOS/terminal-notifier', '-group', 'cast', '-title', 'Mkchromecast', '-message', 'Streaming Stopped!' ] subprocess.Popen(stop) if debug is True: print(':::systray::: stop', stop) elif platform == 'Linux' and self.notifications == 'enabled': try: import gi gi.require_version('Notify', '0.7') from gi.repository import Notify Notify.init('Mkchromecast') if self.pcastfailed is True: stop = Notify.Notification.new( 'Mkchromecast', 'Streaming Process Failed. Try Again...', 'dialog-information' ) else: stop = Notify.Notification.new( 'Mkchromecast', 'Streaming Stopped!', 'dialog-information' ) stop.show() except ImportError: print('If you want to receive notifications in Linux, ' 'install libnotify and python-gobject')
'Mkchromecast', '-message', 'Searching for Media Streaming Devices...' ] subprocess.Popen(searching) if debug is True: print(':::systray:::', searching) elif platform == 'Linux' and self.notifications == 'enabled': try: import gi gi.require_version('Notify', '0.7') from gi.repository import Notify Notify.init('Mkchromecast') found = Notify.Notification.new( 'Mkchromecast', 'Searching for Media Streaming Devices...', 'dialog-information' ) found.show() except ImportError: print('If you want to receive notifications in Linux, ' 'install libnotify and python-gobject.') def main(): menubar() if __name__ == '__main__': checkmktmp() main()
def stop_cast(self): if self.stopped is False: pass if self.cast is not None or self.stopped is True or self.pcastfailed is True: try: self.cast.quit_app() except AttributeError: # This is for sonos. The thing is that if we are at this point, # user requested an stop or cast failed. self.cast.stop() self.reset_audio() try: self.kill_child() except psutil.NoSuchProcess: pass checkmktmp() self.search_cast() # This is to retry when stopping and # pychromecast.error.NotConnected raises. if chromecast: while True: try: self.cast.quit_app() except pychromecast.error.NotConnected: continue except AttributeError: # This is for sonos. The thing is that if we are at this # point, user requested an stop or cast failed. self.cast.stop() break self.stopped = True self.read_config() if platform == "Darwin" and self.notifications == "enabled": if self.pcastfailed is True: stop = [ "./notifier/terminal-notifier.app/Contents/MacOS/terminal-notifier", "-group", "cast", "-title", "Mkchromecast", "-message", "Streaming Process Failed. Try Again...", ] else: stop = [ "./notifier/terminal-notifier.app/Contents/MacOS/terminal-notifier", "-group", "cast", "-title", "Mkchromecast", "-message", "Streaming Stopped!", ] subprocess.Popen(stop) if debug is True: print(":::systray::: stop", stop) elif platform == "Linux" and self.notifications == "enabled": try: import gi gi.require_version("Notify", "0.7") from gi.repository import Notify Notify.init("Mkchromecast") if self.pcastfailed is True: stop = Notify.Notification.new( "Mkchromecast", "Streaming Process Failed. Try Again...", "dialog-information", ) else: stop = Notify.Notification.new("Mkchromecast", "Streaming Stopped!", "dialog-information") stop.show() except ImportError: print("If you want to receive notifications in Linux, " "install libnotify and python-gobject")
#!/usr/bin/env python # This file is part of mkchromecast. It is used to build the macOS app. from mkchromecast.utils import checkmktmp, writePidFile import mkchromecast.systray checkmktmp() writePidFile() mkchromecast.systray.main()