From 35501bdb9c2856db83faebb0f266e67a7d19a73d Mon Sep 17 00:00:00 2001 From: rlaphoenix Date: Sat, 9 Mar 2024 17:52:50 +0000 Subject: [PATCH] fix(DASH): Fix merge regression from recent commit An else tree was used in https://github.com/rlaphoenix/devine/commit/4d6c72ba307b366b3df72cc5243bf8b6a593de11 when it shouldn't have been. Fixes #81 --- devine/core/manifests/dash.py | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/devine/core/manifests/dash.py b/devine/core/manifests/dash.py index 72f5d26..ebb2f5b 100644 --- a/devine/core/manifests/dash.py +++ b/devine/core/manifests/dash.py @@ -496,23 +496,22 @@ class DASH: f.write(init_data) if len(segments_to_merge) > 1: progress(downloaded="Merging", completed=0, total=len(segments_to_merge)) - else: - for segment_file in segments_to_merge: - segment_data = segment_file.read_bytes() - # TODO: fix encoding after decryption? - if ( - not drm and isinstance(track, Subtitle) and - track.codec not in (Subtitle.Codec.fVTT, Subtitle.Codec.fTTML) - ): - segment_data = try_ensure_utf8(segment_data) - segment_data = segment_data.decode("utf8"). \ - replace("‎", html.unescape("‎")). \ - replace("‏", html.unescape("‏")). \ - encode("utf8") - f.write(segment_data) - f.flush() - segment_file.unlink() - progress(advance=1) + for segment_file in segments_to_merge: + segment_data = segment_file.read_bytes() + # TODO: fix encoding after decryption? + if ( + not drm and isinstance(track, Subtitle) and + track.codec not in (Subtitle.Codec.fVTT, Subtitle.Codec.fTTML) + ): + segment_data = try_ensure_utf8(segment_data) + segment_data = segment_data.decode("utf8"). \ + replace("‎", html.unescape("‎")). \ + replace("‏", html.unescape("‏")). \ + encode("utf8") + f.write(segment_data) + f.flush() + segment_file.unlink() + progress(advance=1) track.path = save_path if callable(track.OnDownloaded):