예제 #1
0
 def query_state(self):
     self.controller.set_state(
         'stream',
         self.connection.call(requests.GetStreamingStatus()).getStreaming())
     self.controller.set_state(
         'record',
         self.connection.call(requests.GetStreamingStatus()).getRecording())
예제 #2
0
def ToggleStream(BUTTONCONF):
    #Here we check whether or not the stream is on
    StreamingState = True
    try:
        StreamingState = ws.call(requests.GetStreamingStatus())
        StreamingState = StreamingState.getStreaming()
    except:
        print("Couldn't get streaming status")

    if StreamingState == True:
        try:
            #Here we turn the stream off
            ws.call(requests.StopStreaming())
            #Here we turn the Led on the midi pad off
            try:
                if "Led" in BUTTONCONF:
                    midi_out.write_short(0x90, BUTTONCONF["Led"], 0)
                else:
                    print("No Led argument in Button config")
            except:
                pass
            #Here we wait for the stream to be turned off
            while StreamingState == True:
                try:
                    StreamingState = ws.call(requests.GetStreamingStatus())
                    StreamingState = StreamingState.getStreaming()
                except:
                    print("Couldn't get streaming status")
            print("Stopped Streaming")
        except:
            print("Couldn't stop stream")
    else:
        try:
            #Here we turn the stream on
            ws.call(requests.StartStreaming())
            #Here we turn the Led on the midi pad on
            try:
                if "Led" in BUTTONCONF:
                    if "LedMode" in BUTTONCONF:
                        midi_out.write_short(0x90, BUTTONCONF["Led"],
                                             BUTTONCONF["LedMode"])
                    else:
                        print("No LedMode argument in Button config")
                else:
                    print("No Led argument in Button config")
            except:
                pass
            #Here we wait for the stream to be turned on
            while StreamingState == False:
                try:
                    StreamingState = ws.call(requests.GetStreamingStatus())
                    StreamingState = StreamingState.getStreaming()
                except:
                    print("Couldn't get streaming status")
            print("Started Streaming")
        except:
            print("Couldn't start stream")
예제 #3
0
def test_connect():
    ws.call(requests.StartStopStreaming())
    stream = ws.call(requests.GetStreamingStatus())
    emit('data', {
        'livestate': stream.getStreaming(),
        'recordstate': stream.getRecording()
    })
예제 #4
0
    def get_stream_time(self):
        res = self._call(requests.GetStreamingStatus())

        if res.getStreaming():
            return res.getStreamTimecode().split('.')[0]

        return '00:00:00'
예제 #5
0
    async def setup(self, ctx: Context):
        if not self.bot.check_sender(ctx, 'iarspider'):
            self.logger.info('Wrong sender!')
            return

        if not self.ws:
            self.logger.info('OBS not present!')
            return

        self.ws.reconnect()

        res: obsws_requests.GetStreamingStatus = self.ws.call(
            obsws_requests.GetStreamingStatus())
        if res.getStreaming():
            self.logger.error('Already streaming!')
            return

        self.aud_sources = self.ws.call(obsws_requests.GetSpecialSources())
        self.ws.call(obsws_requests.SetCurrentProfile('Regular games'))
        self.ws.call(obsws_requests.SetCurrentSceneCollection('Twitch'))
        self.ws.call(
            obsws_requests.SetSceneItemProperties(scene_name="Paused",
                                                  item="ужин",
                                                  visible=False))

        asyncio.ensure_future(ctx.send('К стриму готов!'))
예제 #6
0
def test_connect():

    stream = ws.call(requests.GetStreamingStatus())
#     print(stream.getRecording())
    vol = ws.call(requests.GetSourcesList())
    print(vol)
    emit('data', {'livestate': stream.getStreaming(),'recordstate': stream.getRecording()})
예제 #7
0
def is_streaming(ws, args):
    resp = ws.call(requests.GetStreamingStatus())
    if (resp.getStreaming()):
        print('yes')
        exit(0)
    else:
        print('no')
        exit(1)
예제 #8
0
    def set_record(self, val=None):
        if val is None:
            val = not self.connection.call(
                requests.GetStreamingStatus()).getRecording()

        if val == True:
            self.connection.call(requests.StartRecording())
        else:
            self.connection.call(requests.StopRecording())
예제 #9
0
파일: obs.py 프로젝트: rlazarus/impbot
 def keepalive(self) -> None:
     # Sometimes we won't notice the connection is lost until we try to send something and it
     # fails. If we ever go more than a couple of seconds without receiving anything, send a
     # status request and ignore the result.
     while not self.shutdown_event.is_set():
         time.sleep(1)
         if (self.obsws.is_connected() and
                 datetime.datetime.now() - self.obsws.last_received > KEEPALIVE_INTERVAL):
             self.obsws.call(requests.GetStreamingStatus())
예제 #10
0
def ToggleStream(Action, ws, midi_out):
    #Here we check whether or not the stream is on
    try:
        StreamingState = ws.call(requests.GetStreamingStatus())
        StreamingState = StreamingState.getStreaming()
    except:
        print("Couldn't get streaming status")
    else:
        if StreamingState == True:
            try:
                #Here we turn the stream off
                ws.call(requests.StopStreaming())
            except:
                print("Couldn't stop stream")
            else:
                #Here we turn the Led on the midi pad off
                MidiLed(Action, "off", midi_out)
                #Here we wait for the stream to be turned off
                while StreamingState == True:
                    try:
                        StreamingState = ws.call(requests.GetStreamingStatus())
                        StreamingState = StreamingState.getStreaming()
                    except:
                        print("Couldn't get streaming status")
                        break
                PrintWithTime("Stopped Streaming")
        else:
            try:
                #Here we turn the stream on
                ws.call(requests.StartStreaming())
            except:
                print("Couldn't start stream")
            else:
                #Here we turn the Led on the midi pad on
                MidiLed(Action, "on", midi_out)
                #Here we wait for the stream to be turned on
                while StreamingState == False:
                    try:
                        StreamingState = ws.call(requests.GetStreamingStatus())
                        StreamingState = StreamingState.getStreaming()
                    except:
                        print("Couldn't get streaming status")
                        break
                PrintWithTime("Started Streaming")
예제 #11
0
    def SalvarEstadoActual(self):
        """Salta estado inicial de OBS para StreamDeck."""
        DataEscenaActual = self.OBS.call(requests.GetCurrentScene()).datain
        EstadoActual = self.OBS.call(requests.GetStreamingStatus()).datain
        SalvarValor("data/obs.json", "obs_conectar", self.Conectado)
        SalvarValor("data/obs.json", "obs_escena", DataEscenaActual["name"])
        SalvarValor("data/obs.json", "obs_grabar", EstadoActual["recording"])
        SalvarValor("data/obs.json", "obs_envivo", EstadoActual["streaming"])

        self.SalvarFuente()
예제 #12
0
 def TiempoGrabando(self, opciones=None):
     if self.Conectado:
         consulta = self.OBS.call(requests.GetStreamingStatus())
         if consulta.getRecording():
             tiempo = consulta.getRecTimecode().split(".")[0]
             logger.info(f"Tiempo Grabando: {tiempo}")
             return tiempo
     else:
         logger.info("OBS no Conectado")
         self.Notificar("OBS-No-Conectado")
     return "No-Grabando"
예제 #13
0
def ToggleStream(Action):
    #Here we check whether or not the stream is on
    try:
        StreamingState = ws.call(requests.GetStreamingStatus())
        StreamingState = StreamingState.getStreaming()
    except:
        PrintError("Couldn't get streaming status")
    else:
        if StreamingState == True:
            TurnStreamOff(Action)
        else:
            TurnStreamOn(Action)
예제 #14
0
def TurnStreamOff(Action):
    try:
        #Here we turn the stream off
        ws.call(requests.StopStreaming())
    except:
        PrintError("Couldn't stop stream")
    else:
        #Here we turn the Led on the midi pad off
        MidiLed(Action, "off")
        #Here we wait for the stream to be turned off
        StreamingState == True
        while StreamingState == True:
            try:
                StreamingState = ws.call(requests.GetStreamingStatus())
                StreamingState = StreamingState.getStreaming()
            except:
                PrintError("Couldn't get streaming status")
                break
        PrintWithTime("Stopped Streaming")
예제 #15
0
def TurnStreamOn(Action):
    try:
        #Here we turn the stream on
        ws.call(requests.StartStreaming())
    except:
        PrintError("Couldn't start stream")
    else:
        #Here we turn the Led on the midi pad on
        MidiLed(Action, "on")
        #Here we wait for the stream to be turned on
        StreamingState = False
        while StreamingState == False:
            try:
                StreamingState = ws.call(requests.GetStreamingStatus())
                StreamingState = StreamingState.getStreaming()
            except:
                PrintError("Couldn't get streaming status")
                break
        PrintWithTime("Started Streaming")
예제 #16
0
    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")
예제 #17
0
def stop_stream(ws, args):
    response = ws.call(requests.GetStreamingStatus())
    if response.getStreaming():
        ws.call(requests.StartStopStreaming())
예제 #18
0
 def GetStreamingStatus(self):
     try:
         return self.ws.call(
             requests.GetStreamingStatus()).__dict__["datain"]["streaming"]
     except Exception as e:
         print(e)
예제 #19
0
def Stream(client, Action):
    status = client.call(requests.GetStreamingStatus()).getRecording()
    client.call(requests.StartStopRecording(not status))
예제 #20
0
 def stream_status(self):
     logging.info("OBS command: get stream status.")
     return self.ws_call(requests.GetStreamingStatus())
예제 #21
0
    def is_streaming(self):
        res = self._call(requests.GetStreamingStatus())

        return res.getStreaming()
예제 #22
0

    host = data['params']['host']
    port = data['params']['port']
    password = data['params']['password']
    command = data['params']['command']
    enableOverride = data['params']['enableOverride']
	destinationScene = data['params']['destinationScene']

    ws = obsws(host, port, password)
    ws.connect()

    getScenes = ws.call(requests.GetSceneList())
    currentScene = getScenes.getCurrentScene()

    getStreamInformation = ws.call(requests.GetStreamingStatus())
    getStreamStatus = getStreamInformation.getStreaming()

    print("Host:" + host)
    print("Port:" + port)
    print("Password:"******"Destination Scene:" + destinationScene)
    print("Current Scene:" + currentScene)
    print(getStreamStatus)
    print("Override Status:")
    print(enableOverride)

    try:
        #scenes = ws.call(requests.GetSceneList())
        #for s in scenes.getScenes():
        #    name = s['name']
예제 #23
0
    def is_recording(self):
        res = self._call(requests.GetStreamingStatus())

        return res.GetRecording()