diff --git a/pyinstalive/dlfuncs.py b/pyinstalive/dlfuncs.py index bd9ac8b..4236405 100644 --- a/pyinstalive/dlfuncs.py +++ b/pyinstalive/dlfuncs.py @@ -143,6 +143,7 @@ def merge_segments(): live_segments_path = os.path.normpath(pil.broadcast_downloader.output_dir) if pil.segments_json_thread_worker and pil.segments_json_thread_worker.is_alive(): + pil.kill_segment_thread = True pil.segments_json_thread_worker.join() if pil.comment_thread_worker and pil.comment_thread_worker.is_alive(): diff --git a/pyinstalive/helpers.py b/pyinstalive/helpers.py index 180d8e9..9349f49 100644 --- a/pyinstalive/helpers.py +++ b/pyinstalive/helpers.py @@ -81,7 +81,7 @@ def check_if_guesting(): def generate_json_segments(): - while not pil.broadcast_downloader.is_aborted: + while True: pil.livestream_obj['delay'] = (int(pil.epochtime) - pil.livestream_obj['published_time']) if 'initial_buffered_duration' not in pil.livestream_obj and pil.broadcast_downloader.initial_buffered_duration: pil.livestream_obj['initial_buffered_duration'] = pil.broadcast_downloader.initial_buffered_duration @@ -92,7 +92,10 @@ def generate_json_segments(): if not pil.broadcast_downloader.stream_id: pil.broadcast_downloader.stream_id = pil.livestream_obj['id'] #check_if_guesting() - time.sleep(2.5) + if pil.kill_segment_thread: + break + else: + time.sleep(2.5) except Exception as e: logger.warn(str(e)) diff --git a/pyinstalive/pil.py b/pyinstalive/pil.py index 78ea556..bd8878a 100644 --- a/pyinstalive/pil.py +++ b/pyinstalive/pil.py @@ -47,6 +47,7 @@ def initialize(): global verbose global skip_merge global config_login_overridden + global kill_segment_thread ig_api = None ig_user = "" ig_pass = "" @@ -81,4 +82,5 @@ def initialize(): proxy = None verbose = False skip_merge = False - config_login_overridden = False \ No newline at end of file + config_login_overridden = False + kill_segment_thread = False \ No newline at end of file