def execute(self): # TODO slave? if self.on: TVManager().turn_tv_on() TVManager().switch_input_to_pi() else: TVManager().turn_tv_off()
def start_radio(self, name, url): self.stop_play() VLCPlayer().play(url, 0) self.media_data.start_update() self.media_data.type = "Radio" self.media_data.title = name self.media_data.image = None self.media_data.stop_update() TVManager().switch_input_to_pi()
def start_url(self, title, url): self.stop_play() VLCPlayer().play(url, 0) if Settings.get_bool("slave"): self.history_id, = SlaveClientController.request_master( "add_watched_url", 5, url, current_time()) else: self.history_id = Database().add_watched_url(url, current_time()) self.media_data.start_update() self.media_data.type = "Url" self.media_data.title = title self.media_data.stop_update() TVManager().switch_input_to_pi()
def _start_torrent(self, url, media_file): if self.torrent is not None: Logger().write(LogVerbosity.Important, "Can't start new torrent, still torrent active") return success, torrent = Torrent.create_torrent(1, url) if success: self.torrent = torrent if media_file is not None: self.torrent.set_selected_media_file(media_file) torrent.start() self.last_torrent_start = current_time() TVManager().switch_input_to_pi() else: Logger().write(LogVerbosity.Important, "Invalid torrent") EventManager.throw_event(EventType.Error, ["torrent_error", "Invalid torrent"]) self.stop_torrent()
def start_file(self, url, time): actual_url = url if Settings.get_bool("slave"): actual_url = "http://" + Settings.get_string( "master_ip") + ":50015/file/" + urllib.parse.quote(url) self.stop_play() VLCPlayer().play(actual_url, time) if Settings.get_bool("slave"): self.history_id, = SlaveClientController.request_master( "add_watched_file", 5, url, current_time()) else: self.history_id = Database().add_watched_file(url, current_time()) self.media_data.start_update() self.media_data.type = "File" self.media_data.title = os.path.basename(url) self.media_data.url = url self.media_data.image = None self.media_data.stop_update() TVManager().switch_input_to_pi()
def __init__(self): Logger().start(Settings.get_int("log_level")) sys.excepthook = self.handle_exception Logger().write(LogVerbosity.Info, "Starting") self.running = True self.version = datetime.fromtimestamp( self.get_latest_change()).strftime("%Y-%m-%d %H:%M:%S") self.is_slave = Settings.get_bool("slave") self.pi = sys.platform == "linux" or sys.platform == "linux2" Logger().write( LogVerbosity.Info, "Python version " + str(sys.version_info[0]) + "." + str(sys.version_info[1]) + "." + str(sys.version_info[2])) Logger().write(LogVerbosity.Info, "MediaPlayer build [" + self.version + "]") Logger().write(LogVerbosity.Info, "Slave: " + str(self.is_slave)) if self.is_slave: Logger().write( LogVerbosity.Info, "Master ip: " + str(Settings.get_string("master_ip"))) Logger().write(LogVerbosity.Info, "Pi: " + str(self.pi)) Logger().write(LogVerbosity.Info, "UI: " + str(Settings.get_bool("UI"))) Logger().write(LogVerbosity.Debug, "Initializing database") Database().init_database() Logger().write(LogVerbosity.Debug, "Initializing singletons") self.init_singletons() Logger().write(LogVerbosity.Debug, "Initializing sounds and folders") self.init_sound() self.init_folders() Logger().write(LogVerbosity.Debug, "Initializing API") APIController().start() Logger().write(LogVerbosity.Debug, "Initializing WiFi controller") WiFiController().check_wifi() Logger().write(LogVerbosity.Debug, "Initializing stats") Stats().start() Stats().set('start_time', current_time()) Logger().write(LogVerbosity.Debug, "Initializing presence manager") PresenceManager().start() Logger().write(LogVerbosity.Debug, "Initializing rule manager") RuleManager().start() Logger().write(LogVerbosity.Debug, "Initializing TV manager") TVManager().start() if not self.is_slave: Logger().write(LogVerbosity.Debug, "Initializing TradeFriManager") TradfriManager().init() Logger().write(LogVerbosity.Debug, "Initializing master file server") self.file_listener = StreamListener("MasterFileServer", 50015) self.file_listener.start_listening() Logger().write(LogVerbosity.Important, "Started") if Settings.get_bool("UI"): from UI.TV.GUI import App self.gui = App.initialize() else: while self.running: time.sleep(5)