def switch_to(self, scene: str): res = self.ws.call(obsws_requests.GetStudioModeStatus()) if not res.getStudioMode(): self.ws.call(obsws_requests.EnableStudioMode()) self.ws.call(obsws_requests.SetPreviewScene(scene)) self.ws.call(obsws_requests.TransitionToProgram('Stinger')) self.ws.call(obsws_requests.DisableStudioMode())
def ToggleStudioMode(Action, ws, midi_out): StudioState = CheckStudioState(ws) if StudioState == True: try: ws.call(requests.DisableStudioMode()) except: print("Couldn't turn Studio Mode off") else: MidiLed(Action, "off", midi_out) PrintWithTime("Studio mode stopped") else: try: ws.call(requests.EnableStudioMode()) except: print("Couldn't turn Studio Mode on") else: MidiLed(Action, "on", midi_out) PrintWithTime("Studio mode started")
async def countdown(self, ctx: Context): def write_countdown_html(): args = ctx.message.content.split()[1:] parts = tuple(int(x) for x in args[0].split(':')) if len(parts) == 2: m, s = parts m, s = parts # noinspection PyShadowingNames delta = datetime.timedelta(minutes=m, seconds=s) dt = datetime.datetime.now() + delta elif len(parts) == 3: h, m, s = parts dt = datetime.datetime.now().replace(hour=h, minute=m, second=s) else: self.botlogger.error("Invalid call to countdown: {0}".format( args[0])) return self.bot.countdown_to = dt with codecs.open(self.htmlfile.replace('html', 'template'), encoding='UTF-8') as f: lines = f.read() lines = lines.replace('@@date@@', dt.isoformat()) with codecs.open(self.htmlfile, 'w', encoding='UTF-8') as f: f.write(lines) if not self.bot.check_sender(ctx, 'iarspider'): return if not self.ws: return res: obsws_requests.GetStreamingStatus = self.ws.call( obsws_requests.GetStreamingStatus()) if res.getStreaming(): self.logger.error('Already streaming!') return write_countdown_html() self.ws.call(obsws_requests.DisableStudioMode()) # Refresh countdown self.ws.call(obsws_requests.SetCurrentScene('Starting')) try: self.ws.call( obsws_requests.SetMute(self.aud_sources.getMic2(), True)) except KeyError: self.logger.warning("[WARN] Can't mute mic-2, please check!") self.ws.call(obsws_requests.SetMute(self.aud_sources.getMic1(), True)) self.ws.call(obsws_requests.EnableStudioMode()) self.ws.call(obsws_requests.StartStopStreaming()) time.sleep(1) self.ws.call(obsws_requests.PauseRecording()) # self.get_player() # self.player_play_pause() self.ws.call(obsws_requests.SetMute(False, 'Радио')) asyncio.ensure_future( ctx.send('Начат обратный отсчёт до {0}!'.format( self.bot.countdown_to.strftime('%X')))) asyncio.ensure_future(self.bot.my_run_commercial(self.bot.user_id)) self.logger.info("Getting Discord cog...") discord_bot = self.bot.get_cog('DiscordCog') if discord_bot: self.logger.info("Got it, requesting announce...") asyncio.ensure_future(discord_bot.announce()) else: self.logger.warning("Discord cog not found")
def EnableStudioMode(self): try: return self.ws.call(requests.EnableStudioMode()) except Exception as e: print(e)
print("Exception happened") elif Button == 9: try: print("Connecting to Camera2") ws.call(requests.SetPreviewScene("Camera2")) except: print("Exception happened") elif Button == 15: try: print("Send to stream") CurrentsceneObject = ws.call(requests.GetPreviewScene()) # print(CurrentsceneObject) Currentscene = CurrentsceneObject.getName() # print(Currentscene) ws.call(requests.SetCurrentTransition("Fade")) ws.call(requests.SetCurrentScene(Currentscene)) except: print("Exception happened") midi.init() midi_in = midi.Input(1, 1024) ws.call(requests.EnableStudioMode()) while True: while midi_in.poll(): midi_read = midi_in.read(1) # print(midi_read) if midi_read[0][0][0] == 154: # print(midi_read[0][0][1]) press_button(midi_read[0][0][1]) time.sleep(0.01)
def studio_mode(self): res = self._call(requests.EnableStudioMode()) return res.status
def StudioMode_Enable(self, *args, **kwargs): try: self.ws.call(requests.EnableStudioMode()) PrintWithTime(f"Enabled Studio Mode") except Exception as e: PrintWithTime(f"Couldn't enable Studio Mode. Error : {e}")