コード例 #1
0
ファイル: OBS_OSC.py プロジェクト: claudeheintz/obs_osc_py
 def dispatch_obs_recording(self, parts, args):
     if self.check_arg_one(args):
         if len(parts) == 4:
             if parts[3] == "start":  # /obs/recording/start
                 obs.obs_frontend_recording_start()
             if parts[3] == "stop":  # /obs/recording/stop
                 obs.obs_frontend_recording_stop()
コード例 #2
0
ファイル: obsMidiClient.py プロジェクト: rygwdn/obs-scripts
    def handleMidi(self, cmdType, channel, value):
        if self.cmdType != cmdType:
            return

        if channel == self.startChannel:
            print("Start Recording")
            #obs.obs_frontend_recording_active
            #obs.obs_frontend_streaming_active
            #obs.obs_frontend_streaming_start
            obs.obs_frontend_recording_start()
        elif channel == self.endChannel:
            print("Stop Recording")
            #obs.obs_frontend_streaming_stop
            obs.obs_frontend_recording_stop()
        elif channel == self.pauseChannel:
            if obs.obs_frontend_recording_paused():
                print("Already paused")
            else:
                print("Pause Recording")
                obs.obs_frontend_recording_pause(True)
        elif channel == self.unpauseChannel:
            if obs.obs_frontend_recording_paused():
                print("Unpause Recording")
                obs.obs_frontend_recording_pause(False)
            else:
                print("Not paused")
コード例 #3
0
def stop_recording():
    global is_stopped

    if obs.obs_frontend_recording_active():
        obs.obs_frontend_recording_stop()
        print("Stop recording...")
        is_stopped = False
    else:
        obs.timer_remove(stop_recording)
        is_stopped = True
コード例 #4
0
def timer_check_recording():
    global Debug_Mode
    if Debug_Mode: print("Timer Event: timer_check_recording")

    global Enabled_Recording
    global Enabled_Streaming
    global Pause_Time
    global Recording_Start
    global Recording_Timer
    global Recording_End
    global Time_To_Record

    Recording_Active = False

    if Enabled_Recording and Recording_Start is not "None":
        if int(Recording_Start[:2]) <= int(Recording_End[:2]):
            if Debug_Mode: print("Normal Time")
            print("timer_check_recording(): [{}] vs [{}]".format(
                str(datetime.today().strftime("%a")), Avoid_These_Days))
            Recording_Active = time.strftime(
                "%H:%M") >= Recording_Start and time.strftime(
                    "%H:%M") <= Recording_End and str(datetime.today(
                    ).strftime("%a")) not in Avoid_These_Days
        else:
            if Debug_Mode: print("Backwards Time")
            Recording_Active = not (time.strftime("%H:%M") <= Recording_Start
                                    and
                                    time.strftime("%H:%M") >= Recording_End)

        if Recording_Active:
            if obs.obs_frontend_recording_active():
                if time.time() >= Time_To_Record and str(
                        datetime.today().strftime("%a")) in Avoid_These_Days:
                    if Debug_Mode: print("I'm going to stop recording now")
                    obs.obs_frontend_recording_stop()
                    obs.timer_add(timer_start_recording, Pause_Time)
                    Time_To_Record = time.time() + Recording_Timer

            else:
                obs.obs_frontend_recording_start()

            if obs.obs_frontend_streaming_active(
            ) is False and Enabled_Streaming is True:
                obs.obs_frontend_streaming_start()
        else:
            if obs.obs_frontend_recording_active():
                obs.obs_frontend_recording_stop()
            else:
                if Debug_Mode:
                    print("Sleeping Waiting for timer ", Recording_Start)

            if obs.obs_frontend_streaming_active(
            ) and Enabled_Streaming is True:
                obs.obs_frontend_streaming_stop()
コード例 #5
0
def timer_check_recording():
    # print("Timer Event: timer_check_recording")

    global enabled_flag

    if get_pid("gzclient"):
        # print("Find gzclient")
        if not obs.obs_frontend_recording_active():
            obs.obs_frontend_recording_start()
            # print("Recording is started.")
    elif obs.obs_frontend_recording_active():
        obs.obs_frontend_recording_stop()
コード例 #6
0
def timer_check_recording():
    # print("Timer Event: timer_check_recording")
    global cmd

    try:
        if not obs.obs_frontend_recording_active(
        ) and cmd.state == "start recording":
            # print("Find gzclient")
            obs.obs_frontend_recording_start()
            # print("Recording is started.")
        elif obs.obs_frontend_recording_active(
        ) and cmd.state == "stop recording":
            obs.obs_frontend_recording_stop()
            cmd.state = "idle..."
        elif cmd.state == "disable":
            # obs.obs_frontend_recording_stop()
            obs.timer_remove(timer_check_recording)
        # print("Not find gzclient")
        # print("Recording is stopped.")
    except:
        pass
コード例 #7
0
ファイル: obs_s2v.py プロジェクト: nachoverdon/Slippi2Video
def start(properties, button):
    # TODO: Add option to enable recursive search, directoryception.
    replays = glob(replays_dir + '/*.slp')
    found = len(replays)
    print('Replays found:', found)
    if (found):
        dolphin_process = launch_dolphin()
        time.sleep(3)

        # for each replay, load slippi and record video
        for replay in replays:
            watch_replay(replay)
            # Time it takes for a replay to load
            time.sleep(.8)

            if (obs.obs_frontend_recording_active()):
                obs.obs_frontend_recording_stop()

            obs.obs_frontend_recording_start()
            time.sleep(math.ceil(get_frames(replay) / 60) + 1)
            obs.obs_frontend_recording_stop()

        dolphin_process.terminate()
コード例 #8
0
def stopwatch():
    global source_name
    global timer

    source = obs.obs_get_source_by_name(source_name)
    diff = time.time() - start
    if stop_stream and diff >= stop_stream_time:
        timer = False
        if obs.obs_frontend_streaming_active():
            obs.obs_frontend_streaming_stop()
            print('Stopwatch - Stream stopped!')
        if obs.obs_frontend_recording_active():
            obs.obs_frontend_recording_stop()
            print('Stopwatch - Recording stopped!')
        obs.timer_remove(stopwatch)
        obs.remove_current_callback()
    text = str(timed(int(diff)))
    try:
        settings = obs.obs_data_create()
        obs.obs_data_set_string(settings, "text", text)
        obs.obs_source_update(source, settings)
        obs.obs_data_release(settings)
    except UnboundLocalError:
        pass
コード例 #9
0
def busy_thread():
    obs.obs_frontend_recording_stop()
    last_demo_processed = ""
    while run:
        if al and last_demo_processed != "":
            try:
                subprocess.check_output("pidof hl2_linux", shell=True)
            except subprocess.CalledProcessError:
                print("Attempting to auto restart TF2")
                obs.obs_frontend_recording_stop()
                subprocess.call("steam -applaunch 440 +playdemo "+df+"/"+last_demo_processed, shell=True)
                time.sleep(6)
        if not os.path.exists(wf):
            print("--ERROR: Watch folder doesn't exist!")
        elif not os.path.exists(rf):
            print("--ERROR: Record folder doesn't exist!")
        else:
            res = [fn for fn in os.listdir(wf) if fn.startswith("recstart.")]
            if(len(res) > 0):
                print("RECSTART Detected")
                os.remove(wf+"/"+res[0])
                last_demo_processed = "_".join(res[0].split(".")[1].split("_")[:2])
                obs.obs_frontend_recording_start()
            res = [fn for fn in os.listdir(wf) if fn.startswith("recstop.")]
            if len(res) > 0:
                print("RECSTOP DETECTED")
                os.remove(wf+"/"+res[0])
                if obs.obs_frontend_recording_active():
                    obs.obs_frontend_recording_stop()
                    newest = max(glob.glob(rf+"/*"), key=os.path.getctime)
                    newsplit = newest.split("/")
                    n = res[0].split(".")[1]
                    filename = "/".join(newsplit[:-1]) + "/" + n + "." + newsplit[-1].split(".")[1]
                    last_demo_processed = "_".join(n.split("_")[:2])
                    os.rename(newest, filename)
                    print("Recorded "+filename)
                    if(cb):
                        if not os.path.exists(df):
                            print("--ERROR: Demo folder doesn't exist!")
                        elif not os.path.exists(af):
                            print("--ERROR: Archive folder doesn't exist!")
                        else:
                            move_file("_".join(res[0].split(".")[1].split("_")[:2]))            
        time.sleep(.1)
コード例 #10
0
def frame_tick():
    global packet_reader
    global bot_num
    global elapsed
    global overtime
    global ended
    global kickoff
    global team
    global name
    global total_goals
    global own_goals
    global bot_list
    global goal_time
    global end_time
    global start_time
    global names
    global cheer
    global total_blue
    global total_orange
    global boost
    global boost_bar_pos
    global orange_name_item
    global blue_boost_item
    global ended

    boost_bar_pos = [10, 100]


    try:
        packet = packet_reader.get_packet()
    except:
        print("Can't read packet")
        return

    teams = [0, 1]
    # Todo: reset score after game
    if not league_on:
        league_info = league_status()
        if league_info is None:
            print('League has not started yet')
            return

    if time.time() >= end_time and auto_record:
        obs.obs_frontend_recording_stop()
        end_time = 999999999999999
        buffer_delay = time.time() + 20
        return

    if packet.game_info.is_match_ended:
        boost = [[0, 0], [0, 0]]
        total_blue = 0
        total_orange = 0
        do_reset_bar()
        boost_bar(boost)
        set_names('Blue-Name', '')
        set_names('Orange-Name', '')
        prev_total_goals = 0
        if obs.obs_frontend_recording_active() and end_time == 999999999999999 and not ended and auto_record:
            end_time = time.time() + end_delay
        ended = True
        return
    else:
        if not obs.obs_frontend_recording_active() and start_time == 999999999999999 and auto_record:
            #Todo: add start match delay around 3 seconds
            start_time = time.time() + 3
            ended = False
        if time.time() >= start_time and auto_record:
            obs.obs_frontend_recording_start()
            start_time = 999999999999999
            ended = False
            return
    ended = False



    for n in range(bot_num):
        team = packet.game_cars[n].team
        name = packet.game_cars[n].name.lower()

        if team == 0:
            boost[0][0] = packet.game_cars[n].boost / 100
        else:
            boost[0][1] = packet.game_cars[n].boost/100

    prev_overtime = overtime
    prev_ended = ended
    prev_total_goals = total_goals

    bot_num = packet.num_cars
    elapsed = packet.game_info.seconds_elapsed
    overtime = packet.game_info.is_overtime
    ended = packet.game_info.is_match_ended
    kickoff = packet.game_info.is_kickoff_pause

    for n in range(bot_num):
        team = packet.game_cars[n].team
        name = packet.game_cars[n].name
        goals = packet.teams[team].score
        own_goals = packet.game_cars[n].score_info.own_goals
        bot_list[n][0] = team
        bot_list[n][1] = name
        bot_list[n][2] = goals
        bot_list[n][3] = own_goals

    b_goal = 0
    r_goal = 0
    for n in range(bot_num):
        # Todo: streamline goal detection
        if bot_list[n][0] == 0:
            b_goal = b_goal + bot_list[n][2]
            r_goal = r_goal + bot_list[n][3]
        else:
            r_goal = r_goal + bot_list[n][2]
            b_goal = b_goal + bot_list[n][3]
            total_goals = r_goal + b_goal

    b_team_str = ''
    r_team_str = ''
    for n in range(bot_num):
        # Todo: streamline name
        if bot_list[n][0] == 0:
            if b_team_str != '':
                b_team_str = b_team_str + ' and ' + bot_list[n][1]
            else:
                b_team_str = bot_list[n][1]
        else:
            if r_team_str != '':
                r_team_str = r_team_str + ' and ' + bot_list[n][1]
            else:
                r_team_str = bot_list[n][1]

    if prev_total_goals != total_goals:  # Working
        current_event = 'goal'
    else:
        current_event = 'normal'

    if overtime and not prev_overtime:
        current_state = 'overtime'
    else:
        current_state = 'normal'

    if ended and not prev_ended:
        current_state = 'ended'
    else:
        current_state = 'normal'

    boost_bar(boost)

    set_names('Blue-Name', b_team_str)
    set_names('Orange-Name', r_team_str)

    if current_event == "goal":
        goal_time = time.time() + delay

    if time.time() >= goal_time:
        goal_time = 999999999999999
        toggle(True)

    if kickoff:
        toggle(False)

    return
コード例 #11
0
ファイル: obs_s2v.py プロジェクト: nachoverdon/Slippi2Video
def stop(properties, button):
    if (obs.obs_frontend_recording_active()):
        obs.obs_frontend_recording_stop()
    if (dolphin_process != None):
        dolphin_process.terminate()
コード例 #12
0
def start():

    print(c_ipA)
    print(c_port)

    # Open Port?
    """
	#open Port
	if (c_port != ""):
		cmd = 'netsh advfirewall firewall add rule name= \"Open Port ' + str(c_port) + '\" dir=in action=allow protocol=TCP localport='+str(c_port)
		#os.system('cmd /k ' + cmd)
		subprocess.call(['runas', '/user:Administrator', cmd])	
	else:
		#cmd = "echo Hello"#"netsh advfirewall firewall add rule name= \"Open Port \" dir=in action=allow protocol=TCP localport=80"
		#os.system('cmd /k ' + cmd)
		pass
	"""
    with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
        s.settimeout(5)
        if c_ipA != "" and c_port != "":
            print("Connecting with custom ip adress and port...")
            s.bind((c_ipA, int(c_port)))
        elif c_ipA == "" and c_port != "":
            print("Connecting with custom port...")
            s.bind((getIP(), int(c_port)))
        elif c_ipA != "" and c_port == "":
            print("Connecting with custom ip adress...")
            s.bind((c_ipA, PORT))
        else:
            print("Connecting with default values...")
            s.bind(ADDR)
        s.listen()
        print("Server Started...")

        global runServer
        global stopServer
        while runServer:
            print("Server Running...")
            try:
                conn, addr = s.accept()
                conn.settimeout(5)
                with conn:
                    print("connected by", addr)
                    connected = True
                    while connected:
                        try:
                            msg = conn.recv(1024)
                            if not msg:
                                break

                            msg = msg.decode(FORMAT)

                            if "scene" in msg:
                                try:
                                    scene = int(msg[5:])
                                    scenes = obs.obs_frontend_get_scenes()
                                    if len(scenes) >= (scene + 1):
                                        obs.obs_frontend_set_current_scene(
                                            scenes[scene])
                                except:
                                    pass
                            elif "s_mute" in msg:
                                try:
                                    msource = str(msg[6:])
                                    source = obs.obs_get_source_by_name(
                                        msource)
                                    if source is not None:
                                        obs.obs_source_set_muted(source, True)
                                except:
                                    pass
                            elif "s_unmute" in msg:
                                try:
                                    umsource = str(msg[8:])
                                    source = obs.obs_get_source_by_name(
                                        umsource)
                                    if source is not None:
                                        obs.obs_source_set_muted(source, False)
                                except:
                                    pass
                            elif "s_hide" in msg:
                                try:
                                    hsource = str(msg[6:])
                                    source = obs.obs_get_source_by_name(
                                        hsource)
                                    if source is not None:
                                        obs.obs_source_set_enabled(
                                            source, False)
                                except:
                                    pass
                            elif "s_unhide" in msg:
                                try:
                                    uhsource = str(msg[8:])
                                    source = obs.obs_get_source_by_name(
                                        uhsource)
                                    if source is not None:
                                        obs.obs_source_set_enabled(
                                            source, True)
                                except:
                                    pass

                            elif "st_start" in msg:
                                try:
                                    obs.obs_frontend_streaming_start()
                                except:
                                    pass
                            elif "st_stop" in msg:
                                try:
                                    obs.obs_frontend_streaming_stop()
                                except:
                                    pass
                            elif "re_start" in msg:
                                try:
                                    obs.obs_frontend_recording_start()
                                except:
                                    pass
                            elif "re_stop" in msg:
                                try:
                                    obs.obs_frontend_recording_stop()
                                except:
                                    pass
                            elif "re_pause" in msg:
                                try:
                                    if obs.obs_frontend_recording_paused():
                                        obs.obs_frontend_recording_pause(False)
                                    else:
                                        obs.obs_frontend_recording_pause(True)
                                except:
                                    pass

                            if "server_stop" in msg:
                                connected = False
                                runServer = False
                                stopServer = False
                        except:
                            if runServer == False:
                                connected = False

                    print("Closing Connection")
                    conn.close()
                    print("Server Stopped...")
                    sys.exit()
            except:
                pass

        print("Server Stopped...")
        sys.exit()
コード例 #13
0
def stop_recording():
    if manage_recording and obs.obs_frontend_recording_active(
    ) and get_current_scene_name() == closing_scene:
        obs.obs_frontend_recording_stop()
    obs.timer_remove(stop_recording)
コード例 #14
0
def do_stuff(props, prop):
    obs.obs_frontend_recording_start()
    obs.obs_frontend_recording_stop()
    time.sleep(0.35)

    # 1. Get Freeze Frame, Save it to disk somewhere
    latest_frame = helpers.get_latest_frame()
    sepia_frame = helpers.sepia_filter(latest_frame)
    mixed_frame = cv2.addWeighted(latest_frame, 0.4, sepia_frame, 0.6, 0)
    blurred_frame = helpers.blur(mixed_frame, kernel_size=21)
    # Dunno why default folder isn"t loading ?
    img_path = os.path.join("C:\\Users\\avikn\\Videos\\", "blurred.png")
    cv2.imwrite(img_path, blurred_frame)

    # 2. Add the freeze frame as a new full sized source
    current_scene_source = obs.obs_frontend_get_current_scene()
    obs.obs_frontend_set_current_preview_scene(current_scene_source)
    current_scene = obs.obs_scene_from_source(current_scene_source)
    freeze_frame = obs.obs_source_create("image_source", "FreezeFrame", None,
                                         None)

    image_settings = obs.obs_data_create()
    obs.obs_data_set_string(image_settings, "file", img_path)
    obs.obs_source_update(freeze_frame, image_settings)
    obs.obs_data_release(image_settings)

    freeze_item = obs.obs_scene_add(current_scene, freeze_frame)
    obs.obs_frontend_preview_program_trigger_transition()

    #3. Add A text source for the We'll be right back
    text = obs.obs_source_create("text_gdiplus", "BeRightBack", None, None)
    text_settings = obs.obs_data_create()
    font_settings = obs.obs_data_create()
    obs.obs_data_set_string(font_settings, "face", "Helvetica")
    obs.obs_data_set_int(font_settings, "size", 128)
    obs.obs_data_set_obj(text_settings, "font", font_settings)
    obs.obs_data_set_bool(text_settings, "outline", True)
    obs.obs_data_set_double(text_settings, "outline_size", 10)
    obs.obs_data_set_double(text_settings, "outline_color", 0)
    obs.obs_data_set_bool(text_settings, "extents", True)
    obs.obs_data_set_bool(text_settings, "extents_wrap", True)
    obs.obs_data_set_int(text_settings, "extents_cx", 300)
    obs.obs_data_set_int(text_settings, "extents_cy", 600)
    obs.obs_data_set_string(text_settings, "text", "We'll Be Right Back")
    obs.obs_source_update(text, text_settings)
    obs.obs_data_release(text_settings)

    text_item = obs.obs_scene_add(current_scene, text)

    #4. Add a media source for the sound byte
    song = obs.obs_source_create("ffmpeg_source", "Jingle", None, None)
    song_settings = obs.obs_data_create()
    obs.obs_data_set_string(song_settings, "local_file",
                            "C:\\Users\\avikn\\Downloads\\brb_jingle.mp3")
    obs.obs_source_update(song, song_settings)
    obs.obs_data_release(song_settings)

    song_item = obs.obs_scene_add(current_scene, song)

    #5. Trigger the transition so that it updates, mute other audio sources.
    obs.obs_frontend_preview_program_trigger_transition()
    desktop_audio = obs.obs_get_output_source(1)
    obs.obs_source_set_muted(desktop_audio, True)

    mic_audio = obs.obs_get_output_source(4)
    obs.obs_source_set_muted(mic_audio, True)

    #6. Artificial delay, then cleanup.
    time.sleep(4)

    obs.obs_sceneitem_remove(freeze_item)
    obs.obs_source_release(freeze_frame)

    obs.obs_sceneitem_remove(text_item)
    obs.obs_source_release(text)

    obs.obs_sceneitem_remove(song_item)
    obs.obs_source_release(song)

    obs.obs_source_set_muted(desktop_audio, False)
    obs.obs_source_set_muted(mic_audio, False)
    obs.obs_frontend_preview_program_trigger_transition()
コード例 #15
0
def timer_check():
    global Debug_Mode
    if Debug_Mode: print("Entrando en timer_check")

    global start_time_record
    global end_time_record

    # in_process_record = False
    updated_json = False

    # leer archivo con configuraciones
    print("Leyendo JSON")
    # json_path = "/peztech/static/obs.json"
    json_path = "D:/Documentos/PythonProjects/pezTech/static/obs.json"
    with open(json_path, 'r') as file:
        data = json.load(file)

        enabled_record = bool(data['enabled_record'])
        start_time_record = data['start_time']
        end_time_record = data['end_time']

        if start_time_record:
            start_time_record = datetime.strptime(start_time_record,
                                                  "%Y-%m-%d %H:%M:%S")
        else:
            enabled_record = False
        """if start_time_record == "" or start_time_record == end_time_record:
			enabled_record = False"""

        if end_time_record:
            end_time_record = datetime.strptime(end_time_record,
                                                "%Y-%m-%d %H:%M:%S")

        if enabled_record is True:
            print("Grabacion habilitada, procesando...")
            print("Hora de comienzo grabacion: " + str(start_time_record))
            print("Hora de fin grabacion: " + str(end_time_record))

            actual_time = datetime.now(pytz.timezone('America/Santiago'))
            actual_time = actual_time.strftime("%H:%M:%S")
            print("actualTime: " + str(actual_time))

            start_time_record_format = start_time_record.strftime("%H:%M:%S")
            actual_time_format = time.strftime(actual_time)

            # if int(start_time_record[:2]) <= int(end_time_record[:2]):
            if start_time_record and str(end_time_record) == "":
                in_process_record = actual_time_format >= start_time_record_format
            elif start_time_record and end_time_record:
                end_time_record_format = end_time_record.strftime("%H:%M:%S")
                # in_process_record = actual_time_format >= start_time_record_format and
                # actual_time_format <= end_time_record_format
                in_process_record = start_time_record_format <= actual_time_format <= end_time_record_format
            else:
                end_time_record_format = end_time_record.strftime("%H:%M:%S")
                in_process_record = not (actual_time_format >
                                         end_time_record_format)

            if in_process_record:
                print("La grabacion esta en proceso")
                # obs_frontend_recording_active: TRUE si la grabación está activa, False en caso contrario.
                if obs.obs_frontend_recording_active():
                    print("En proceso de grabado...")
                    # si la hora actual es mayor a la hora de fin de la grabacion, se finaliza
                    if end_time_record:
                        if Debug_Mode: print("Dejando de grabar ahora")
                        #
                        obs.obs_frontend_recording_stop(
                        )  # detiene la grabacion
                        data['enabled_record'] = "False"
                        data['start_time'] = ""
                        data['end_time'] = ""
                        data['description_record'] = ""
                        updated_json = True
                else:
                    print("Iniciando la grabacion...")
                    # si la grabacion no esta activa, se inicia
                    obs.obs_frontend_recording_start()  # Inicia la grabación.
            else:
                print(
                    "La grabacion aun no esta en el tiempo de comienzo o no esta activa"
                )
                # obs_frontend_recording_active: TRUE si la grabación está activa, False en caso contrario.
                if obs.obs_frontend_recording_active():
                    print("in_process_record FALSE, FINALIZANDO LA GRABACION")
                    obs.obs_frontend_recording_stop()  # Detiene la grabación.
                    data['enabled_record'] = "False"
                    data['start_time'] = ""
                    data['end_time'] = ""
                    data['description_record'] = ""
                    updated_json = True
        else:
            print("No existe grabacion habilitada")

    if updated_json is True:
        print("Actualizando JSON")
        with open(json_path, 'w') as file:
            file.write(json.dumps(data))
            obs.timer_remove(timer_check)
def stop_recording():
    if obs.obs_frontend_recording_active():
        obs.obs_frontend_recording_stop()
        obs.timer_remove(stop_recording)
    start_recording()
コード例 #17
0
def update_text():
    global cal_url
    global interval
    global source_names
    global CLIENT_SECRET_FILE
    global max_events
    global images_path
    global image_sources

    # Gets stored credentials (taken from Calendar API quickstart)
    credentials = get_credentials()
    http = credentials.authorize(httplib2.Http())
    service = discovery.build('calendar', 'v3', http=http)

    # Time objects using datetime
    dt_now = datetime.datetime.utcnow()
    now = datetime.datetime.utcnow().isoformat(
    ) + 'Z'  # 'Z' indicates UTC time

    # Gets events currently happending by setting bounds to events happening within a second of current datetime
    events = service.events().list(
        calendarId=cal_url,
        timeMin=now,
        timeMax=(dt_now + datetime.timedelta(0, 1)).isoformat() + 'Z',
        maxResults=max_events,
        singleEvents=True,
        orderBy='startTime').execute()

    # Logs the events to console
    for event in events['items']:
        print(event['summary'])

    # Updates the text for each event
    count = 0
    stream_event_happening = False
    record_event_happening = False
    for event in events['items']:
        if (count >= max_events):
            break
        text = event['summary']
        settings = obs.obs_data_create()
        obs.obs_data_set_string(settings, "text", text)
        source = obs.obs_get_source_by_name(source_names[count])
        obs.obs_source_update(source, settings)
        obs.obs_data_release(settings)
        obs.obs_source_release(source)

        settings2 = obs.obs_data_create()
        obs.obs_data_set_string(settings2, "file",
                                "{}/{}.jpg".format(images_path, text))
        source2 = obs.obs_get_source_by_name(image_sources[count])
        obs.obs_source_update(source2, settings2)
        obs.obs_data_release(settings2)
        obs.obs_source_release(source2)

        count += 1

        # Checks for the "Stream" event and starts streaming if not doing so already
        if text == "Stream":
            stream_event_happening = True
            if ~obs.obs_frontend_streaming_active():
                obs.obs_frontend_streaming_start()
        # Likewise, checks for "Record" event
        elif text == "Record":
            record_event_happening = True
            if ~obs.obs_frontend_recording_active():
                obs.obs_frontend_recording_start()

    # Stops the stream/recording if the Google Calendar event is no longer occuring
    if obs.obs_frontend_streaming_active() and not (stream_event_happening):
        obs.obs_frontend_streaming_stop()
    if obs.obs_frontend_recording_active() and not (record_event_happening):
        obs.obs_frontend_recording_stop()

    # Sets any specified sources to blank if here is no event
    for x in range(count, max_events):
        text = ""
        settings = obs.obs_data_create()
        obs.obs_data_set_string(settings, "text", text)
        source = obs.obs_get_source_by_name(source_names[x])
        obs.obs_source_update(source, settings)
        obs.obs_data_release(settings)
        obs.obs_source_release(source)

        settings2 = obs.obs_data_create()
        obs.obs_data_set_string(settings2, "file", text)
        source2 = obs.obs_get_source_by_name(image_sources[x])
        obs.obs_source_update(source2, settings2)
        obs.obs_data_release(settings2)
        obs.obs_source_release(source2)