コード例 #1
0
ファイル: obscog.py プロジェクト: iarspider/arachnobot
    def do_pause(self, ctx: Context, is_dinner: bool):
        # self.get_player()
        # self.player_play_pause()

        if self.ws is not None:
            self.ws.call(obsws_requests.PauseRecording())
            self.ws.call(
                obsws_requests.SetSceneItemProperties(scene_name="Paused",
                                                      item="ужин",
                                                      visible=is_dinner))
            self.switch_to('Paused')
            if self.vr:
                self.ws.call(
                    obsws_requests.SetMute(self.aud_sources.getMic2(), True))
            else:
                self.ws.call(
                    obsws_requests.SetMute(self.aud_sources.getMic1(), True))

            self.ws.call(obsws_requests.SetMute(False, 'Радио'))
        # self.get_chatters()
        asyncio.ensure_future(ctx.send('Начать перепись населения!'))
        asyncio.ensure_future(self.bot.my_run_commercial(self.bot.user_id, 60))
コード例 #2
0
ファイル: obscog.py プロジェクト: iarspider/arachnobot
    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")
コード例 #3
0
ファイル: OBSObject.py プロジェクト: Atomiumm/OBSPython-Midi
 def PauseRecording(self):  #untested
     try:
         self.ws.call(requests.PauseRecording())
     except Exception as e:
         print(e)
コード例 #4
0
import logging

logging.basicConfig(level=logging.INFO)

sys.path.append('../')
from obswebsocket import obsws, requests  # noqa: E402

host = "localhost"
port = 4444
password = "******"

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

try:
    scenes = ws.call(requests.GetSceneList())
    for s in scenes.getScenes():
        name = s['name']
        print("\n" + name + "\n")
        ws.call(requests.PauseRecording())
        time.sleep(2)
        ws.call(requests.ResumeRecording())

    print("End of list")

except KeyboardInterrupt:
    pass

ws.disconnect()
コード例 #5
0
async def stopScript():
    global theScriptProcess
    t.kill("autoPauseOrResumeTheOBSrecording.py")
    if theScriptProcess is not None:
        theScriptProcess.kill()
        myOBScall(requests.PauseRecording())
コード例 #6
0
async def pause():
    myOBScall(requests.PauseRecording())
    return {"message": "done"}
コード例 #7
0
ファイル: OBSAPI.py プロジェクト: Atomiumm/OBSPython-Midi
 def Recording_Pause(self, *args, **kwargs):
     try:
         self.ws.call(requests.PauseRecording())
         PrintWithTime(f"Paused recording")
     except Exception as e:
         PrintWithTime(f"Couldn't pause recording. Error : {e}")