forked from DRMTalks/devine
Mark track as stopping when skipping segments
This commit is contained in:
parent
b482f86bb3
commit
f4ad7a2e6c
|
@ -524,9 +524,6 @@ class DASH:
|
||||||
download_size = download.result()
|
download_size = download.result()
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
stop_event.set()
|
stop_event.set()
|
||||||
if not has_stopped:
|
|
||||||
has_stopped = True
|
|
||||||
progress(downloaded="[orange]STOPPING")
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
stop_event.set()
|
stop_event.set()
|
||||||
if has_stopped:
|
if has_stopped:
|
||||||
|
@ -537,24 +534,28 @@ class DASH:
|
||||||
progress(downloaded="[red]FAILING")
|
progress(downloaded="[red]FAILING")
|
||||||
traceback.print_exception(e)
|
traceback.print_exception(e)
|
||||||
log.error(f"Segment Download worker threw an unhandled exception: {e!r}")
|
log.error(f"Segment Download worker threw an unhandled exception: {e!r}")
|
||||||
else:
|
continue
|
||||||
if stop_event.is_set():
|
|
||||||
# skipped
|
|
||||||
continue
|
|
||||||
progress(advance=1)
|
|
||||||
|
|
||||||
now = time.time()
|
if stop_event.is_set():
|
||||||
time_since = now - last_speed_refresh
|
if not has_stopped:
|
||||||
|
has_stopped = True
|
||||||
|
progress(downloaded="[orange]STOPPING")
|
||||||
|
continue
|
||||||
|
|
||||||
if download_size: # no size == skipped dl
|
progress(advance=1)
|
||||||
download_sizes.append(download_size)
|
|
||||||
|
|
||||||
if time_since > 5 or finished_threads == len(segments):
|
now = time.time()
|
||||||
data_size = sum(download_sizes)
|
time_since = now - last_speed_refresh
|
||||||
download_speed = data_size / time_since
|
|
||||||
progress(downloaded=f"DASH {filesize.decimal(download_speed)}/s")
|
if download_size: # no size == skipped dl
|
||||||
last_speed_refresh = now
|
download_sizes.append(download_size)
|
||||||
download_sizes.clear()
|
|
||||||
|
if time_since > 5 or finished_threads == len(segments):
|
||||||
|
data_size = sum(download_sizes)
|
||||||
|
download_speed = data_size / time_since
|
||||||
|
progress(downloaded=f"DASH {filesize.decimal(download_speed)}/s")
|
||||||
|
last_speed_refresh = now
|
||||||
|
download_sizes.clear()
|
||||||
if has_failed:
|
if has_failed:
|
||||||
progress(downloaded="[red]FAILED")
|
progress(downloaded="[red]FAILED")
|
||||||
if has_stopped:
|
if has_stopped:
|
||||||
|
|
|
@ -364,9 +364,6 @@ class HLS:
|
||||||
download_size = download.result()
|
download_size = download.result()
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
stop_event.set()
|
stop_event.set()
|
||||||
if not has_stopped:
|
|
||||||
has_stopped = True
|
|
||||||
progress(downloaded="[orange]STOPPING")
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
stop_event.set()
|
stop_event.set()
|
||||||
if has_stopped:
|
if has_stopped:
|
||||||
|
@ -377,24 +374,28 @@ class HLS:
|
||||||
progress(downloaded="[red]FAILING")
|
progress(downloaded="[red]FAILING")
|
||||||
traceback.print_exception(e)
|
traceback.print_exception(e)
|
||||||
log.error(f"Segment Download worker threw an unhandled exception: {e!r}")
|
log.error(f"Segment Download worker threw an unhandled exception: {e!r}")
|
||||||
else:
|
continue
|
||||||
if stop_event.is_set():
|
|
||||||
# skipped
|
|
||||||
continue
|
|
||||||
progress(advance=1)
|
|
||||||
|
|
||||||
now = time.time()
|
if stop_event.is_set():
|
||||||
time_since = now - last_speed_refresh
|
if not has_stopped:
|
||||||
|
has_stopped = True
|
||||||
|
progress(downloaded="[orange]STOPPING")
|
||||||
|
continue
|
||||||
|
|
||||||
if download_size: # no size == skipped dl
|
progress(advance=1)
|
||||||
download_sizes.append(download_size)
|
|
||||||
|
|
||||||
if time_since > 5 or finished_threads == len(master.segments):
|
now = time.time()
|
||||||
data_size = sum(download_sizes)
|
time_since = now - last_speed_refresh
|
||||||
download_speed = data_size / time_since
|
|
||||||
progress(downloaded=f"HLS {filesize.decimal(download_speed)}/s")
|
if download_size: # no size == skipped dl
|
||||||
last_speed_refresh = now
|
download_sizes.append(download_size)
|
||||||
download_sizes.clear()
|
|
||||||
|
if time_since > 5 or finished_threads == len(master.segments):
|
||||||
|
data_size = sum(download_sizes)
|
||||||
|
download_speed = data_size / time_since
|
||||||
|
progress(downloaded=f"HLS {filesize.decimal(download_speed)}/s")
|
||||||
|
last_speed_refresh = now
|
||||||
|
download_sizes.clear()
|
||||||
if has_failed:
|
if has_failed:
|
||||||
progress(downloaded="[red]FAILED")
|
progress(downloaded="[red]FAILED")
|
||||||
if has_stopped:
|
if has_stopped:
|
||||||
|
|
Loading…
Reference in New Issue