forked from DRMTalks/devine
HLS: Skip merging continuity if all segments were skipped
If all segments of a continuity is skipped, i.e. by OnSegmentFilter, then this code fails as the folder wouldn't exist.
This commit is contained in:
parent
cd194e3192
commit
bd185126b6
|
@ -325,20 +325,21 @@ class HLS:
|
||||||
last_speed_refresh = now
|
last_speed_refresh = now
|
||||||
download_sizes.clear()
|
download_sizes.clear()
|
||||||
|
|
||||||
with open(discontinuity_save_path, "wb") as f:
|
if discontinuity_save_dir.exists():
|
||||||
for segment_file in sorted(discontinuity_save_dir.iterdir()):
|
with open(discontinuity_save_path, "wb") as f:
|
||||||
segment_data = segment_file.read_bytes()
|
for segment_file in sorted(discontinuity_save_dir.iterdir()):
|
||||||
if isinstance(track, Subtitle):
|
segment_data = segment_file.read_bytes()
|
||||||
segment_data = try_ensure_utf8(segment_data)
|
if isinstance(track, Subtitle):
|
||||||
if track.codec not in (Subtitle.Codec.fVTT, Subtitle.Codec.fTTML):
|
segment_data = try_ensure_utf8(segment_data)
|
||||||
# decode text direction entities or SubtitleEdit's /ReverseRtlStartEnd won't work
|
if track.codec not in (Subtitle.Codec.fVTT, Subtitle.Codec.fTTML):
|
||||||
segment_data = segment_data.decode("utf8"). \
|
# decode text direction entities or SubtitleEdit's /ReverseRtlStartEnd won't work
|
||||||
replace("‎", html.unescape("‎")). \
|
segment_data = segment_data.decode("utf8"). \
|
||||||
replace("‏", html.unescape("‏")). \
|
replace("‎", html.unescape("‎")). \
|
||||||
encode("utf8")
|
replace("‏", html.unescape("‏")). \
|
||||||
f.write(segment_data)
|
encode("utf8")
|
||||||
segment_file.unlink()
|
f.write(segment_data)
|
||||||
shutil.rmtree(discontinuity_save_dir)
|
segment_file.unlink()
|
||||||
|
shutil.rmtree(discontinuity_save_dir)
|
||||||
|
|
||||||
if DOWNLOAD_LICENCE_ONLY.is_set():
|
if DOWNLOAD_LICENCE_ONLY.is_set():
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue